What's the practical use of the error close() returns?
Daniel Shahaf
d.s at daniel.shahaf.name
Sun Jul 29 02:12:13 IDT 2012
Shachar Shemesh wrote on Sat, Jul 28, 2012 at 09:56:40 +0300:
> On 07/27/2012 02:52 PM, Elazar Leibovich wrote:
> >
> > (as mentioned earlier, the "no space left" could just as well happen
> > after the file was closed, so I don't mind that much it's not reported
> > on a close())
> >
> Ehm, no.
>
> First of all, please note a subtle but important difference between your
> question and Orna's answer. You asked about close, she answered about
> fclose.
>
> Fclose is an stdio function, and performs a flush of the (user space)
> buffers. As such, it is possible for it to run out of disk space. Close,
> on the other hand, might only run out of disk space on remote file
> systems (such as nfs), and even then, it depends on the local cache
> coherency policy. I fail to see how an "out of disk space" might
> possibly happen AFTER close, as all that's left then are caches.
>
> Please note that just because the data is in the OS caches, rather than
> on disk, this does not mean that anything can change as far as file
> system notion of the data goes. By the time close returns, the OS has
> already allocated space for the data, and decided where on the disk this
> data should go. It is not possible for it to fail after that point
> because of lack of disk space.
So if the disk hardware fails after close() returns but before the OS
caches are flushed...
More information about the Linux-il
mailing list