"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Stefan Sperling <stsp@stsp.name>
Subject:
Re: -portable: add a wrapper for open() on FreeBSD
To:
Thomas Adam <thomas@xteddy.org>
Cc:
"Todd C. Miller" <millert@openbsd.org>, Christian Weisgerber <naddy@mips.inka.de>, gameoftrees@openbsd.org
Date:
Sun, 26 Sep 2021 13:57:49 +0200

Download raw body.

Thread
On Sat, Sep 25, 2021 at 11:05:00PM +0100, Thomas Adam wrote:
> On Sat, Sep 25, 2021 at 03:40:14PM -0600, Todd C. Miller wrote:
> > On Sat, 25 Sep 2021 23:20:54 +0200, Christian Weisgerber wrote:
> > 
> > > add a wrapper function to render open() POSIX-compliant on FreeBSD
> > >
> > > POSIX mandates that open(symlink, O_NOFOLLOW) fail with errno == ELOOP.
> > > FreeBSD chooses to deviate from this, but Got depends on it.  Introducing
> > > a wrapper avoids (1) the need to patch every occurrence, (2) having to
> > > check each release for new instances, and (3) slipups when modifying
> > > complex boolean expressions.
> > 
> > Is this really better than just checking for EMLINK in addition to
> > ELOOP?  Is it worth filing a bug with FreeBSD about this or do they
> > consider it to be a feature?
> 
> Agreed.  I can't believe this is a feature, and I'd rather see this fixed in
> FreeBSD if possible.
> 
> Kindly,
> Thomas Adam
> 

I suspect it is not intentional.

It looks like EMLINK from open(symlink, O_NOFOLLOW) comes from this change:
https://reviews.freebsd.org/D29323
(I don't have a freebsd system to test with, so I might be wrong.)

No discussion of the wrong errno value in that patch occurred,
as far as I can tell.

All other instances of EMLINK I could find in the FreeBSD kernel
are based on the hard link counter of a file, not symlinks.