2

Suppose one process does this: mv a large file to a destination directory

And another process is watching for that file in the destination directory because it wants to read its contents as soon as possible. Does the file system ensure that the second process only "sees" the file when it is fully available?

I looked at the man page for mv but didn't see any guarantees...

user1011471
  • 179
  • 1
  • 8

1 Answers1

3

This will depend largely on whether the source and destination files are on the same filesystem (in which case a rename(2) is done,† which is about as atomic as one can get) or a different filesystem (not at all atomic, and a process may easily see an incomplete file, especially if the system or network or filesystem is slow).

† based on a strace of mv I did years ago on Linux, so YMMV with different implementations of mv.

thrig
  • 1,626
  • 9
  • 9