Skip to contentSkip to conversation

readlink(2) handling of empty strings

DISCUSSION Ben Hutchings 2 participants 3 messages Sep 29, 2014 – Sep 30, 2014 2 messages not in the archive Man-pages: manual pages for Linux -- Sections 2, 3, 4, 5, and 7

lore
Share & tools
lore
#0 lore raw

readlink(2) claims:

Since Linux 2.6.39, pathname can be an empty string, in which case the call operates on the file referred to by dirfd (which may have been obtained using the open(2) O_PATH flag). In this case, dirfd can refer to any type of file, not just a directory.

The last sentence seems to be incorrect. dirfd must refer to a symlink that has been opened using the O_PATH flag. (The symlink could refer to a file, directory, or nothing, but opening with O_PATH doesn't resolve it.)

Ben.

Signature · 2 lines
Ben Hutchings
The two most common things in the universe are hydrogen and stupidity.
#2 lore raw
In reply to a message not in the archive

Hello Ben,

Quoted 11 lines · Ben Hutchings

readlink(2) claims:

Since Linux 2.6.39, pathname can be an empty string, in which case the call operates on the file referred to by dirfd (which may have been obtained using the open(2) O_PATH flag). In this case, dirfd can refer to any type of file, not just a directory.

The last sentence seems to be incorrect. dirfd must refer to a symlink that has been opened using the O_PATH flag. (The symlink could refer to a file, directory, or nothing, but opening with O_PATH doesn't resolve it.)

Yes, you must be right. The existing text makes no sense; I suspect a cut-and-paste error as I went through updating some of the *at.2 pages. I've changed the text to:

Since Linux 2.6.39, pathname can be an empty string, in which case the call operates on the symbolic link referred to by dirfd (which should have have been obtained using the open(2) with the O_PATH and O_NOFOLLOW flags).

Okay?

Cheers,

Michael

Signature · 7 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#4 lore raw
In reply to a message not in the archive
Quoted 19 lines · Michael Kerrisk (man-pages)

Hello Ben,

Quoted 11 lines · Ben Hutchings

readlink(2) claims:

Since Linux 2.6.39, pathname can be an empty string, in which case the call operates on the file referred to by dirfd (which may have been obtained using the open(2) O_PATH flag). In this case, dirfd can refer to any type of file, not just a directory.

The last sentence seems to be incorrect. dirfd must refer to a symlink that has been opened using the O_PATH flag. (The symlink could refer to a file, directory, or nothing, but opening with O_PATH doesn't resolve it.)

Yes, you must be right. The existing text makes no sense; I suspect a cut-and-paste error as I went through updating some of the *at.2 pages. I've changed the text to:

Quoted 6 lines

Since Linux 2.6.39, pathname can be an empty string, in which case the call operates on the symbolic link referred to by dirfd (which should have have been obtained using the open(2) with the O_PATH and O_NOFOLLOW flags).

Okay?

LGTM.

Ben.

Signature · 2 lines
Ben Hutchings
The two most common things in the universe are hydrogen and stupidity.