DragonFly kernel List (threaded) for 2008-06
DragonFly BSD
DragonFly kernel List (threaded) for 2008-06
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Re: link(2) behaviour when creating a hardlink to a symlink


From: ejc <eric.j.christeson@xxxxxxxxx>
Date: Wed, 11 Jun 2008 16:19:35 -0500

On Wed, Jun 11, 2008 at 3:48 PM, ejc <eric.j.christeson@gmail.com> wrote:
> On Wed, Jun 11, 2008 at 3:27 PM, Jordan Gordeev <jgordeev@dir.bg> wrote:
>> Cvs2svn, a package available in pkgsrc, doesn't extract successfully on
>> DragonFly.
>> During extraction, a link() syscall is made to create a hardlink to a
>> symlink that points to a non-existent file. The link() call fails with
>> ENOENT.
>> I'd like to know if you think that behaviour to be a bug.
>
> I looked up symbolic links in apue2 and link() is listed as a function
> that follows symbolic links.  "If the function follows a symbolic
> link, a pathname argument to the function refers to the file pionted
> to by the symbolic link."
> Looks like this behavior is correct.

Just for kicks I ran a test on a few systems at my disposal:

OSX 10.4.11

dyn253:~/test ejc$ touch foo
dyn253:~/test ejc$ ls -li
total 0
955608 -rw-r--r--   1 ejc  ejc  0 Jun 11 16:12 foo
dyn253:~/test ejc$ ln -s foo bar
dyn253:~/test ejc$ ls -li
total 8
955609 lrwxr-xr-x   1 ejc  ejc  3 Jun 11 16:12 bar -> foo
955608 -rw-r--r--   1 ejc  ejc  0 Jun 11 16:12 foo
dyn253:~/test ejc$ ln bar blah
dyn253:~/test ejc$ ls -li
total 8
955609 lrwxr-xr-x   1 ejc  ejc  3 Jun 11 16:12 bar -> foo
955608 -rw-r--r--   2 ejc  ejc  0 Jun 11 16:12 blah
955608 -rw-r--r--   2 ejc  ejc  0 Jun 11 16:12 foo


FreeBSD 6.3

ejc@chicadee$ touch foo
ejc@chicadee$ ls -li
total 0
16863301 -rw-r--r--  1 ejc  ejc  0 Jun 11 16:14 foo
ejc@chicadee$ ln -s foo bar
ejc@chicadee$ ls -li
total 0
16863303 lrwxr-xr-x  1 ejc  ejc  3 Jun 11 16:14 bar -> foo
16863301 -rw-r--r--  1 ejc  ejc  0 Jun 11 16:14 foo
ejc@chicadee$ ln bar blah
ejc@chicadee$ ls -li
total 0
16863303 lrwxr-xr-x  1 ejc  ejc  3 Jun 11 16:14 bar -> foo
16863301 -rw-r--r--  2 ejc  ejc  0 Jun 11 16:14 blah
16863301 -rw-r--r--  2 ejc  ejc  0 Jun 11 16:14 foo


Slackware 12.0 (Linux 2.6.21.5)

ejc@robin:~/test$ touch foo
ejc@robin:~/test$ ln -s foo bar
ejc@robin:~/test$ rm bar
ejc@robin:~/test$ ls -li
total 0
982125 -rw-r--r-- 1 ejc wheel 0 2008-06-11 16:15 foo
ejc@robin:~/test$ ln -s foo bar
ejc@robin:~/test$ ls -li
total 0
982129 lrwxrwxrwx 1 ejc wheel 3 2008-06-11 16:16 bar -> foo
982125 -rw-r--r-- 1 ejc wheel 0 2008-06-11 16:15 foo
ejc@robin:~/test$ ln bar blah
ejc@robin:~/test$ ls -li
total 0
982129 lrwxrwxrwx 2 ejc wheel 3 2008-06-11 16:16 bar -> foo
982129 lrwxrwxrwx 2 ejc wheel 3 2008-06-11 16:16 blah -> foo
982125 -rw-r--r-- 1 ejc wheel 0 2008-06-11 16:15 foo

OSX and FreeBSD (DragonFlyBSD also) follow the symlink, Linux doesn't
I tried this on a Linux box with a 2.4 series kernel and it performed
the same as 2.6, but I got a warning:
"making a hard link to a symbolic link is not portable"

eric



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