[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Feature request, mv
From: |
Jim Meyering |
Subject: |
Re: Feature request, mv |
Date: |
Wed, 10 May 2006 15:38:48 +0200 |
Thanks to Joshua for the report and to Eric for pursuing it.
There is indeed a bug.
Before the fix, mv would unnecessarily unlink the destination symlink:
$ rm -rf s[12]; ln -s / s1; ln -s /tmp s2; strace -qe unlink /bin/mv -T s1 s2
unlink("s2") = 0
With the fix, it doesn't call unlink:
$ rm -rf s[12]; ln -s / s1; ln -s /tmp s2; strace -qe unlink ./mv -T s1 s2
$
Here's a snap fix to disable the offending condition in move-mode.
That disjunct *is* required to support cp's use of this code.
This might prompt me to add a first test case using strace.
(of course, it'll run only on systems with strace)
This change (or some variant of it) will go on both
the trunk and the b5_9 branch -- just in time for coreutils-5.95.
Index: src/copy.c
===================================================================
RCS file: /fetish/cu/src/copy.c,v
retrieving revision 1.197
diff -u -p -r1.197 copy.c
--- src/copy.c 12 Mar 2006 22:52:46 -0000 1.197
+++ src/copy.c 10 May 2006 13:25:14 -0000
@@ -1230,8 +1230,10 @@ copy_internal (char const *src_name, cha
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_ISLNK (src_sb.st_mode))))
+ || (!x->move_mode
+ && x->dereference == DEREF_NEVER
+ && S_ISLNK (src_sb.st_mode))
+ ))
{
if (unlink (dst_name) != 0 && errno != ENOENT)
{
- Feature request, mv, Joshua Hudson, 2006/05/09
- Re: Feature request, mv, Eric Blake, 2006/05/09
- Message not available
- Re: Feature request, mv, Eric Blake, 2006/05/10
- Re: Feature request, mv,
Jim Meyering <=
- Re: Feature request, mv, Joshua Hudson, 2006/05/10
- Re: Feature request, mv, Jim Meyering, 2006/05/10
- Re: Feature request, mv, Joshua Hudson, 2006/05/10
- Re: Feature request, mv, Jim Meyering, 2006/05/10
Re: Feature request, mv, Eric Blake, 2006/05/10