This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: POSIX-compliance of link(2)


> On Mar 17 06:07, Eric Blake wrote:
> > According to POSIX, creating a hardlink to a symlink is supposed to be
> > impossible, because link(2) is supposed to resolve symlinks before
> > performing the actual link.  See
> > http://www.opengroup.org/austin/mailarchives/ag/msg08153.html.
> 
> Regardless of this mail exchange, the ultimate word on this is the
> SUSv3 man page, which shows no trace of demanding that link(2) follows
> symlinks, see
> http://www.opengroup.org/onlinepubs/009695399/functions/link.html

But the SUSv3 publication also defers to this definition, in POSIX XBD 4.11, http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap04.html:

"If a symbolic link is encountered during pathname resolution, the behavior shall depend on whether the pathname component is at the end of the pathname and on the function being performed. If all of the following are true, then pathname resolution is complete:

This is the last pathname component of the pathname.

The pathname has no trailing slash.

The function is required to act on the symbolic link itself, or certain arguments direct that the function act on the symbolic link itself."


Since link(2) does not mention that it is required to act on the symbolic link itself, it is required to resolve the symlink first because of this overarching requirement on all SUSv3 functions.

> 
> Same if I use ln(1) instead of link(1).  So?

So Linux has the same bug, per strict interpretation of POSIX.  So does Solaris 9 (but it was fixed in Solaris 10).  OpenBSD, however, does not have the bug.  If you read further on the austin mailing list, my bug report has stirred up quite a bit of controversy over whether hardlinks to symlinks should be allowed.  I would hold off on making any change to cygwin until the fray has settled and final consensus has been reached.  The list's claim so far is that POSIX does not require symlinks to have a link count, to allow implementations that use special directory entries ("fast symlinks") instead of occupying an inode, and that in those implementations, hardlinks to symlinks are impossible, so they made it impossible everywhere.

--
Eric Blake



--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]