[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bad cp -a behaviour
From: |
Paul Eggert |
Subject: |
Re: Bad cp -a behaviour |
Date: |
Wed, 11 Aug 2004 10:23:25 -0700 |
User-agent: |
Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux) |
Philip Rowlands <address@hidden> writes:
> I don't know the specs to which GNU cp adheres well enough, but I'd be
> surprised if they mandate a sort routine for recursive copying.
POSIX places no requirement here, since these options are an extension to POSIX.
The GNU documentation says that "-a" implies "--preserve=links" and
that "--preserve-links" means "Preserve in the destination files any
links between corresponding source files." Here, Tim wants "cp -a"
to preserve in the destination the fact that the source files are
different, even though they are already hard links in the destination.
This sounds reasonable to me, so I installed the following patch. But
I'd like someone with sharp eyes (Jim? :-) to double-check it. In
particular, I don't understand what these lines are doing in the
existing code:
|| (x->dereference == DEREF_NEVER
&& ! S_ISREG (src_sb.st_mode))))
Why should the behavior differ here merely because the source
is (say) a character special file?
2004-08-11 Paul Eggert <address@hidden>
* src/copy.c (copy_internal): When preserving links, unlink
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. Problem
reported by Tim Waugh in:
http://lists.gnu.org/archive/html/bug-coreutils/2004-08/msg00053.html
Index: src/copy.c
===================================================================
RCS file: /home/eggert/coreutils/cu/src/copy.c,v
retrieving revision 1.170
retrieving revision 1.171
diff -p -u -r1.170 -r1.171
--- src/copy.c 30 Jul 2004 07:51:59 -0000 1.170
+++ src/copy.c 11 Aug 2004 17:19:25 -0000 1.171
@@ -1079,6 +1079,7 @@ copy_internal (const char *src_path, con
}
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))))
{
- Bad cp -a behaviour, Tim Waugh, 2004/08/07
- Re: Bad cp -a behaviour, Andreas Schwab, 2004/08/07
- Re: Bad cp -a behaviour, Philip Rowlands, 2004/08/07
- Re: Bad cp -a behaviour, Tim Waugh, 2004/08/10
- Re: Bad cp -a behaviour, Philip Rowlands, 2004/08/11
- Re: Bad cp -a behaviour, Tim Waugh, 2004/08/11
- Re: Bad cp -a behaviour, Philip Rowlands, 2004/08/11
- Re: Bad cp -a behaviour, Tim Waugh, 2004/08/11
- Re: Bad cp -a behaviour,
Paul Eggert <=
- Re: Bad cp -a behaviour, Tim Waugh, 2004/08/12
- Re: Bad cp -a behaviour, Philip Rowlands, 2004/08/12
- Re: Bad cp -a behaviour, Andreas Schwab, 2004/08/12