quibble re checking for output errors

artichoke

Verified User
Joined
Jan 23, 2006
Messages
43
Location
San Jose, California, USA
Minor quibble relating to:

http://www.directadmin.com/features.php?id=733

This is listed as a feature, described as:
stat temp files during config file writing to ensure the disk isn't full

Each time a config file is written, it's first written to a temp file, then moved overtop of the orignal. This is prevent a wiping the original if the disk is full. DirectAdmin currently counts the number of bytes written as returned by the "fwrite" function, but this isn't reliable due to system cacheing.

The more reliable method is to check the size of the temp file after fclose is called as the file should be flushed and fully on disk by then.

Checking for errors when writing to disk and updating files atomically via a rename is normal programming practice, so doing this reliably now is a bug fix, not a feature. Otherwise we would have a long list of features, any time we checked for an error.

Automatically buying a new disk when a filesystem gets full -- now that would be a feature.

Rahul

P.S.

The normal method for checking for output errors is to look at the return value from fclose(). This will return any error reported by the underlying close() system call, which allocates sufficient disk space before returning, even if the cache is not flushed until later. If a hardware error has occurred, the output write count and/or output file size may be correct but the data written to the file might be wrong. In such cases the return value from fclose() is likely to be a better indicator of the output error. I'm sure the DirectAdmin developers have some good reason for counting output file size instead -- maybe they encountered an NFS client that did not properly return an error from close() on an NFS-mounted filesystem. It's still a bug fix, though, not a feature.
 
Back
Top