]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
(copy_internal): Don't skip test for same file if creating a hardlink
authorJim Meyering <jim@meyering.net>
Fri, 3 Jul 1998 20:06:50 +0000 (20:06 +0000)
committerJim Meyering <jim@meyering.net>
Fri, 3 Jul 1998 20:06:50 +0000 (20:06 +0000)
from symlink over a non-symlink while making backups.

src/copy.c

index 16372218986ba4d65821913e6b297d4c75cde700..6c563b8438071e6f7accf93d895b46956b0d17e9 100644 (file)
@@ -437,8 +437,12 @@ copy_internal (const char *src_path, const char *dst_path,
          if (!same
              /* If we're making a backup, we'll detect the problem case in
                 copy_reg because SRC_PATH will no longer exist.  Allowing
-                the test to be deferred lets cp do some useful things.  */
-             && x->backup_type == none
+                the test to be deferred lets cp do some useful things.
+                But when creating hardlinks and SRC_PATH is a symlink
+                but DST_PATH is not we must test anyway.  */
+             && (x->backup_type == none
+                 || (x->hard_link && S_ISLNK (src_sb.st_mode)
+                     && !S_ISLNK (dst_sb.st_mode)))
              && !x->dereference
              && (S_ISLNK (dst_sb.st_mode) || S_ISLNK (src_sb.st_mode)))
            {