[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] cp --no-derefence --link assumes a Linux kernel
From: |
Aurelien Jarno |
Subject: |
Re: [PATCH] cp --no-derefence --link assumes a Linux kernel |
Date: |
Sat, 24 Sep 2005 00:35:31 +0200 |
User-agent: |
Mutt/1.5.10i |
On Wed, Sep 21, 2005 at 09:16:57PM -0700, Paul Eggert wrote:
> Aurelien Jarno <address@hidden> writes:
>
> > POSIX.1-2001 says that link() should dereference symlinks. The Linux
> > kernel does not follow POSIX, so that calling cp with --no-dereference
> > and --link works as expected. However on non-Linux kernel, this does not
> > work as expected, the symlinks being dereferenced. This is even worse
> > with symlinks pointing to non-existing paths, where contrary to Linux,
> > cp fails in such cases.
>
> Sorry, I can't quite understand your explanation. Can you please give
> a series of shell commands that illustrates the problems?
Sure.
On GNU/Linux:
[bode:/tmp]$ touch a
[bode:/tmp]$ ln -s a b
[bode:/tmp]$ cp --link --no-dereference b c
[bode:/tmp]$ ls -al a b c
-rw-r--r-- 1 aurel32 aurel32 0 2005-09-24 00:23 a
lrwxrwxrwx 2 aurel32 aurel32 1 2005-09-24 00:23 b -> a
lrwxrwxrwx 2 aurel32 aurel32 1 2005-09-24 00:23 c -> a
[bode:/tmp]$
On GNU/kFreeBSD (and probably on some other systems):
[bode:/tmp]$ touch a
[bode:/tmp]$ ln -s a b
[bode:/tmp]$ cp --link --no-dereference b c
[bode:/tmp]$ ls -al a b c
-rw-r--r-- 1 aurel32 aurel32 0 2005-09-24 00:23 a
lrwxrwxrwx 2 aurel32 aurel32 1 2005-09-24 00:23 b -> a
-rw-r--r-- 1 aurel32 aurel32 0 2005-09-24 00:23 c
[bode:/tmp]$
ie the --no-dereference option has been ignored. This is because the
POSIX link() function always dereference symlinks, contrary to the Linux
kernel.
I think in that case a simple copy of the symlink is more appropriate
and conducts to the same result. That's what the patch does.
> Also, what does "cp --version" and "uname -a" say for you?
[bode:/tmp]$ cp --version
cp (coreutils) 5.2.1
[bode:/tmp]$ uname -a
GNU/kFreeBSD hertz.aurel32.net 5.4-1-686 #0 Wed Sep 7 10:13:03 CEST 2005 i686
GNU/kFreeBSD
[bode:/tmp]$
(ie a FreeBSD kernel on a GNU userland, including glibc)
Bye,
Aurelien
--
.''`. Aurelien Jarno | GPG: 1024D/F1BCDB73
: :' : Debian GNU/Linux developer | Electrical Engineer
`. `' address@hidden | address@hidden
`- people.debian.org/~aurel32 | www.aurel32.net