delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/03/17/12:01:20

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
From: ericblake AT comcast DOT net (Eric Blake)
To: cygwin AT cygwin DOT com
Subject: Re: POSIX-compliance of link(2)
Date: Thu, 17 Mar 2005 17:00:59 +0000
Message-Id: <031720051700.22416.4239B7CB0000F2230000579022070009530A050E040D0C079D0A@comcast.net>
X-Authenticated-Sender: ZXJpY2JsYWtlQGNvbWNhc3QubmV0

> 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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019