Re: imapd and synchronous writes

Theodore Ts'o (tytso@mit.edu)
Thu, 14 Mar 1996 20:31:40 -0500


Date: Thu, 14 Mar 1996 12:40:37 -0500 (EST)
From: John Gardiner Myers <jgm+@cmu.edu>

"Theodore Ts'o" <tytso@MIT.EDU> writes:
> Actually, there is, but it's not portable. If you open the directory
> using open, and then call fsync on the resulting file descriptor, you
> will forcibly commit the directory change. This is *not* guaranteed to
> work on all POSIX systems, and indeed it may not work on many. But it
> will work under Linux.

How is an application, written to compile on a broad range of unix
systems, to know it has to take this particular set of steps?

Well, now that you know, you can do it. An application which does an
open() on the directory, followed by a fsync(), shouldn't break on a
broad range of unix systems. The worse that will happen is that either
the open() or the fsync() will fail.

For better or for worse, the POSIX.1 standard makes very little
guarantees about when data will actually get syncronized to disk; it
doesn't even define fsync(). fsync() is defined in POSIX.4, but it's
not defined well at all. What an implementation will do to assure that
data associated with the file is syncronized to disk is purely
implementation specific.

- Ted