Re: move instead of copy
Frederik Eaton <[email protected]> Wed, 16 Sep 2015 17:30:20 -0700
| Newsgroups | gmane.network.unison.devel |
|---|---|
| Message-ID | <[email protected]> |
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