CS FundamentalsHardGATE CS · Amazon/Microsoft SDE MCQ
In a directory, `ln data h` and `ln -s data s` are run, and then `mv data data2` renames the original within the same file system. What happens on `cat h` and `cat s`?
- A. Both print the contents, since both links follow the inode
- B. Both fail, since the name data no longer exists
- C. cat s works but cat h fails, since hard links store the name
- D. cat h prints the contents, but cat s fails with no such file
Correct answer: D. cat h prints the contents, but cat s fails with no such file
A hard link is another directory entry for the same inode, so renaming the old name does not affect it. A symbolic link stores the path 'data', which no longer resolves after the rename, so it dangles.
More Operating Systems questions
- What does it mean that the read() system call on a terminal is 'blocking', and what state does the process enter while no input is…
- Which statement about thrashing and the degree of multiprogramming is correct?
- Two threads acquire mutexes: T1 locks A then B; T2 locks B then A. Which change prevents deadlock while still letting both threads hold…
- A system uses demand paging with a 4 KB page, and a process allocates a fresh 1 MB zeroed buffer with mmap but touches only its first 10…
- Which statement about a system call compared with an ordinary function call is correct?
- Five batch jobs arrive together with run times 9, 6, 3, 5 and x, where x < 3. In what order should they run to minimise average turnaround…