file descriptor flag retrieval

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,
in proc(5)
it says for the fdinfo-entries regarding the flags:

This is an octal number that displays the file access
mode and file status flags (see open(2)).  If the
close-on-exec file descriptor flag is set, then flags
will also include the value O_CLOEXEC.


That is true, but not complete. The 'file creation flags'

O_DIRECTORY, O_NOFOLLOW, O_TMPFILE

are also returned.
Further I think it is worth mentioning that those flags are equal to the flags received via

fcntl(fd , F_GETFL);

*except* O_CLOEXEC, which is retrieved separately (and indirectly) via

fcntl(fd , F_GETFD);

as FD_CLOEXEC.

Similarly, in fnctl(2), it should say for F_GETFL:
"
Return (as the function result) the file access mode and the file status flags as well as the file creation flags O_DIRECTORY, O_NOFOLLOW and O_TMPFILE; arg is ignored.
"

Consequently the file creation flags O_CREAT, O_EXCL, O_TRUNC, O_NOCTTY are not returned by either call. Despite the inconsistency with O_CLOEXEC (a mistake, in my opinion), it seems that the reason for omitting those is to being able to retrieve them and reopening a file with the same flags, except those, that would destroy it (that does *not* apply to O_NOCTTY, which is not returned for reasons I don't understand).


Test-system:
$ uname -a
Linux debian-foo 4.9.0-8-amd64 #1 SMP Debian 4.9.144-3.1 (2019-02-19) x86_64 GNU/Linux


Thanks
Tycho




[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux