>> >Linux' fsync() works only on directories, not on files.
>> 
>>    Huh? That doesn't make any sense. The "f" in fsync() stands for "file".
>
>It does write the file to the disk but not the inode. To get the inode
>on the disk you have to fsync() the directory (which sync'ed the whole
>FS before 2.0.35). Kinda stupid...

fsync() can't reasonably sync everything on filesystems with async metadata.
It think it should sync the file's contents and inode, but not directory
entries pointing to the inode.  fsync() on the directories containing the
entries that you care about seems reasonable.

>If you can't believe it:
>http://www.ornl.gov/its/archives/mailing-lists/qmail/1998/05/threads.html#00691

No one mentioned the POSIX.1b way, perhaps because it has only been
standard for 4-5 years.  It has:

__POSIX_FSYNC feature test macro.  If this is defined, then fsync() exists
and synchronizes the file to an implementation-defined stage.

__POSIX_SYNCHRONIZED_IO feature test macro.  If this is defined,
then fsync() synchronizes to completion.  Also, fdatasync() exists
and synchronizes the file's contents, like Linux's fsync() does.  Also,
there are open flags ODSYNC, O_RSYNC and O_SYNC.  O_SYNC and O_DSYNC have
similar semantics to fsync() and fdatasync().  O_RSYNC is to synchronise
metadata changed by reads (mainly access timestamps).

Bruce


To Unsubscribe: send mail to majord...@freebsd.org
with "unsubscribe freebsd-current" in the body of the message

Reply via email to