]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
(copy_internal): When preserving links, unlink
authorPaul Eggert <eggert@cs.ucla.edu>
Wed, 11 Aug 2004 17:19:25 +0000 (17:19 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Wed, 11 Aug 2004 17:19:25 +0000 (17:19 +0000)
a destination with link count greater than one.  This is so
that commands like "cp -a" don't get confused when copying into
a destination that already contains many hard links.

src/copy.c

index 12530355700100e6ecb0bedf4189bcfa4942f68a..61c74c383eb63cfb84a8c2a5a2d0cb2a51e705ee 100644 (file)
@@ -1079,6 +1079,7 @@ copy_internal (const char *src_path, const char *dst_path,
            }
          else if (! S_ISDIR (dst_sb.st_mode)
                   && (x->unlink_dest_before_opening
+                      || (x->preserve_links && 1 < dst_sb.st_nlink)
                       || (x->dereference == DEREF_NEVER
                           && ! S_ISREG (src_sb.st_mode))))
            {