From nobody Sat Jun 20 06:12:12 2026 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2C79A2874FB for ; Sun, 19 Apr 2026 15:29:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776612579; cv=none; b=igaJQrKPSfLo6mXDbVtEMjBxCE60vLB9WURTxgCaxFRAeHtE5P2ITlRjsl38z9WagaqTXOa0p+IhR7r015dd8K6M7xoSdxwQ8IMVMnVbaPGTJ09kdJ/1Cc/dGmg82AFeE/YNY3aCT91gdCdZ82mV9ySWYPROoTZ+glLOOlOLQ3Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776612579; c=relaxed/simple; bh=wp6GzBOpxT4VXxZ2bC88bhslU6pM+r2f+kncWPm3BsE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=QvOr1i7ptQdkAJv/b5+AVbgm9lmnrnAQj8i1mFFMYwZ5p8dpOorFIk0uRW+Wgd/QW5slU49FBTiaKJFCGN6MjwHtK9k/u5UOrPplH0hzCAAkLp0wotlMmSaPPf1PjQh0e7VLxtYjgzpJNwDaZxI8y5V7Iu/Y4Ai+HJIBrDRsMPg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=Ad+8qteq; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="Ad+8qteq" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1776612569; bh=wp6GzBOpxT4VXxZ2bC88bhslU6pM+r2f+kncWPm3BsE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Ad+8qteqQyc1JWd8Ig6CWBqEi4i0hromFlKscOhuqWD+01kQnWp+IXNPb34q+Lao7 ev5u7oWYlIwEXynTWlcZ/ubNc+s5RlIC7PXTYIw7iAatmxTf5BSVj4+3+vF3Fe9Bq0 pJeUpBtB30Y4EcUbe40rhtJz/uPOnJsWc53RX0rM= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sun, 19 Apr 2026 17:29:03 +0200 Subject: [PATCH 1/3] selftests/nolibc: drop unnecessary 'mode' argument to open() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260419-nolibc-open-mode-v1-1-8dc5a960daa7@weissschuh.net> References: <20260419-nolibc-open-mode-v1-0-8dc5a960daa7@weissschuh.net> In-Reply-To: <20260419-nolibc-open-mode-v1-0-8dc5a960daa7@weissschuh.net> To: Willy Tarreau Cc: linux-kernel@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1776612568; l=699; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=wp6GzBOpxT4VXxZ2bC88bhslU6pM+r2f+kncWPm3BsE=; b=d+BBWqy3WoTVHWlAjFXQjuROvJ6AIlw050wsJkVhFSkCF2YL9wJIKMVIxNZXXTgDjxdFXp0AJ btwlTHW4FKuCIi0xsVLqccT5aTXBLW4sQ8lgu2106VSjJZ08JUky0hx X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= The mode is unnecessary here, drop it. Signed-off-by: Thomas Wei=C3=9Fschuh Acked-by: Willy Tarreau --- tools/testing/selftests/nolibc/nolibc-test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/s= elftests/nolibc/nolibc-test.c index a8e88b5ff20a..36d769736356 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -797,7 +797,7 @@ int test_getdents64(const char *dir) int fd, ret; int err; =20 - ret =3D fd =3D open(dir, O_RDONLY | O_DIRECTORY, 0); + ret =3D fd =3D open(dir, O_RDONLY | O_DIRECTORY); if (ret < 0) return ret; =20 --=20 2.53.0 From nobody Sat Jun 20 06:12:12 2026 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2C85437C0EB for ; Sun, 19 Apr 2026 15:29:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776612580; cv=none; b=EaoCtCsKn6vefnSMrI2WzXGaUXUTVUngZiHmD5QFGfgNwF5YNpYMPvm7lwJ/AiEn+bH+/8NnFnyYFOG7tcYGV/b2+y/9mSxWPS4FV2S0J2RjWOCx1c0oO6xPI/tz6Q/O6JjCKdaqyzhEXsAwKGo1I3PJaLhiItXH4WeqOT+7j84= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776612580; c=relaxed/simple; bh=ws+sfy5cMi7I1TcIfQFQ9IGuAZ7JaEQj9r824cF4Ho8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Yrg7oxjQNICpXXBJqxj2SOVIutkyo+IXH1L3v0Bxfx2rYXdRSKdTVdYN6lB0na3yUnkzJzA7m5TheJeaUO9BYB7dcL8yKr+StGTW2chg8n/abiEMV40uUho381SotJpm7Rwtvr0tjCMD845oT282R3tHt0rpElvTpwN8ReOMRC8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=Bz4Pamsf; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="Bz4Pamsf" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1776612569; bh=ws+sfy5cMi7I1TcIfQFQ9IGuAZ7JaEQj9r824cF4Ho8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Bz4Pamsf4FSa7zzUATRVMBjowEBi1H6y/VflERfI91Us1JQdWJxPYAzdd4nTIe4gN hGJLzNQzjmRb04ACfF36jYQ67sB71V8SXqTm2fSL4R/ZFaSHOeHm5Rx34BOQfNlhVS z74vsoOPFC6f7qWNNJYwSzu2MQwQT6yyqwnoHg3g= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sun, 19 Apr 2026 17:29:04 +0200 Subject: [PATCH 2/3] tools/nolibc: add creat() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260419-nolibc-open-mode-v1-2-8dc5a960daa7@weissschuh.net> References: <20260419-nolibc-open-mode-v1-0-8dc5a960daa7@weissschuh.net> In-Reply-To: <20260419-nolibc-open-mode-v1-0-8dc5a960daa7@weissschuh.net> To: Willy Tarreau Cc: linux-kernel@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1776612568; l=751; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=ws+sfy5cMi7I1TcIfQFQ9IGuAZ7JaEQj9r824cF4Ho8=; b=oLbng6h8YkGYGrmQ9TdNq7RTDD+hevS94JJUQ330rIAC/6JxWTtq5RECgfHqW+Q/TIjpvC8/i 5MCUp+Z4I5FBcHYn2FgusP4YL46VS5RL/KEkyirx8GcVdiC+c9SCq5c X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= creat() is a simple wrapper around open(). Signed-off-by: Thomas Wei=C3=9Fschuh Acked-by: Willy Tarreau --- tools/include/nolibc/fcntl.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tools/include/nolibc/fcntl.h b/tools/include/nolibc/fcntl.h index ed2f5553c65a..56650a36f856 100644 --- a/tools/include/nolibc/fcntl.h +++ b/tools/include/nolibc/fcntl.h @@ -66,4 +66,14 @@ int open(const char *path, int flags, ...) return __sysret(_sys_open(path, flags, mode)); } =20 +/* + * int creat(const char *path, mode_t mode); + */ + +static __attribute__((unused)) +int creat(const char *path, mode_t mode) +{ + return open(path, O_CREAT | O_WRONLY | O_TRUNC, mode); +} + #endif /* _NOLIBC_FCNTL_H */ --=20 2.53.0 From nobody Sat Jun 20 06:12:12 2026 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2C8DD37D118 for ; Sun, 19 Apr 2026 15:29:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776612579; cv=none; b=Zpn88yyXv5D+U+XTG6G3mLTTLH/mCD7GSEI8guFa/GGmjbK23qQWGdug6kY8AqW51BEyPtPe9pmSNsvW02bGk9bwQQOOlJNl4x4BhwcLYP2vXZaty3S6b7DPe5iiZI1MFpfhPF40Ow+BzARd3av5mvlRSSNK5Jtr2v4v2/dk5po= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776612579; c=relaxed/simple; bh=EUJxU5aby5poCXi4gxuvYlGYuWCtAZuZinfkh9a0qao=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=RdqGkwbM7PLCI3JiIL/Hw+JBTw3U+pVX7upu9IDgtaw36Qiev0KnYt6OYD4zmW4om4ZEerpcoDmjoC1l+2iJ64tFSW1sr5bZ3ABjjx4jzD/H2zLTVj7qtgF+KmJnTLp+KcEBguuIy+KnZYlFvQVFp551PspMU1iFOBrAK3ugc24= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=SpdDpeqm; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="SpdDpeqm" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1776612569; bh=EUJxU5aby5poCXi4gxuvYlGYuWCtAZuZinfkh9a0qao=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=SpdDpeqmB+mjqxjIkmB6Hx6wJoci/NJ1+nRVvTgmdHxOEWEHecf/j3PfRCMbGsyav 255OzSvVJso9Y9fO65vTbFVXtW7KAleneWcyhbvEOirT5XGufVZlF040MK/t+kOYAF wEB097H2VPdzjM6DbGxalSLcO9ov+WJ97wbrSUUM= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sun, 19 Apr 2026 17:29:05 +0200 Subject: [PATCH 3/3] tools/nolibc: simplify mode handling in open() and openat() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260419-nolibc-open-mode-v1-3-8dc5a960daa7@weissschuh.net> References: <20260419-nolibc-open-mode-v1-0-8dc5a960daa7@weissschuh.net> In-Reply-To: <20260419-nolibc-open-mode-v1-0-8dc5a960daa7@weissschuh.net> To: Willy Tarreau Cc: linux-kernel@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1776612568; l=2918; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=EUJxU5aby5poCXi4gxuvYlGYuWCtAZuZinfkh9a0qao=; b=+BdxggvPek/MkiqJXT1AiziUQ3+yMa3VtZNHGw3mTde4FAyGDsT26M31UTjYRtJcspDo/akIv TkjRjwS7euhDo/XaFwOaMP2ggDjTIoLn790+/9yDd+0tPfUCP4NiFdp X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= The current handling of the optional mode arguments using va_list has some drawbacks. It is hard for the compiler to optimize away and it needs specific code to handle the O_ flags that need to pass the mode parameter. Currently that mode parameter is not respected for O_TMPFILE, which is a bug. Switch to a macro-based variant which does not generate any additional code and avoid the explicit handling of 'mode'. The macros require somewhat recent compiler versions, but users stuck on old compilers have a trivial workaround by always specifying mode. Signed-off-by: Thomas Wei=C3=9Fschuh --- It might also possible to use macros similar to syscall() to not require __VA_OPT__, but those would be fairly ugly. --- tools/include/nolibc/compiler.h | 2 ++ tools/include/nolibc/fcntl.h | 34 +++++++++++++--------------------- 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/tools/include/nolibc/compiler.h b/tools/include/nolibc/compile= r.h index b56570bf9f69..a154aa4e143a 100644 --- a/tools/include/nolibc/compiler.h +++ b/tools/include/nolibc/compiler.h @@ -90,4 +90,6 @@ # define __nolibc_no_sanitize_undefined #endif =20 +#define __nolibc_first_arg(_a1, ...) _a1 + #endif /* _NOLIBC_COMPILER_H */ diff --git a/tools/include/nolibc/fcntl.h b/tools/include/nolibc/fcntl.h index 56650a36f856..89436a72e987 100644 --- a/tools/include/nolibc/fcntl.h +++ b/tools/include/nolibc/fcntl.h @@ -25,18 +25,8 @@ int _sys_openat(int dirfd, const char *path, int flags, = mode_t mode) } =20 static __attribute__((unused)) -int openat(int dirfd, const char *path, int flags, ...) +int openat(int dirfd, const char *path, int flags, mode_t mode) { - mode_t mode =3D 0; - - if (flags & O_CREAT) { - va_list args; - - va_start(args, flags); - mode =3D va_arg(args, mode_t); - va_end(args); - } - return __sysret(_sys_openat(dirfd, path, flags, mode)); } =20 @@ -51,20 +41,22 @@ int _sys_open(const char *path, int flags, mode_t mode) } =20 static __attribute__((unused)) -int open(const char *path, int flags, ...) +int open(const char *path, int flags, mode_t mode) { - mode_t mode =3D 0; + return __sysret(_sys_open(path, flags, mode)); +} =20 - if (flags & O_CREAT) { - va_list args; +#if __nolibc_gnuc_version >=3D __nolibc_version(8, 0, 0) || \ + __nolibc_clang_version >=3D __nolibc_version(12, 0, 0) =20 - va_start(args, flags); - mode =3D va_arg(args, mode_t); - va_end(args); - } +# define __nolibc_open_mode(...) __nolibc_first_arg(__VA_ARGS__ __VA_OPT_= _(,) 0) =20 - return __sysret(_sys_open(path, flags, mode)); -} +# define open(path, flags, ...) \ + open(path, flags, __nolibc_open_mode(__VA_ARGS__)) +# define openat(dirfd, path, flags, ...) \ + openat(dirfd, path, flags, __nolibc_open_mode(__VA_ARGS__)) + +#endif =20 /* * int creat(const char *path, mode_t mode); --=20 2.53.0