Re: [RFC] correct flags to f_mode conversion in __dentry_open



On Wed, 21 May 2008, Michael Kerrisk wrote:

Christoph Hellwig wrote:
On Sat, Mar 15, 2008 at 05:59:52PM -0400, Alan Cox wrote:
does 11 really mean and should it really always be mapped to (FMODE_READ
| FMODE_WRITE) or should it continue to get mapped to 'no permission?'
We've always mapped 3 to "no permission" to read or write. It's a linuxism

I've tripped over this recently aswell. It would for sure be useful
to add a sumbolic O_FOO constant for this magic value '3' and document
it in the manpage.

Late follow-up to this thread
(http://thread.gmane.org/gmane.linux.kernel/653123):
I propose to add the following text to the open(2) man page.

Unlike the other values that can be specified in flags,
the access mode values O_RDONLY, O_WRONLY, and O_RDWR, do
not specify individual bits. Rather, they define the low
order two bits of flags, and are defined respectively as
0, 1, and 2. In other words, the combination O_RDONLY |
O_WRONLY is a logical error, and certainly does not have
the same meaning as O_RDWR. Linux reserves the special,
non-standard access mode 3 (binary 11) in flags to mean:
check for read and write permission on the file and
return a descriptor that can't be used for reading or
writing. This non-standard access mode is used by some
Linux drivers to return a descriptor that is only to be
used for device-specific ioctl(2) operations.

Seem okay?

Looks good to me. We definitely need this documented.



- James
--
James Morris
<jmorris@xxxxxxxxx>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



Relevant Pages

  • Re: [RFC] correct flags to f_mode conversion in __dentry_open
    ... Unlike the other values that can be specified in flags, ... the access mode values O_RDONLY, O_WRONLY, and O_RDWR, do ... Linux drivers to return a descriptor that is only to be ...
    (Linux-Kernel)
  • Re: [patch 2/2] ufd v1 - use unsequential O(1) fdmap
    ... more or less random descriptor values. ... old descriptor (maybe this can be overwritten with a flags bit). ... cannot break dup2() and F_DUPFD though, so we have to handle those too. ... which don't care about sequential allocation and are slowed down by the ...
    (Linux-Kernel)
  • Re: [patch 2/2] ufd v1 - use unsequential O(1) fdmap
    ... more or less random descriptor values. ... old descriptor (maybe this can be overwritten with a flags bit). ... The flags parameter will also allow to specify the additional ... which don't care about sequential allocation and are slowed down by the ...
    (Linux-Kernel)
  • Re: O_NONBLOCK is broken
    ... restore flags ASAP. ... and first fcntl can return flags with O_NONBLOCK set ... you cannot change file flags on a shared descriptor. ...
    (Linux-Kernel)