CS FundamentalsVery hardGATE CS
Which of these is the correct reason that the Unix `rename(old, new)` within one file system is widely used to update a file safely (write a temp file, then rename over the original)?
- A. rename copies the data and verifies a checksum
- B. rename locks the file against all readers forever
- C. rename within a file system is atomic: observers see either the old file or the new one, never a half-written file
- D. rename works across file systems by moving blocks
Correct answer: C. rename within a file system is atomic: observers see either the old file or the new one, never a half-written file
POSIX requires rename to replace the target atomically. Combined with fsync of the temp file (and the directory), it gives crash-safe updates. Across file systems rename fails with EXDEV.
More Operating Systems questions
- A process opens the same file twice with two separate open() calls, getting fd 3 and fd 4, and also calls dup(3) to get fd 5. It then…
- After fork(), a parent and child both write to a file descriptor that was opened before the fork, without OAPPEND. Why do their writes not…
- Which statement about access-control lists (ACLs) versus capability lists is correct?
- A setuid-root program calls access(path, ROK) to check the real user may read path, then calls open(path). Which vulnerability does this…
- Which defence makes a stack-buffer-overflow attack that jumps to injected shellcode on the stack fail, even if the return address is…
- In the Bell–LaPadula confidentiality model, which rules apply?