Open GitMensch opened 3 years ago
given the way fsync
is written , I imagine this would just be a wrapper for fsync
. would that be useful?
I haven't checked the fsync
implementation. The documented difference between those are:
fsync
does the syncing of the buffers and returns when that is either finished or an error occursfdatasync
: same as before + "forcing of all currently queued I/O operations associated with the file indicated to the synchronized I/O completion state"fsync
with _POSIX_SYNCHRONIZED_IO
defined before inclusion of unistd.h: same as fdatasync
+ "all I/O operations shall be completed as defined for synchronized I/O file integrity completion"The current implementation definitely does not include anything about _POSIX_SYNCHRONIZED_IO
, so I don't know if it is the third option or second or first. I think a wrapper is only reasonable if there are differences or if the current implementation is actually identical to the defined fdatasync
behavior.
i don't think i wrote the fsync, but all it does is duplicate the handle then close the duplicated handle. I don't even know if that is correct, e.g. should it do a __flush() first.... I can't see fdatasync doing more than that because there really isn't anything more you can do...
Not sure, commonly fflush
will ensure everything from the user-buffers used for write
is at least in the filesystem cache, while fsync
will wait tell the OS to place it to the disk and waits until this is done.
What part of this is done by the current implementation of fsync
?
the current version of fsync just dups the handle and closes the dup, which I assume writes the file system buffers to disk. That says nothing about what is stored locally in the program's buffers though...
Mainly wondering: Would it be reasonable to add
fdatasync
or would it be better to only supportfsync
, as it is now?