]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
(copy_internal): Don't preserve hard-linked directories
authorJim Meyering <jim@meyering.net>
Sun, 27 Sep 1998 02:57:29 +0000 (02:57 +0000)
committerJim Meyering <jim@meyering.net>
Sun, 27 Sep 1998 02:57:29 +0000 (02:57 +0000)
to avoid damaging the destination filesystem when copying from a
Netapp snapshot directory.  With code from Kjetil Torgrim Hollstein
and Paul Eggert.

src/copy.c

index 8c5ae54e7a1086a3ccafb3c7d2fc41a9e09a2d22..82f29b29d39d5b6122639157d5ff8549cf529365 100644 (file)
@@ -598,11 +598,22 @@ copy_internal (const char *src_path, const char *dst_path,
 
   if (!x->dereference && src_sb.st_nlink > 1 && earlier_file)
     {
+      /* Avoid damaging the destination filesystem by refusing to preserve
+        hard-linked directories (which are found at least in Netapp snapshot
+        directories).  */
+      if (S_ISDIR (src_type))
+       {
+         error (0, 0, _("%s: won't create hard link `%s' to directory `%s'"),
+                dst_path, earlier_file);
+         goto un_backup;
+       }
+
       if (link (earlier_file, dst_path))
        {
          error (0, errno, "%s", dst_path);
          goto un_backup;
        }
+
       return 0;
     }