* Request for clarification of O_PATH in open(2)
@ 2022-04-15 17:48 meator
2022-04-25 20:49 ` Alejandro Colomar
0 siblings, 1 reply; 2+ messages in thread
From: meator @ 2022-04-15 17:48 UTC (permalink / raw)
To: mtk.manpages, alx.manpages; +Cc: linux-man
[-- Attachment #1: Type: text/plain, Size: 1635 bytes --]
Hello. I was reading open(2) and I have noticed an interesting statement: "The argument flags must include one of the following access modes: O_RDONLY, O_WRONLY, or O_RDWR." Must one of these flags be specified when O_PATH is in use?
O_PATH description says that "Opening a file or directory with the O_PATH flag requires no permissions on the object itself (but does require execute permission on the directories in the path prefix)." I think that this can be a little bit ambiguous. When I first read it, I have thought that this sentence talks about filesystem permissions required on the file, not the access modes.
O_PATH description states that: "When O_PATH is specified in flags, flag bits other than O_CLOEXEC, O_DIRECTORY, and O_NOFOLLOW are ignored." One could think that you must specify an access mode, but it will be ignored.
The O_PATH description actually mentions the O_RDONLY flag, but it compares the difference of opening a file with O_PATH and opening it with (only) O_RDONLY, it doesn't mention the need of O_RDONLY flag when opening a file with O_PATH.
The only part of the manpage that clearly states that using access modes with O_PATH is not mandatory is the code sample included in the O_PATH description, which calls open("some_prog", O_PATH); (but this code sample covers another aspect of O_PATH).
Maybe I'm just dumb and I misread some of the text, but I think this can be ambiguous. I would have sent a patch fixing this, but I'm not a native English speaker and I don't actually know how open() works, so I don't want to make a mistake when modifying its manpage.
Thanks in advance,
Meator
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Request for clarification of O_PATH in open(2)
2022-04-15 17:48 Request for clarification of O_PATH in open(2) meator
@ 2022-04-25 20:49 ` Alejandro Colomar
0 siblings, 0 replies; 2+ messages in thread
From: Alejandro Colomar @ 2022-04-25 20:49 UTC (permalink / raw)
To: meator, mtk.manpages; +Cc: linux-man
Hello Meator,
On 4/15/22 19:48, meator wrote:
> Hello. I was reading open(2) and I have noticed an interesting statement: "The argument flags must include one of the following access modes: O_RDONLY, O_WRONLY, or O_RDWR." Must one of these flags be specified when O_PATH is in use?
> O_PATH description says that "Opening a file or directory with the O_PATH flag requires no permissions on the object itself (but does require execute permission on the directories in the path prefix)." I think that this can be a little bit ambiguous. When I first read it, I have thought that this sentence talks about filesystem permissions required on the file, not the access modes.
I agree that it talks about FS permissions, and not access mode.
> O_PATH description states that: "When O_PATH is specified in flags, flag bits other than O_CLOEXEC, O_DIRECTORY, and O_NOFOLLOW are ignored." One could think that you must specify an access mode, but it will be ignored.
This is the only part that talks about access mode, and implies that you
don't need to specify any RD or WR flags. It's true that it could be
interpreted as you say.
> The O_PATH description actually mentions the O_RDONLY flag, but it compares the difference of opening a file with O_PATH and opening it with (only) O_RDONLY, it doesn't mention the need of O_RDONLY flag when opening a file with O_PATH.
> The only part of the manpage that clearly states that using access modes with O_PATH is not mandatory is the code sample included in the O_PATH description, which calls open("some_prog", O_PATH); (but this code sample covers another aspect of O_PATH).
But the code sample clarifies the doubt about the necessity or not of
writing the (to be ignored) access mode. So you don't need to.
It's true that the code sample is not talking about that, but it's
unequivocally saying you don't specify the access mode RD or WR flags.
That's for clarifying it to you.
>
> Maybe I'm just dumb and I misread some of the text, but I think this can be ambiguous. I would have sent a patch fixing this, but I'm not a native English speaker and I don't actually know how open() works, so I don't want to make a mistake when modifying its manpage.
As for clarifying it in the manual page, I have doubts. I think it's
enough as is, but I'll take your report into account, and if I receive
other similar reports, I'll assume that it's not so clear and will try
to improve it.
Thanks,
Alex
P.S.: Internet searches also consistently confirm that you don't need
to specify the RD WR mode flags:
<https://stackoverflow.com/questions/12416889/semantics-of-linux-o-path-file-descriptors>.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-04-25 20:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-15 17:48 Request for clarification of O_PATH in open(2) meator
2022-04-25 20:49 ` Alejandro Colomar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox