From nobody Fri Jun 12 14:00:00 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 2AA8F3C768A for ; Thu, 14 May 2026 12:05:15 +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=1778760316; cv=none; b=Ir0i7IFcAcp2u1uTdIe9VJgTP1iCQrTexzZMUSCOViVUd0jMmY+qICAOxhDXA5LE9kucmv5u7lgf68vKovvfXO0kZivVBkornoHVf7ChMm2rcVosPenJlVNIxYYpgzRpWrfMTOllP/QkcPA0ZvWvPCsujjDZoBA5qg9OycYEjFQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778760316; c=relaxed/simple; bh=WBGWBBRWJ7w0mLToE/vXf/0kpWuSbT+iI61hREkihWg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=fjvZVcKQDa+iJLTk3mDGkTVbiTmvlB14Kg0Sd5S6YTpi9U5qKqErFii7tjlxZDxJRyV1/H+nm1UvMk5Ggxv2D+CiTRiUEpv04rfOVPQu+f+99gMEv9QQ5XPfaa/ZNd2NGsQYiymlJKqyurmhnYATyqteqSklph5ZQjaNfPbirr4= 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=UuhX3o12; 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="UuhX3o12" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1778760313; bh=WBGWBBRWJ7w0mLToE/vXf/0kpWuSbT+iI61hREkihWg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=UuhX3o12NUEsIvtzV602lNfyAsuutcdDgG1C7Qj0oGR0tJhzlWgguZjxN7wehMwje CP7zbXwTvQnYc/xx6xkShfON1SQDj7Z8grRsqdTC/gXEJFPXhY0ZVwXcw8w//Id2cP 62Nh2i1N4VWik5w3pV80wrsMcKdA0dhEIdkSWB8E= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Thu, 14 May 2026 14:05:11 +0200 Subject: [PATCH v2 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: <20260514-nolibc-open-tmpfile-v2-1-b4c6c5efa266@weissschuh.net> References: <20260514-nolibc-open-tmpfile-v2-0-b4c6c5efa266@weissschuh.net> In-Reply-To: <20260514-nolibc-open-tmpfile-v2-0-b4c6c5efa266@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=1778760312; l=1603; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=WBGWBBRWJ7w0mLToE/vXf/0kpWuSbT+iI61hREkihWg=; b=5Cb23NVT9C4hVxeDrDbz5Upouuee8+xq+amLjQQfo6m6+1WGH18Gaa4tvUGmvAvC/7MNUWCLk yF/FrnDWCN1DAE91TZ2t/edIGfHhVEIyErBRhXhDnIEnoirtf8zfQXL 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 Fri Jun 12 14:00:00 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 172353C1976 for ; Thu, 14 May 2026 12:05:15 +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=1778760317; cv=none; b=d9ViA5rQiWbLMJgujrMOiVTaLHpth3Ix9LSGsZwf46Jf/X77HihhVFxdpx2COmmoXaqA4Xd/DbI4kec7XGNIAT39I/M72NKkp0DUANlbR4hgKGryPALEl+WSjcRaUFtAUKb/0nvqiRignQLyZVGaDPnDetow3yZeV/EahAHNT9I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778760317; c=relaxed/simple; bh=OzhbJErdpi5kofWxecp9Bm1Q1npXYSoFwhp+v8vn9TI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=fbClsmnkk6yyeJ9lctYpKC4DVvLmtVi8+PR16hj+2LU8rPpKBcKEkGCNPRkEMAaS+cCUf5cleTOIPcO1Ix4EgPLAFz5y0R/QKkyaPfiU7wE8Qap4HMUOxX0M0CUVJy2/WIGkZZfycob2Y0Bmlb+ukmYPv2h+Dz9Jl0+0beUQEs4= 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=eIgomS9A; 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="eIgomS9A" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1778760313; bh=OzhbJErdpi5kofWxecp9Bm1Q1npXYSoFwhp+v8vn9TI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=eIgomS9APoizFgZRbVfgQBIoOxgVzVucb3n2wLCZ8LnynRv6v2zhpVhozrMPCzIKN 2LlCdRm3Zg62zhW44SBNbDMHdtjTCMQF+AZc4LWqu0zgT1FPZjmnRRRzuI1OpW7T9g EueRbhp7RMzSuuOk6EfDeCJb+BA6DUURpQst5b+k= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Thu, 14 May 2026 14:05:12 +0200 Subject: [PATCH v2 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: <20260514-nolibc-open-tmpfile-v2-2-b4c6c5efa266@weissschuh.net> References: <20260514-nolibc-open-tmpfile-v2-0-b4c6c5efa266@weissschuh.net> In-Reply-To: <20260514-nolibc-open-tmpfile-v2-0-b4c6c5efa266@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=1778760312; l=2161; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=OzhbJErdpi5kofWxecp9Bm1Q1npXYSoFwhp+v8vn9TI=; b=r6bEpWPuF+lBr3vXuWAZojZ6JW5jRYXQKoiTbUZ3DSGsOlfkiTKc7U5JUQ6BVzYAD/Qex/xQH I4VqBrywjFCAIORwhKCSf/hGKpgbHHryYxDp93jspBsXd9v9WEMXp5U 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 Fri Jun 12 14:00:00 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 C911D397E80 for ; Thu, 14 May 2026 12:05:15 +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=1778760317; cv=none; b=GrkQbpbRvPkgv1but6l8q4n/JWLdeGe+CriNmdYo/jOjuwwJ8r1mfdqdBLpE7s8Jbk6SvNNzjT/uMe72gcN3OvOG4z4jRUvTmFrgUKKyX7Ztfm9s2MoeU+lBvQjGtltmshxhMgznRuXHLa/SOSdkbxxDmvNloIaoP9ZKp8s1nuI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778760317; c=relaxed/simple; bh=7wm2f9hAnKbhD20sgub75gG4A7kezXuwZCRSyREaRpw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=PwZ9NVaJ9su+aw1wwJiwU/bcJTkPlACLM65fiC9d9r8/ZNiG0P8DfyFNSW7cnTPu+s3i/rOpsBxSgdw0u3TWAjQh5lo2+20rYksZwOrCQ4ApWNdAcl5HFfACA0/Au+j/fPmY6Ki5djaf3Dcs4ru12mVAoo9BxGVsnOoBUWkTfSw= 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=n11PCePd; 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="n11PCePd" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1778760313; bh=7wm2f9hAnKbhD20sgub75gG4A7kezXuwZCRSyREaRpw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=n11PCePdAUqFCydQjZxItUicKNpd7qZVuuBAnjN/fHnRiR9JWsI02TP5JpTIgUjFY MXscvDZF9ivTztBq2jrOhNKsuFPkJweQPdqWae/I8CAcWkFECqmgmV/LwUakpg0iP7 m9XL9jUqshNgow0sCwSvo1+SkVhzHRe5xzCR5YgU= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Thu, 14 May 2026 14:05:13 +0200 Subject: [PATCH v2 3/4] tools/nolibc: always pass mode to open syscall 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: <20260514-nolibc-open-tmpfile-v2-3-b4c6c5efa266@weissschuh.net> References: <20260514-nolibc-open-tmpfile-v2-0-b4c6c5efa266@weissschuh.net> In-Reply-To: <20260514-nolibc-open-tmpfile-v2-0-b4c6c5efa266@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=1778760312; l=1434; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=7wm2f9hAnKbhD20sgub75gG4A7kezXuwZCRSyREaRpw=; b=ELRlciMkOPEefAqzugFUp2GvpX/MaLjYep4jjIDFI3zJm2frU5A89n81la5cxJX6HUbJZ/E4x F8zJc+TmzQoB/kCHwhd6xfd5yi0tVPdEET0gjbBVr8sp65ps5+dbhpv 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. 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 3r= d argument") Suggested-by: Willy Tarreau Link: https://lore.kernel.org/lkml/afRfjdovT6pNtwtP@1wt.eu/ Signed-off-by: Thomas Wei=C3=9Fschuh Acked-by: Willy Tarreau --- tools/include/nolibc/fcntl.h | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/tools/include/nolibc/fcntl.h b/tools/include/nolibc/fcntl.h index d7ea02e1332d..d4b6af60d4cc 100644 --- a/tools/include/nolibc/fcntl.h +++ b/tools/include/nolibc/fcntl.h @@ -18,15 +18,12 @@ =20 #define __nolibc_open_mode(_flags) \ ({ \ - mode_t _mode =3D 0; \ + mode_t _mode; \ + va_list args; \ \ - if ((_flags) & O_CREAT) { \ - va_list args; \ - \ - va_start(args, (_flags)); \ - _mode =3D va_arg(args, mode_t); \ - va_end(args); \ - } \ + va_start(args, (_flags)); \ + _mode =3D va_arg(args, mode_t); \ + va_end(args); \ \ _mode; \ }) --=20 2.54.0 From nobody Fri Jun 12 14:00:00 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 172C73C417B for ; Thu, 14 May 2026 12:05:14 +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=1778760316; cv=none; b=pfQ22pV6A7wd/knWVAs5lQYwJSb+CSsjTzR9rPUM6d/xKOfMMYlKUoO7Br5whcbgTYCkl+g7H8Acd2uP4TPhGRT/M8WucmQTw/S2awmcDPcgXampuse91SQDeJKgO433IJZ1EtU37LlMEI4KiJ9c/iXF4RNvY1BvjiS37NFB+zg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778760316; c=relaxed/simple; bh=wwpt8S8jJUGaTDEX26WdQlXWM9LM8+wM9UtOfJ8MARY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WStVP4/otwtRyaoHIBbGq6Qj24Q5lVhRVm0M6dd61rLqgNDbJ+NZtaiV23iDH4aw940aQhXy//28V0IhrUA0cq7ESI8C2ZxrnbBK4yKbT+0hDcGS8D7vKHBenSpOyNXv+q3ToiJ1TrsCuWMVJki9TYuh7zotWGWLkXMYFm2mxQY= 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=aA/o4A7o; 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="aA/o4A7o" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1778760313; bh=wwpt8S8jJUGaTDEX26WdQlXWM9LM8+wM9UtOfJ8MARY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=aA/o4A7o/g58b01uxFeKAZiC3Ilq+ElPDKkGwsSVwy8eWh56yDi+f+UAtTQRJVJ0h 594s7EWNUp0C7L6LJoLRiVnBsBN7Ulr5wX8Kl1ekPSAPFz31CjjE85V/h/kKQHwHMS 3XapHmq0NoSmCEuXfT6PXuBweH2JolfelNZAVk3A= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Thu, 14 May 2026 14:05:14 +0200 Subject: [PATCH v2 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: <20260514-nolibc-open-tmpfile-v2-4-b4c6c5efa266@weissschuh.net> References: <20260514-nolibc-open-tmpfile-v2-0-b4c6c5efa266@weissschuh.net> In-Reply-To: <20260514-nolibc-open-tmpfile-v2-0-b4c6c5efa266@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=1778760312; l=1835; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=wwpt8S8jJUGaTDEX26WdQlXWM9LM8+wM9UtOfJ8MARY=; b=FqqCEgACsiUWtKaatzJKNDk33nkFEp6+8eYBLZxYUerwr3zAB6WrWCFkfQvUb82KJMdggGCuI 6RfLj/5G2YwBjMZp9zJInrqJicjxiIP9VNuvKRp9qXJxDtrA1Zv2Vfr 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 1db6e8d55c16..c3867cc570c6 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -1305,6 +1305,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) @@ -1540,6 +1562,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