i came across a bit of code which says
int fd = open(fn, flags, 0);
if (fd < 0 && errno != EMLINK)
...
flags
is either O_RDONLY
or O_RDONLY|O_NOFOLLOW
IEEE Std 1003.1, 2013 (SUSv4) has just
[EMLINK] Too many links. An attempt was made to have the link count of a single file exceed {LINK_MAX}.
{LINK_MAX} Maximum number of links to a single file.
how does opening a file increase its link count?
Good question. When O_NOFOLLOW
was added, they chose to reuse an existing error code rather than make up a new one. EMLINK
in this case signifies that the file is a symlink and is returned on FreeBSD. Linux and Darwin return ELOOP
rather than EMLINK
, while NetBSD uses EFTYPE
.
My manpages say O_NOFOLLOW
is a FreeBSD extension subsequently added to Linux (ie you won't find its behaviour explained in older versions of the SUS, but it is included in the POSIX 2008 with the Linux return code).
This is not specified by SUS v4. See http://pubs.opengroup.org/onlinepubs/9699919799/functions/open.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With