<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<style type="text/css">body p { margin-bottom: 0.2cm; margin-top: 0pt; } </style>
</head>
<body bidimailui-detected-decoding-type="UTF-8" bgcolor="#FFFFFF"
text="#000000">
<div class="moz-cite-prefix">On 07/27/2012 02:52 PM, Elazar
Leibovich wrote:<br>
</div>
<blockquote
cite="mid:CAHNTFm+5ums2vXvAq3B8hGrLzxq9poXuKpJc-V4kQEWUoRBkTg@mail.gmail.com"
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.<br>
<br>
Shachar<br>
<br>
<pre class="moz-signature" cols="72">--
Shachar Shemesh
Lingnu Open Source Consulting Ltd.
<a class="moz-txt-link-freetext" href="http://www.lingnu.com">http://www.lingnu.com</a>
</pre>
</body>
</html>