diff options
author | Jim Meyering <jim@meyering.net> | 1998-09-27 02:57:29 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 1998-09-27 02:57:29 +0000 |
commit | 80499598c1596b3f279737385c4fde734bcaf679 (patch) | |
tree | 6c389032bc47a0b321c52e9d4d1a14ea883c4350 /src | |
parent | b6dcafff113b972965f7e39f67cb2b588170b8ea (diff) | |
download | coreutils-80499598c1596b3f279737385c4fde734bcaf679.tar.xz |
(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.
Diffstat (limited to 'src')
-rw-r--r-- | src/copy.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/copy.c b/src/copy.c index 8c5ae54e7..82f29b29d 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; } |