I'm implementing atomic writes (FWIW in Python on Linux & FreeBSD), and I'm writing to a temporary file in the same directory with the file I'm planning to write to (in order to ensure that they are on the same filesystem, and thus rename(2) succeeds and writes can be atomic).

My question is that is there any condition where two files in the same directory be on different filesystems? (I am not following symlinks, so a file symlinked to another file on a different filesystem is not a problem for me).


Yes. It is not only possible to mount directories, but also files. This enables to mount files residing on different file systems into one mutual directory.

Renaming the file results in EBUSY, when mv is used, this usually prints the message “Device or resource busy”. The destination can be renamed without throwing an error. The changes are applied to the new name instead.

  • How would this interact with rename(2)? (Fail with EACCESS?) – user27225 Oct 22 '13 at 14:24
  • 2
    @gkya, no, EBUSY. Try touch a b && sudo mount --bind a b && mv b c – Stéphane Chazelas Oct 22 '13 at 14:32
  • Thanks for the input, it has been helpful. So I have to report busy in this case too. BTW, @StephaneChazelas, that little experiment helped a lot. – user27225 Oct 22 '13 at 14:48

It is also possible, if you're using mhddfs. Actually it's a driver combines a several mount points into the single one.

Article with brief description.

  • What is the effect of this in regards of atomicity of rename? – user27225 Oct 22 '13 at 14:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy