Undocumented feature in Sys5: synchronous write

guy at rlgvax.UUCP guy at rlgvax.UUCP
Wed May 30 14:59:07 AEST 1984


> Normally, writes to normal files are cached in the buffer pool and
> written out to disk with some delay.
> Some database people asked me to introduce a "write-through" system
> call, i.e. a write that writes data immediately to disk, thus avoiding
> disk consistency problems after a system crash. Looking at the Sys5 code,
> I found that the code for doing this is already there: in <sys/file.h>
> you have
> 	#define FSYNC   00020
> but an appropriate define
> 	#define O_SYNC  00020
> is missing from <fcntl.h> and also the docu doesn't mention it.

Yup.  Welcome to the wonderful world of UNIX; a treasure hunt each day.
The annoying thing is that some of the stuff are real treasures, but the
authors have seen fit to bury them deeply.  I suspect this feature was
introduced "accidentally"(!); it may have been a side-effect of the changes
to the file system code in System V to write file system data structures in
a specified order.  On the other hand, if somebody felt this wasn't useful
enough to applications to finish implementing (i.e., putting in the O_SYNC bit)
and documenting, I'd like to know what kind of applications they've ever seen.
At least Berkeley documented "fsync".

	Guy Harris
	{seismo,ihnp4,allegra}!rlgvax!guy



More information about the Comp.unix.wizards mailing list