On Wed, 22 Nov 2000 23:56:55 -0800 Alex Zepeda wrote: > On Wed, Nov 22, 2000 at 09:12:23PM +0000, David Faure wrote: > > > We don't use mmap for writing, we use QDataStream over a QFile. > > > > You're right. The problem has nothing to do with mmap, it's when writing that > > some data became corrupted. > > Quickly, the most reliable NFS implementations are usually v2 over UDP. > Anything else often runs into problems, especially in a heterogeneous > environment. > > Also perhaps it would be safer to write to a separate file, and then move > it, instead of appending to it. Right. That's the only way to be safe. * Open a temporary file for writing. * Check the number of bytes returned from each write() call. * Call fsync() and checking the retval. * Call close() and checking the retval. * Move the file to the 'real' name. You need to check the retval of close because some NFS implementations get fsync() wrong. Thankfully you can use the retval of close() to check you fsync()ed ok. Rik