From: Pádraig Brady Date: Sat, 16 Jan 2016 11:35:50 +0000 (+0000) Subject: mv: consistently warn about multiply specified source dirs X-Git-Tag: v8.25~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0d60653001d0fd56b36507ad00615bef18dc95a9;p=thirdparty%2Fcoreutils.git 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. --- diff --git a/src/copy.c b/src/copy.c index db2ce73774..191ccaaab5 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? */