bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#8374: cp -a [-l] sometimes does not preserve timestamps of symlinks


From: Jim Meyering
Subject: bug#8374: cp -a [-l] sometimes does not preserve timestamps of symlinks
Date: Fri, 01 Apr 2011 14:21:29 +0200

Pádraig Brady wrote:
...
>> Hmm it looks now like we're creating symlinks (with wrong timestamps),
>> but in fact we should be creating hardlinks to symlinks.
>>
>> This seems to have been changed with:
>> http://git.sv.gnu.org/gitweb/?p=coreutils.git;a=commit;h=3346c0af
>
> That commit didn't actually change the logic as far as I can see.
> It was actually ca9e212c that introduced the logic bug I think.
>
> So I'm going to apply the attached.
...
> Subject: [PATCH] copy: link rather than copy symlinks, when --link used
>
> This bug was introduced in commit ca9e212c, 2009-09-24,
> "cp, mv: use linkat to guarantee semantics", which
> inadvertently disabled the creation of hardlinks to symlinks.
> However rather than implementing the intention of that commit
> and relying on gnulib linkat emulation, we'll revert to the
> previous emulation as that maintains ownership and timestamps.
>
> * src/copy.c (copy_internal): Use our existing hardlink to
> symlink emulation when we're not sure that link() will
> not dereference the symlink.  Also ensure that we copy the

How about "...when link() might dereference..."

> timestamps of the original symlink when we use the emulation.
> * tests/cp/link-symlink: Add a test to ensure timestamps copied.
> * tests/Makefile.am: Reference the new test.
> * NEWS: Mention the fix.
> Reported by Ruediger Meier
> ---
>  NEWS                  |    4 ++++
>  src/copy.c            |   27 ++++++++++++++++++++-------
>  tests/Makefile.am     |    1 +
>  tests/cp/link-symlink |   41 +++++++++++++++++++++++++++++++++++++++++
>  4 files changed, 66 insertions(+), 7 deletions(-)
>  create mode 100755 tests/cp/link-symlink
>
> diff --git a/NEWS b/NEWS
> index 6d66355..f25a696 100644
> --- a/NEWS
> +++ b/NEWS
> @@ -20,6 +20,10 @@ GNU coreutils NEWS                                    -*- 
> outline -*-
>    wc would dereference a NULL pointer upon an early out-of-memory error
>    [bug introduced in coreutils-7.1]
>
> +  cp -a --link would not create a hardlink to a symlink, instead
> +  copying the symlink and then not preserving its timestamp.
> +  [bug introduced in coreutils-8.0]

Please move that "up" so they're alphabetized.

>    dd now accepts the 'nocache' flag to the iflag and oflag options,
> diff --git a/src/copy.c b/src/copy.c

Thanks for fixing that!





reply via email to

[Prev in Thread] Current Thread [Next in Thread]