[prev in list] [next in list] [prev in thread] [next in thread]
List: linux-man
Subject: file descriptor flag retrieval
From: Tycho Kirchner <tychokirchner () mail ! de>
Date: 2019-03-18 12:09:45
Message-ID: 415175d5-7cf3-65d4-ac6a-3237b04b29e4 () mail ! de
[Download RAW message or body]
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
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic