diff options
author | Nicolas Cavallari <nicolas.cavallari@green-communications.fr> | 2021-04-07 19:08:23 +0200 |
---|---|---|
committer | Waldemar Brodkorb <wbx@openadk.org> | 2021-04-09 05:56:24 +0200 |
commit | 221f2898b9140b4cc103d2c485061023706c1fcf (patch) | |
tree | 89ecaeda872ea2074d05b5941e20575d0b9238e1 /libc/sysdeps/linux/common | |
parent | 2bf4991c4dd7b50b74656011dea9c40464ff390c (diff) |
open: Add support for O_TMPFILE
Since Linux 3.11, O_TMPFILE allows to create unnamed files that can be
linked later on. It is internally defined as (O_TMPFILE | O_DIRECTORY)
to make it fail on old kernels.
Copying definitions from glibc for O_TMPFILE is not enough to support
O_TMPFILE; The open() wrapper also need to pass the mode when the flag
contains O_TMPFILE, otherwise, it will pass mode 000 which will succeed
but yield unexpected results.
openat() is curiously not affected since it passes the mode
unconditionally..
Signed-off-by: Nicolas Cavallari <nicolas.cavallari@green-communications.fr>
Diffstat (limited to 'libc/sysdeps/linux/common')
-rw-r--r-- | libc/sysdeps/linux/common/open.c | 2 | ||||
-rw-r--r-- | libc/sysdeps/linux/common/open64.c | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/libc/sysdeps/linux/common/open.c b/libc/sysdeps/linux/common/open.c index ccdcf3848..ac09d40f0 100644 --- a/libc/sysdeps/linux/common/open.c +++ b/libc/sysdeps/linux/common/open.c @@ -31,7 +31,7 @@ int open(const char *file, int oflag, ...) int oldtype, result; #endif - if (oflag & O_CREAT) { + if (oflag & (O_CREAT | (O_TMPFILE &~ O_DIRECTORY))) { va_list arg; va_start(arg, oflag); mode = va_arg(arg, mode_t); diff --git a/libc/sysdeps/linux/common/open64.c b/libc/sysdeps/linux/common/open64.c index 6e65a988e..9d4c06b18 100644 --- a/libc/sysdeps/linux/common/open64.c +++ b/libc/sysdeps/linux/common/open64.c @@ -10,13 +10,13 @@ #include <stdarg.h> #include <cancel.h> -/* Open FILE with access OFLAG. If OFLAG includes O_CREAT, +/* Open FILE with access OFLAG. If OFLAG includes O_CREAT or O_TMPFILE, a third argument is the file protection. */ int open64(const char *file, int oflag, ...) { mode_t mode = 0; - if (oflag & O_CREAT) { + if (oflag & (O_CREAT | (O_TMPFILE &~ O_DIRECTORY))) { va_list arg; va_start (arg, oflag); mode = va_arg (arg, mode_t); |