<div dir="ltr">BTW - everyone here keeps assuming that close(2) is called on disk files, what about other types of file descriptors (sockets, pipes, character and block devices, "virtual filesystem" files)? How would you adjust your answers for that case?<br>
<br><div class="gmail_quote">On 28 July 2012 16:56, Shachar Shemesh <span dir="ltr"><<a href="mailto:shachar@shemesh.biz" target="_blank">shachar@shemesh.biz</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
<div>On 07/27/2012 02:52 PM, Elazar
Leibovich wrote:<br>
</div>
<blockquote type="cite">
<div dir="ltr"><br>
<div>(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())<br>
<div><br>
</div>
</div>
</div>
</blockquote>
Ehm, no.<br>
<br>
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.<br>
<br>
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.<br>
<br>
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.<br>
<br>
As I said before, for local file systems, this is also true of
"write". The main reason we need to check the return code of "close"
is because you never know who will run your program over NFS. Over
NFS, for performance reasons, it is possible for a "write" command
to fail after the kernel has already returned to user space with a
success indication. Doing it otherwise will result in horrible
latency for anyone working over NFS. All such errors will get
reported on the next operation over the file descriptor: close.<span class="HOEnZb"><font color="#888888"><br>
<br>
Shachar<br>
<br>
<pre cols="72">--
Shachar Shemesh
Lingnu Open Source Consulting Ltd.
<a href="http://www.lingnu.com" target="_blank">http://www.lingnu.com</a>
</pre>
</font></span></div>
<br>_______________________________________________<br>
Linux-il mailing list<br>
<a href="mailto:Linux-il@cs.huji.ac.il">Linux-il@cs.huji.ac.il</a><br>
<a href="http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il" target="_blank">http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br><div dir="ltr">
<a href="http://www.linkedin.com/in/gliderflyer" target="_blank">
<span>
<img src="http://s4.licdn.com/scds/common/u/img/webpromo/btn_viewmy_160x25.png" alt="View my profile on LinkedIn" height="25" width="160">
</span></a></div><br>
</div>