bug-coreutils
[Top][All Lists]
Advanced

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

Re: symlinks and targets are not the same file


From: Eric Blake
Subject: Re: symlinks and targets are not the same file
Date: Fri, 04 Dec 2009 19:05:16 -0700
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.23) Gecko/20090812 Thunderbird/2.0.0.23 Mnenhy/0.7.6.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Karl Berry on 12/4/2009 6:51 PM:
> [coreutils 8.1, gnu/linux]
> 
> $ touch foo 
> $ ln -s foo lnk
> $ \cp --no-dereference foo lnk
> cp: `foo' and `lnk' are the same file
> 
> Well, no, they're not.
> I expected the file foo to overwrite the symlink lnk.
> I can imagine that error without --no-dereference, but with it ... ?

I'm not so sure it is a bug.  cp --help | grep no-deref states:

  -d                           same as --no-dereference --preserve=links
  -P, --no-dereference         never follow symbolic links in SOURCE

But lnk is a DEST, not a SOURCE.  Which means you effectively did 'cp foo
foo'.

On the other hand, not even -T/--no-target-directory is enough to make us
try to blindly overwrite lnk, rather than stat()ing through it.  And it
almost seems like 'cp --no-deref -f foo lnk' should recognize failure to
copy, perform the unlink(), and try again, thus succeeding to overwrite
lnk with a regular file.  So, I'm fuzzy on whether you found an actual bug.

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAksZv9wACgkQ84KuGfSFAYAM2ACeNA/lkMNk7Q/udW78qNv0iVYn
fdUAn0dWw3GaTgjPnVsk1c3L4faZ9iNX
=ZrgT
-----END PGP SIGNATURE-----




reply via email to

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