On 13/01/16 18:30, Pádraig Brady wrote: >> > FAIL: tests/mv/dup-source >> > ========================= >> > >> > + diff -u exp out >> > --- exp 2016-01-13 12:07:44.597145567 -0500 >> > +++ out 2016-01-13 12:07:44.593145610 -0500 >> > @@ -2,4 +2,4 @@ >> > mv: cannot stat 'a': No such file or directory >> > mv: cannot stat 'b': No such file or directory >> > mv: cannot move './b' to a subdirectory of itself, 'b/b' >> > -mv: warning: source directory 'b' specified more than once >> > +mv: cannot move 'b' to a subdirectory of itself, 'b/b' >> > + fail=1 > Interesting. The mv case is different to cp on this system. > I can't think why off the top of my head. The "earlier_file" > must not be found in the hash for some reason.
It wasn't stored in the hash actually, because on BTRFS the link count for a dir is always 1 (so there is no limit on the number of subdirs). The attached patch always hashes specified source dirs. cheers, Pádraig
>From 0d60653001d0fd56b36507ad00615bef18dc95a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draig=20Brady?= <[email protected]> Date: Sat, 16 Jan 2016 11:35:50 +0000 Subject: [PATCH] mv: consistently warn about multiply specified source dirs * src/copy.c (copy internal): Remember directories irrespective of their link count, because on some file systems like BTRFS, directories always have a link count of 1. --- src/copy.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/copy.c b/src/copy.c index db2ce73..191ccaa 100644 --- a/src/copy.c +++ b/src/copy.c @@ -2232,7 +2232,14 @@ copy_internal (char const *src_name, char const *dst_name, Also, with --recursive, record dev/ino of each command-line directory. We'll use that info to detect this problem: cp -R dir dir. */ - if (x->move_mode && src_sb.st_nlink == 1) + if (x->recursive && S_ISDIR (src_mode)) + { + if (command_line_arg) + earlier_file = remember_copied (dst_name, src_sb.st_ino, src_sb.st_dev); + else + earlier_file = src_to_dest_lookup (src_sb.st_ino, src_sb.st_dev); + } + else if (x->move_mode && src_sb.st_nlink == 1) { earlier_file = src_to_dest_lookup (src_sb.st_ino, src_sb.st_dev); } @@ -2245,13 +2252,6 @@ copy_internal (char const *src_name, char const *dst_name, { earlier_file = remember_copied (dst_name, src_sb.st_ino, src_sb.st_dev); } - else if (x->recursive && S_ISDIR (src_mode)) - { - if (command_line_arg) - earlier_file = remember_copied (dst_name, src_sb.st_ino, src_sb.st_dev); - else - earlier_file = src_to_dest_lookup (src_sb.st_ino, src_sb.st_dev); - } /* Did we copy this inode somewhere else (in this command line argument) and therefore this is a second hard link to the inode? */ -- 2.5.0
