]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
tools/nolibc: always pass mode to open syscall
authorThomas Weißschuh <linux@weissschuh.net>
Thu, 14 May 2026 12:05:13 +0000 (14:05 +0200)
committerThomas Weißschuh <linux@weissschuh.net>
Thu, 14 May 2026 15:41:14 +0000 (17:41 +0200)
When O_TMPFILE is set, the open mode needs to be passed to the kernel as
per the documentation. Currently this is not done.
Instead of checking for O_TMPFILE explicitly and making the conditionals
more complex, just always pass the mode to the kernel. If no value was
passed the mode will be garbage, but the kernel will ignore it anyways.

Fixes: a7604ba149e7 ("tools/nolibc/sys: make open() take a vararg on the 3rd argument")
Suggested-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/lkml/afRfjdovT6pNtwtP@1wt.eu/
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://patch.msgid.link/20260514-nolibc-open-tmpfile-v2-3-b4c6c5efa266@weissschuh.net
tools/include/nolibc/fcntl.h

index d7ea02e1332d85cc444d2ca79e3c3e98e51f8935..d4b6af60d4cc02526455b8ca7a2f07186dad4870 100644 (file)
 
 #define __nolibc_open_mode(_flags)                                                     \
 ({                                                                                     \
-       mode_t _mode = 0;                                                               \
+       mode_t _mode;                                                                   \
+       va_list args;                                                                   \
                                                                                        \
-       if ((_flags) & O_CREAT) {                                                       \
-               va_list args;                                                           \
-                                                                                       \
-               va_start(args, (_flags));                                               \
-               _mode = va_arg(args, mode_t);                                           \
-               va_end(args);                                                           \
-       }                                                                               \
+       va_start(args, (_flags));                                                       \
+       _mode = va_arg(args, mode_t);                                                   \
+       va_end(args);                                                                   \
                                                                                        \
        _mode;                                                                          \
 })