0

Assume I want to move a tree in the filesystem, e.g.

/path/to/a
  a.txt
  b.txt

to another location with rsync (3.0.9 protocol version 30), e.g. with rsync -a --remove-source-files /path/to/a/ /path/to/b/, why does rsync not find out that /path/to/a and /path/to/b are on the save filesystem (rsync is definitely capable of doing that, otherwise there would be no -x argument - the functionality would have to be made available without specification of -x) and uses the mv command which will probably profit from filesystem level manipulation, like changing links and inodes instead of reading, wrting and deleting all files in the tree?

EDIT 1: I experienced reading and writing instead of usage of mv on an ext4 and a reiserfs file system. I'm not looking for inputs like "it simply doesn't, patches welcome", but whether there're some explicit and possibly documented or discussed decisions regarding the design or use cases (like e.g. Gilles' answer).

Kalle Richter
  • 2,100
  • 4
  • 20
  • 37
  • 2
    How do you know it does not effectively do this? Also, you've misinterpreted the meaning and purpose of `-x`; from `man rsync`: *This tells rsync to **avoid crossing a filesystem boundary when recursing. This does not limit the user’s ability to specify items to copy from multiple filesystems,** just rsync’s recursion through the hierarchy of each directory that the user specified, and also the analogous recursion on the receiving side during deletion.* – goldilocks Aug 25 '14 at 17:04
  • My point regarding `-x` was just that `rsync` has a mechanism to recognize whether two path prefixes are on the same filesystem and that this could be reused to facilitate the implementation of usage of `mv` command. Where's the misinterpretation and how does your quote rely to it? – Kalle Richter Aug 26 '14 at 16:16
  • Fair enough (I'm not a downvote, BTW). I would take it as given that such a mechanism is available (e.g. [`statvfs()`](http://pubs.opengroup.org/onlinepubs/9699919799/functions/statvfs.html), POSIX), so your question implies to me you mean "since such a check is done anyway *in this case*", otherwise discussing `-x` is redundant; my point about `-x` is that's not "this case". But point taken. You still haven't said *why* you think it doesn't move the file -- I'm presuming you did some test, but there's no explanation of that in the question. – goldilocks Aug 27 '14 at 09:52
  • I agree, I tried to make it less missleading and added information about the tests I made. – Kalle Richter Aug 27 '14 at 12:13

1 Answers1

2

Rsync is very often used to copy files over a network link. It's also used to copy files to backup media. Removing source files is a fairly rare usage of rsync. Preserving metadata is commonly requested but optional. So it takes a combination of unusual use cases for rsync to have the opportunity to move a file from the source to the destination, rather than copy and delete. Detecting the case where it's possible would require additional complexity for something that rarely happens.

Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175