3 ms·
No, a null implementation is permitted because write() could potentially already provide these guarantees internally, at which point fsync() would be able to sa
by mehrdadn 6y ago
No, a null implementation is permitted because write() could potentially already provide these guarantees internally, at which point fsync() would be able to satisfy all requirements without needing to do anything. That sentence does not mean you could take any arbitrary system and slap a no-op fsync() onto it and somehow still maintain these guarantees.
- formerly_proven 6y agoThe next sentence in the document would have told you that this conception is simply wrong. fsync does not give you durability guarantees. POSIX is worded such that a system with no durability can be compliant. > It is explicitly intended that a null implementation is permitted. This could be valid in the case where the system cannot assure non-volatile storage under any circumstances or when the system is highly fault-tolerant and the functionality is not required. In the middle ground between these extremes, fsync() might or might not actually cause data to be written where it is safe from a power failure. The conformance document should identify at least that one configuration exists (and how to obtain that configuration) where this can be assured for at least some files that the user can select to use for critical data. It is not intended that an exhaustive list is required, but rather sufficient information is provided so that if critical data needs to be saved, the user can determine how the system is to be configured to allow the data to be written to non-volatile storage. Again, the way the normative language you quoted above is written makes it abundantly clear (for a standard) that fsync doing anything is entirely optional.
- mehrdadn 6y agoDid you read the first sentence in that paragraph? That entire paragraph is talking about when _POSIX_SYNCHRONIZED_IO is not defined: > If _POSIX_SYNCHRONIZED_IO is not defined, the wording relies heavily on the conformance document to tell the user what can be expected from the system. [...] If you check your Linux system, you will see _POSIX_SYNCHRONIZED_IO is defined: printf "%s\n" "#include <unistd.h>" "#ifdef _POSIX_SYNCHRONIZED_IO" "#error _POSIX_SYNCHRONIZED_IO is defined" "#endif" | gcc -fsyntax-only -x c - and hence the rest of that paragraph isn't talking about this situation.