From owner-freebsd-current Sat May 1 12:35:55 1999 Delivered-To: freebsd-current@freebsd.org Received: from godzilla.zeta.org.au (godzilla.zeta.org.au [203.26.10.9]) by hub.freebsd.org (Postfix) with ESMTP id 076FF14BF9 for ; Sat, 1 May 1999 12:35:52 -0700 (PDT) (envelope-from bde@godzilla.zeta.org.au) Received: (from bde@localhost) by godzilla.zeta.org.au (8.8.7/8.8.7) id FAA08996; Sun, 2 May 1999 05:35:30 +1000 Date: Sun, 2 May 1999 05:35:30 +1000 From: Bruce Evans Message-Id: <199905011935.FAA08996@godzilla.zeta.org.au> To: dg@root.com, oppermann@pipeline.ch Subject: Re: Porting Greg Lehey's rawio.c from FreeBSD to Linux... Cc: brad@shub-internet.org, FreeBSD-current@FreeBSD.ORG, grog@lemis.com, mjacob@feral.com Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG >> >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 majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message