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?

  1. A. fsync on a file already syncs every directory in its path
  2. B. The directory entry (rename) is metadata of the directory; without syncing the directory, the new name may not be durable after a crash
  3. C. rename cannot be undone by a crash
  4. 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

Exams that ask this topic