From 80499598c1596b3f279737385c4fde734bcaf679 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Sun, 27 Sep 1998 02:57:29 +0000 Subject: [PATCH] (copy_internal): Don't preserve hard-linked directories 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 | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/copy.c b/src/copy.c index 8c5ae54..82f29b2 100644 --- a/src/copy.c +++ b/src/copy.c @@ -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; } -- 2.7.4