[prev] 45 [next]

File System Operations (cont)

int fsync(int FileDesc)
  • ensure that data associated with FileDesc is written to storage

Unix/Linux makes heavy use of buffering
  • data "written" to a file is initially stored in memory buffers
  • eventually, it makes its way onto permanent storage device
  • fsync() forces this to happen now. This can be important when dealing with critical transactions.

Writing to permanent storage is typically an expensive operation
  • fsync() is normally called just once at process exit

Note also: fflush() forces stdio buffers to be copied to kernel buffers