summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2016-01-16 11:35:50 +0000
committerPádraig Brady <P@draigBrady.com>2016-01-16 11:40:54 +0000
commit0d60653001d0fd56b36507ad00615bef18dc95a9 (patch)
tree83746ef2bd5ce86e3da462b0014d0c51f557f1a7 /src
parent3aa84d02ddd22dc9430275f544cb435d64c5e385 (diff)
downloadcoreutils-0d60653001d0fd56b36507ad00615bef18dc95a9.tar.xz
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.
Diffstat (limited to 'src')
-rw-r--r--src/copy.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/copy.c b/src/copy.c
index db2ce7377..191ccaaab 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? */