CS FundamentalsVery hardGATE CS
An application calls fsync() after writing a new file and then renames it into place. Why must it also fsync the containing directory on many file systems?
- A. fsync on a file already syncs every directory in its path
- B. The directory entry (rename) is metadata of the directory; without syncing the directory, the new name may not be durable after a crash
- C. rename cannot be undone by a crash
- D. Directories cannot be fsynced
Correct answer: B. The directory entry (rename) is metadata of the directory; without syncing the directory, the new name may not be durable after a crash
POSIX fsync on a file guarantees the file's data and inode, not the directory entries that reference it. Syncing the parent directory makes the rename durable.
More Operating Systems questions
- A TLB with 32 entries uses 4 KB pages. A program loops over an array of 40 pages, touching each page once per pass. With LRU replacement…
- How many page faults occur when a process sequentially reads a 1 MB file through mmap() with 4 KB pages, assuming no read-ahead and none…
- Dirty pages are written back by a background daemon every 30 s. A process writes 100 MB to a file and then the machine loses power 10 s…
- A process performs 100 random 4 KB reads on a disk with 10 ms average access time and on an SSD with 0.1 ms access time. Roughly what are…
- Round Robin with quantum 3 ms; processes (arrival, burst): P1 (0, 5), P2 (1, 3), P3 (2, 8), P4 (3, 6). What are the completion times of…
- What values are printed (in any order)? (Every fork() succeeds.) c int main() { int x = 0; for (int i = 0; i < 2; i++) { if (fork() == 0)…