On Wed, Mar 30, 2005 at 10:11:19AM +0200, Jindrich Novy wrote: > if (!vfs_file_is_local (filename) || > (fd = mc_open (filename, O_WRONLY | O_BINARY)) == -1) > > what actually truncates the filename to zero size. > it does not, unless mc_open has totally misleading semantics - there is no O_TRUNCATE. the truncation comes during the actual write ... which leaves us with a truncated/empty file, if we run out-of-space in the middle. the "solution" would be not to use O_TRUNCATE at all. instead, first write the part that extends beyond the end of the old file. if that fails to complete, truncate to the old length. if we crash now, the old file will have garbage appended, but at least it's not clobbered alltogether. note that we cannot just seek to the new end and write one byte because of sparse files. after the "extension" was written, overwrite the start of the file with the new content and possibly truncate the file to the new length. this is all sooo ugly ...
-- Hi! I'm a .signature virus! Copy me into your ~/.signature, please! -- Chaos, panic, and disorder - my work here is done. _______________________________________________ Mc-devel mailing list http://mail.gnome.org/mailman/listinfo/mc-devel