[Unison-hackers] move instead of copy

Frederik Eaton frederik at ofb.net
Wed Sep 16 20:30:20 EDT 2015


On Wed, Sep 16, 2015 at 11:44:21PM +0200, Hadmut Danisch wrote:
>
> On 15.09.2015 23:51, Julian Squires wrote:
> > At least in the case of Posix systems, couldn't one rename(2) and if
> > it fails with EXDEV, then fall back to copy-and-delete?
> 
> Well, you could stat (2) the source file and the target directory and
> compare st_dev, and try the move only if equal, i.e. both on the same
> file system. (needs to be verified for nested file systems in zfs or
> btrfs).

But the source and the target could have changed filesystems between
stat(2) and rename(2)... not that this would ever happen, but isn't it
better to just try the rename and fall back to something else if you
get EXDEV?

Frederick


More information about the Unison-hackers mailing list