On 08/08/2017 03:10 PM, Philippe Mathieu-Daudé wrote: >> Technically, POSIX says (and 'man 2 open' agrees, modulo the fact that >> Linux still lacks O_SEARCH) that you MUST provide one of the 5 access >> modes (they are O_RDONLY, O_RDWR, O_WRONLY, O_EXEC, and O_SEARCH; >> although POSIX allows O_EXEC and O_SEARCH to be the same bit pattern), >> and then bitwise-or any additional flags. So the usage here is correct. >>
> Oh ok. I didn't think of that, just checked Linux manpage: > > O_PATH (since Linux 2.6.39) > > When O_PATH is specified in flags, flag bits other than > O_CLOEXEC, O_DIRECTORY, and O_NOFOLLOW are ignored. There are access modes (5 in POSIX), and then flag bits (O_NONBLOCK being one of the flag bits, and therefore ignored when O_PATH is true). Presumably, the author was being careful by mentioning "flag bits" (and thereby implicitly meaning that O_RDONLY is NOT ignored when using O_PATH). But I'm not _quite_ sure whether O_PATH should be considered a sixth access mode, or a flag bit, and the Linux man page doesn't help on that front ;) Hmm - if you treat O_PATH as an access mode rather than a flag bit, then O_RDONLY | O_PATH no longer makes sense at all (you can't mix two modes at once). Maybe we should file a bug report against the man page to get clarification. -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature