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

Previous Next

Package: coreutils;

Reported by: Ruediger Meier <ruediger.meier <at> ga-group.nl>

Date: Tue, 29 Mar 2011 16:31:01 UTC

Severity: normal

Done: Pádraig Brady <P <at> draigBrady.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Eric Blake <eblake <at> redhat.com>
To: Pádraig Brady <P <at> draigBrady.com>
Cc: 8374 <at> debbugs.gnu.org, bug-gnulib <bug-gnulib <at> gnu.org>, Ruediger Meier <ruediger.meier <at> ga-group.nl>
Subject: bug#8374: cp -a [-l] sometimes does not preserve timestamps of symlinks
Date: Thu, 31 Mar 2011 08:20:16 -0600
[Message part 1 (text/plain, inline)]
[adding bug-gnulib]

On 03/31/2011 08:11 AM, Pádraig Brady wrote:
>> So probably -al is broken since you fixed -a in 7.5.
> 
> 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
> 
> Eric do you have any suggestions?
> The following seems to make things work as expected
> 
> diff --git a/src/copy.c b/src/copy.c
> index a672fd3..4f07d2c 100644
> --- a/src/copy.c
> +++ b/src/copy.c
> @@ -2226,8 +2226,7 @@ copy_internal (char const *src_name, char const *dst_name,
>       where link(2) follows the link, gnulib creates a symlink with
>       identical contents, which is good enough for our purposes).  */
>    else if (x->hard_link
> -           && (!S_ISLNK (src_mode)
> -               || x->dereference != DEREF_NEVER))
> +           && !(S_ISLNK (src_mode) && x->dereference != DEREF_NEVER))
>      {
>         if (linkat (AT_FDCWD, src_name, AT_FDCWD, dst_name, 0))
>          {
> 
> Hmm, maybe it's better to skip linkat() for symlinks altogether
> since the gnulib fallback on systems that implicitly dereference,
> will create symlinks, but without the right timestamps.
> Or, perhaps the gnulib fallback should try to update timestamps too?

Sounds to me like the gnulib fallback should be made smarter.  Which
systems lack linkat() but have the capability to set timestamps?  BSD?
But the original report was about opensuse, which is Linux based, and my
recollection is that Linux handles hardlinks to symlinks much longer
than it could set symlink timestamps.

-- 
Eric Blake   eblake <at> redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

[signature.asc (application/pgp-signature, attachment)]

This bug report was last modified 14 years and 55 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.