From nobody Tue Jun 16 19:36:41 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 C71862D7814 for ; Wed, 29 Apr 2026 14:45:26 +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=1777473929; cv=none; b=QkHL4QQJ78mBWOraCdrcRHo5pTVKxHIlsOsz1UUCpm4gB3c3b4jKVHnItW9Pyrzprzy2As74iprzwTnOSbrUvS/Lx5hdasFhcBeJ+xIT7t/al5EKd9Cme0j1qFEXkY43Lx+YGcJ/Sgop+YKeKAQIeMwvTDsSJ7w6J6uyn3F1mJ0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777473929; c=relaxed/simple; bh=8Ex6oahs9xsi8Bjj516Z2UAY6DnCBws19jXZSfv8kJY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=adZWjN10tV6XopVyVkYRnrPXWz569CogUSZezIib+mqezTyecrKjsnuSIG0HpALLKytu3e/Kzb6UoLXFzi6Vyg8wz4/Gedzt5EAbFcQhIYRfLNN8/RRiswDklRIjBm1KzBsgtCi9er2TT/Xn7I8vuozTRofvgKezVIhhnLLNBGA= 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=uKwJubCV; 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="uKwJubCV" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1777473921; bh=8Ex6oahs9xsi8Bjj516Z2UAY6DnCBws19jXZSfv8kJY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=uKwJubCVTkjFerboGLLOo5F1+m0BRAURytPay3Mq5z1XlaDz7TIA8PLzsHgXWtAfH nI0zbLDRSuLoQSj3rI9Q3nB2+RZTc7JbiCdcDWRo0xAl2XQtxlXbYiQCEfTz2Xeop8 +e0HIlZa8SdwEiCefzGTmM0JxNjsStzxaSiGhfBw= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Wed, 29 Apr 2026 16:45:09 +0200 Subject: [PATCH 1/4] tools/nolibc: split implicit open flags into a macro 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: <20260429-nolibc-open-tmpfile-v1-1-63d19c95c0a5@weissschuh.net> References: <20260429-nolibc-open-tmpfile-v1-0-63d19c95c0a5@weissschuh.net> In-Reply-To: <20260429-nolibc-open-tmpfile-v1-0-63d19c95c0a5@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=1777473920; l=1567; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=8Ex6oahs9xsi8Bjj516Z2UAY6DnCBws19jXZSfv8kJY=; b=f4bliBb2PPmDV6nn/SPqMyVXaCX61d31DqF/dZubAwQdNFl2deW2g3Bwt7I3wzSm22wXjSv8G 38V54gDP5/PCMgIPn94WOp8YL3LxmQ8LVoLcAEfZEy9hizGpcNhhZNU X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= This logic is duplicated and its current form will be in the way of some upcoming simplificiations. Move it into a macro to avoid the duplication and enable some cleanups. Signed-off-by: Thomas Wei=C3=9Fschuh Acked-by: Willy Tarreau --- tools/include/nolibc/fcntl.h | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tools/include/nolibc/fcntl.h b/tools/include/nolibc/fcntl.h index 014910a8e928..46f591cf82fd 100644 --- a/tools/include/nolibc/fcntl.h +++ b/tools/include/nolibc/fcntl.h @@ -14,6 +14,8 @@ #include "types.h" #include "sys.h" =20 +#define __nolibc_open_flags(_flags) ((_flags) | O_LARGEFILE) + /* * int openat(int dirfd, const char *path, int flags[, mode_t mode]); */ @@ -29,8 +31,6 @@ int openat(int dirfd, const char *path, int flags, ...) { mode_t mode =3D 0; =20 - flags |=3D O_LARGEFILE; - if (flags & O_CREAT) { va_list args; =20 @@ -39,7 +39,7 @@ int openat(int dirfd, const char *path, int flags, ...) va_end(args); } =20 - return __sysret(_sys_openat(dirfd, path, flags, mode)); + return __sysret(_sys_openat(dirfd, path, __nolibc_open_flags(flags), mode= )); } =20 /* @@ -57,8 +57,6 @@ int open(const char *path, int flags, ...) { mode_t mode =3D 0; =20 - flags |=3D O_LARGEFILE; - if (flags & O_CREAT) { va_list args; =20 @@ -67,7 +65,7 @@ int open(const char *path, int flags, ...) va_end(args); } =20 - return __sysret(_sys_open(path, flags, mode)); + return __sysret(_sys_open(path, __nolibc_open_flags(flags), mode)); } =20 /* --=20 2.54.0 From nobody Tue Jun 16 19:36:41 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 C73032FD696 for ; Wed, 29 Apr 2026 14:45:26 +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=1777473930; cv=none; b=g+A8TQrMbeC1oA1PnVIW6kK1k91SELo0d6WtaTjbr/k+wgT3JUEniEryL116hCRRvwILhUwmoSPSSnCdwL2vsqKPw1HIxP77Tt6w+6Pu0g4BanzDB5hdXoPEdlFzTBaPlyWonTKu1v/4TDwA6NYZG0ipZvdabehIglZM6mbwIqk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777473930; c=relaxed/simple; bh=+iD0DTH8fHV1UU32ZChoR5rEtiyQRBQnCO9QdLA5QLg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=GVmuyyjjpAs4v79B76PA3JSagOwZ/C0lrxs2TRZuBkA1cim5dJp/SPlZS8f2tKfSdMrUPe52AwxLqqspyv+JUXxOCPHDg+tFd9NG06/clQej5MJSb2jI7xsDj880w3gbefpDtBEPYbHChh7anarWui0Vlm2nl+mG3mLgSMxOIA4= 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=Iw5SuFIS; 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="Iw5SuFIS" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1777473921; bh=+iD0DTH8fHV1UU32ZChoR5rEtiyQRBQnCO9QdLA5QLg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Iw5SuFISmU4jBfAbrnMNywS+OULMpWqZqThJQDR5eDlOwj2htxkyM2TRLuUMmMOGV QO+V6XYMq8cFFMsy0NxUMh+C5zfglFWpT84V+G15xvcOF2jF8guRtQZhrw7Y2kKlYp fv2xiXI6IUnotsdSVvX3r9u8b3iyEITH2SEKy4EE= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Wed, 29 Apr 2026 16:45:10 +0200 Subject: [PATCH 2/4] tools/nolibc: split open mode handling into a macro 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: <20260429-nolibc-open-tmpfile-v1-2-63d19c95c0a5@weissschuh.net> References: <20260429-nolibc-open-tmpfile-v1-0-63d19c95c0a5@weissschuh.net> In-Reply-To: <20260429-nolibc-open-tmpfile-v1-0-63d19c95c0a5@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=1777473920; l=2125; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=+iD0DTH8fHV1UU32ZChoR5rEtiyQRBQnCO9QdLA5QLg=; b=TJ42K2ReDCEr/CGvy1bn8v3327/kpXV9CHEfu4YMQ+BWwfiqW5848tSzklHv+wm94XK4tNT0j 8LLDsTmeFNSBMmpv0O9j1CdmHIxkcJdKEEqSCuyPnwIEWf9plslH5JX X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= This logic is duplicated and some upcoming extensions would require even more duplicated logic. Move it into a macro to avoid the duplication and allow cleaner changes. Signed-off-by: Thomas Wei=C3=9Fschuh Acked-by: Willy Tarreau --- tools/include/nolibc/fcntl.h | 40 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/tools/include/nolibc/fcntl.h b/tools/include/nolibc/fcntl.h index 46f591cf82fd..d7ea02e1332d 100644 --- a/tools/include/nolibc/fcntl.h +++ b/tools/include/nolibc/fcntl.h @@ -16,6 +16,21 @@ =20 #define __nolibc_open_flags(_flags) ((_flags) | O_LARGEFILE) =20 +#define __nolibc_open_mode(_flags) \ +({ \ + 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); \ + } \ + \ + _mode; \ +}) + /* * int openat(int dirfd, const char *path, int flags[, mode_t mode]); */ @@ -29,17 +44,8 @@ int _sys_openat(int dirfd, const char *path, int flags, = mode_t mode) static __attribute__((unused)) int openat(int dirfd, const char *path, int flags, ...) { - 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, __nolibc_open_flags(flags), mode= )); + return __sysret(_sys_openat(dirfd, path, __nolibc_open_flags(flags), + __nolibc_open_mode(flags))); } =20 /* @@ -55,17 +61,7 @@ int _sys_open(const char *path, int flags, mode_t mode) static __attribute__((unused)) int open(const char *path, int flags, ...) { - 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_open(path, __nolibc_open_flags(flags), mode)); + return __sysret(_sys_open(path, __nolibc_open_flags(flags), __nolibc_open= _mode(flags))); } =20 /* --=20 2.54.0 From nobody Tue Jun 16 19:36:41 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 8FA2827E1DC for ; Wed, 29 Apr 2026 14:45:28 +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=1777473930; cv=none; b=BAYZ8esiovM9YN5SoUL3jLPeVpz711OZDtgpQDE7/kcQwEXwmOvGzUIox6pO3h7mYhjlTAeZ/lwQ2aXpMLWU3GhtabWsk0Q9PmJkQUG1KSF1CztdbMN7cnB5ex56wm1E3J/s7Yx7yBKWn9EWmYLFdUeUaX/IsMNe+KFPi1e9VFc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777473930; c=relaxed/simple; bh=SHBlFtD6drZt6Cq/XWWpwS47GmUnuNg91CUUI2K8XCU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=MAspd1k+O2Mb5pZmmOsyRJOZkil9zPBywjDTHj9kF1w0nEd28P2c4aniQGgakUWe6sU3bSQLxll/hJJHVlbSHI6lYTSz1RLvP4rEMO6JqRlikGQxZ6pyFNkpSJB5jR7bhOvfrLpwGGEHcwhUDrcVO5YptIrYlyom9Syf+pU89AI= 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=HDBJULV1; 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="HDBJULV1" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1777473921; bh=SHBlFtD6drZt6Cq/XWWpwS47GmUnuNg91CUUI2K8XCU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=HDBJULV1mrm+5B1hy3tuP4kW0gr35IKqe9bjlMXPrEc67AvCmv1lm7yAinenUfixd dy97vbOn0aPvHPR+wel3ZRdxeSQZ0RyesGagFw8W9iafZTahQkZwje0P/AUHbXg6+I RNnX3QcCZyiSWx2XW7wSBGWuPWIzhIc3oHPqma68= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Wed, 29 Apr 2026 16:45:11 +0200 Subject: [PATCH 3/4] tools/nolibc: pass mode to open syscall if O_TMPFILE is set 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: <20260429-nolibc-open-tmpfile-v1-3-63d19c95c0a5@weissschuh.net> References: <20260429-nolibc-open-tmpfile-v1-0-63d19c95c0a5@weissschuh.net> In-Reply-To: <20260429-nolibc-open-tmpfile-v1-0-63d19c95c0a5@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=1777473920; l=813; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=SHBlFtD6drZt6Cq/XWWpwS47GmUnuNg91CUUI2K8XCU=; b=oja3GJe48GCriSM6GImvfHQbxzHyrsttNmKUql5vn5n1wya1D6nwPLefNyBIQpJvf/gIxwwmR zJctiHYGg8/DfGxG4g941F+a712GBbBDpKqXqo3f/Gw27EoHLUye1KR X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= When O_TMPFILE is set, the open mode needs to be passed to the kernel as per the documentation. Fixes: a7604ba149e7 ("tools/nolibc/sys: make open() take a vararg on the 3r= d argument") Signed-off-by: Thomas Wei=C3=9Fschuh Acked-by: Willy Tarreau --- tools/include/nolibc/fcntl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/include/nolibc/fcntl.h b/tools/include/nolibc/fcntl.h index d7ea02e1332d..c401419e12b1 100644 --- a/tools/include/nolibc/fcntl.h +++ b/tools/include/nolibc/fcntl.h @@ -20,7 +20,7 @@ ({ \ mode_t _mode =3D 0; \ \ - if ((_flags) & O_CREAT) { \ + if (((_flags) & O_CREAT) || (((_flags) & O_TMPFILE) =3D=3D O_TMPFILE)) { = \ va_list args; \ \ va_start(args, (_flags)); \ --=20 2.54.0 From nobody Tue Jun 16 19:36:41 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 C8A3130DEB2 for ; Wed, 29 Apr 2026 14:45:26 +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=1777473931; cv=none; b=aUF0+NglA9q1HPw2zoy586Gtt8Ejz83CyNuuJX2E3oPrXSrl2GsSBHEk1tXqvXqkGKM6qF3hTk74205YpbUgLom8J4ZmXWxGgNkkKiTD/MlUQZuAc81N2oCEvEluZ4v7RpgMw65ToGEdqxjOIKTTGs9ZTRXc1yIcU4Fjq45ssvE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777473931; c=relaxed/simple; bh=Yvyr76d9HMXWyv14DckkXYjVIs9bNiF+Uf63JEOWnFs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WhOLLSfUe3SX2sBGsBK4sbXTud/zUmWv449yYaCaYQxZ3bVBLIMAv7NuXQJEuJXUtTFmXBDVqVqXpyRWgr57AejDVV7RW7JpLu+itQ57WaiGY0/Qj4k4GrnSdrlACqiyD0UV3qBFefomRqklh2elrWTYwVf8t0i5fuzgDhQvQgk= 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=V5yE1Wta; 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="V5yE1Wta" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1777473921; bh=Yvyr76d9HMXWyv14DckkXYjVIs9bNiF+Uf63JEOWnFs=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=V5yE1WtaZI+5cJJodbtrlI24zX+4/Q63ggSoqxw0h0IhaFcU+3WkwzSgoe38Odn9z cnwlzeM9M+PN9w1m5stlvO3/UP7jBAvVHf0zjlbWi+4nDPYz9tW9KWTEJHeuqgGnCz Wz0/PW5CSq2FFkRyKXyi8FMxKMY5P5DOYkoVE5r8= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Wed, 29 Apr 2026 16:45:12 +0200 Subject: [PATCH 4/4] selftests/nolibc: test open mode handling 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: <20260429-nolibc-open-tmpfile-v1-4-63d19c95c0a5@weissschuh.net> References: <20260429-nolibc-open-tmpfile-v1-0-63d19c95c0a5@weissschuh.net> In-Reply-To: <20260429-nolibc-open-tmpfile-v1-0-63d19c95c0a5@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=1777473920; l=1799; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=Yvyr76d9HMXWyv14DckkXYjVIs9bNiF+Uf63JEOWnFs=; b=M66mw8AizHHNg4dd8WNc3ZqKqBg6t73XX2MNbIm9PRvEl2A2xXWxZmTJMfkEyND239aXDkYp/ iDknuVrkBLIBu8uDx4ZQf68HSepFygAt45uy3zkrGPZlvDyvAN8JXSs X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= Add a selftest for the new O_TMPFILE open mode handling. While O_CREAT or openat() are not tested, the code is the same, so assume these also work. Signed-off-by: Thomas Wei=C3=9Fschuh Acked-by: Willy Tarreau --- tools/testing/selftests/nolibc/nolibc-test.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/s= elftests/nolibc/nolibc-test.c index 08610cacf030..6a03781fffab 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -1300,6 +1300,28 @@ int test_openat(void) return 0; } =20 +int test_open_mode(void) +{ + const mode_t mode =3D 0444; + struct stat stat_buf; + int fd, ret; + + fd =3D open("/tmp", O_TMPFILE | O_RDWR, mode); + if (fd =3D=3D -1) + return -1; + + ret =3D fstat(fd, &stat_buf); + close(fd); + + if (ret =3D=3D -1) + return -1; + + if ((stat_buf.st_mode & 0777) !=3D mode) + return -1; + + return 0; +} + int test_nolibc_enosys(void) { if (true) @@ -1535,6 +1557,7 @@ int run_syscall(int min, int max) CASE_TEST(open_tty); EXPECT_SYSNE(1, tmp =3D open("/dev/null", = O_RDONLY), -1); if (tmp !=3D -1) close(tmp); break; CASE_TEST(open_blah); EXPECT_SYSER(1, tmp =3D open("/proc/self/b= lah", O_RDONLY), -1, ENOENT); if (tmp !=3D -1) close(tmp); break; CASE_TEST(openat_dir); EXPECT_SYSZR(1, test_openat()); break; + CASE_TEST(open_mode); EXPECT_SYSZR(1, test_open_mode()); break; CASE_TEST(pipe); EXPECT_SYSZR(1, test_pipe()); break; CASE_TEST(poll_null); EXPECT_SYSZR(1, poll(NULL, 0, 0)); break; CASE_TEST(poll_stdout); EXPECT_SYSNE(1, ({ struct pollfd fds =3D {= 1, POLLOUT, 0}; poll(&fds, 1, 0); }), -1); break; --=20 2.54.0