File corruption with KSaveFile on full disk

Thiago Macieira thiago at kde.org
Fri Feb 6 19:56:39 GMT 2009


Michael Pyne wrote:
>On Friday 06 February 2009, David Faure wrote:
>> On Tuesday 20 January 2009, Thiago Macieira wrote:
>> > The problem with buffered mode is that write() will report that it
>> > wrote all bytes, but the saving of them to disk might fail. In that
>> > case, the write happens inside flush()
>>
>> So a solution is to test the return value of flush(), right? That's
>> actually easier than checking each and every write() call... (and much
>> more performant than using Unbuffered).
>>
>> When does flush happen if not called explicitely? In close? So we
>> should do this?
>
>There's no guarantee that in buffered mode write() won't actually have
> to write to disk though, is there?  We know that pending changes will
> have been written out by flush() but there's no reason that write()
> won't actually write if its own internal buffers fill up.

And then there's no reason that the write won't be blocked in the hard 
drive's own buffers.

There's a point where the effort becomes too great.

-- 
  Thiago Macieira  -  thiago (AT) macieira.info - thiago (AT) kde.org
    PGP/GPG: 0x6EF45358; fingerprint:
    E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20090206/697f6e94/attachment.sig>


More information about the kde-core-devel mailing list