[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

mv should call fsync before erasing source file

From: drwowe
Subject: mv should call fsync before erasing source file
Date: Fri, 2 Oct 2009 22:41:07 -0700 (PDT)

I was moving some files with mv from a hard drive to a flash drive.  The
flash drive is very slow.  The mv command finished and the original files
were gone but I realized the operating system still had a gigabyte or so of
data in RAM which was in the process of being written to the flash disk.  I
ran "sync" to make sure everything was flushed and it took almost 60 seconds
to finish writing.  If my computer had crashed during that minute, the data
would have been gone.
Either by default, or at least with a command line flag, mv should call
fsync() on the new file being written and wait for a successful return
before erasing the original file.  Otherwise there is a significant window
of opportunity for significant data loss.  In theory, that window is
infinite according to POSIX standards, in practice my example shows that it
can be on the order of minutes which is just too long in my opinion to leave
a user's data in jeopardy.
View this message in context: 
Sent from the Gnu - Coreutils - Discuss mailing list archive at Nabble.com.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]