Thomas Hood <[EMAIL PROTECTED]> wrote:
>> mv ~/foo /mnt/disk/somedir
>>
>> ~/foo is removed but foo is not always synchronously
>> copied : it may stay in the cache from some time.
>> Hence if my disk crashes during (or before) the
>> real writing, I complety lose the file foo
>> (As it has been removed  BEFORE the real copy
>> takes place)
>>
>> If there is a fsync before the erasure, this will
>> solve the problem.
>
> Jim Meyering: Good idea or bad idea?

IMHO, mv should not call fsync.

Closing the destination file descriptor is supposed
to guarantee that all data has been written to some sort of
storage (not necessarily nonvolatile).  I seem to recall that
a successful `close' call means the O/S can no longer report
a write failure.  Anything beyond that point is policy.

E.g., you configure your file system to minimize disk activity,
or risk of data loss.

The same argument would apply to code that does this:

  cp important /mnt/new-name && rm -fr important

At some point, you have to rely on the underlying file system.


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to