Ticket #15 (new defect)

Opened 16 years ago

Last modified 11 years ago

savannah: "quick save" may clobber files

Reported by: ossi Owned by:
Priority: minor Milestone: Future Releases
Component: mcedit Version:
Keywords: Cc:
Blocked By: Blocking:
Branch state: no branch Votes for changeset:

Description (last modified by ossi) (diff)

Original: http://savannah.gnu.org/bugs/?13143

Submitted by:Oswald Buddenhagen <ossi>Submitted on:Sat 21 May 2005 05:24:59 PM UTC
Category:EditorSeverity:3 - Normal
Status:ConfirmedPrivacy:Public
Assigned to:NoneOpen/Closed:Open
Release:current (CVS or snapshot)Operating System:All

Original submission:

if we run out of disk space, some i/o error occurs, or we are just 
killed while saving a file, the old contents will be lost.
that's because the old file is opened with O_TRUNC and rewritten.
the "solution" would be not to use O_TRUNC at all. instead, first 
write the part that extends beyond the end of the old file (note 
that we cannot just seek to the new end and write one byte because 
of sparse files) - if that fails to complete, truncate to the old 
length (if we crash in between, the old file will have garbage 
appended, but at least it's not clobbered alltogether). after the 
"extension" was written, overwrite the start of the file with the 
new content (if we crash in during this, the file is clobbered, but 
that's what you get for using "quick save") and possibly truncate 
the file to the new length.
some VFS inherently don't support seeking, so this "slightly safer" 
mode is not universally applicable.

a related note: for non-local files, "quick save" is used 
independently of the configured save mode. i think the VFS should 
tell the editor whether it can do remote renames, so the safe save 
modes we can be used in as many cases as possible. 

Change History

comment:1 Changed 16 years ago by styx

  • Milestone set to 4.7

comment:2 Changed 15 years ago by angel_il

  • Milestone changed from 4.7 to future releases

comment:3 Changed 14 years ago by ossi

  • Cc ossi@… added
  • severity set to no branch

comment:4 Changed 11 years ago by ossi

  • Description modified (diff)
  • Branch state set to no branch
  • Reporter changed from slavazanko to ossi

comment:5 Changed 11 years ago by ossi

  • Cc ossi@… removed
Note: See TracTickets for help on using tickets.