]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
(copy_internal): Treat src and dest as the `same' in
authorJim Meyering <jim@meyering.net>
Thu, 11 Nov 1999 13:19:36 +0000 (13:19 +0000)
committerJim Meyering <jim@meyering.net>
Thu, 11 Nov 1999 13:19:36 +0000 (13:19 +0000)
`mv src symlink-to-src' when src and dest are on different partitions.
Otherwise, that `mv' command would silently remove `src'.
Reported by Michael Stone.

src/copy.c

index e06acc14a7f37a63adf9b21ee7296c6e3afbb015..9d8c0c070b9f39e7f686ee8761ca85719295fabc 100644 (file)
@@ -429,9 +429,11 @@ copy_internal (const char *src_path, const char *dst_path,
              && ! x->force
 
              /* Allow them to be the same (and don't set `same') if
-                we're in move mode and the target is a symlink.  */
+                we're in move mode and the target is a symlink
+                on the same partition.  */
              && !(move_mode
-                  && S_ISLNK (dst_sb.st_mode))
+                  && S_ISLNK (dst_sb.st_mode)
+                  && src_sb.st_dev == dst_sb.st_dev)
 
              /* If we're making a backup, we'll detect the problem case in
                 copy_reg because SRC_PATH will no longer exist.  Allowing