From patchwork Thu May 15 19:57:47 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 890417 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 45812269B07; Thu, 15 May 2025 19:58:21 +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=1747339105; cv=none; b=NRS7eXYiQMUVSSs+OM6+6zuSpRgkxEj9jmpoqUjW4bMt8qSkoxvdu6LcO6zi5QnKgBW5mLtL27UMDEZS9ho6YapKocWvaTnpjNGlNoeWNaxLV/+xPnRI1pdcTe6MUrlDBNDxSBmj9oNCxjYaGAzFk4hY/GcRdBGOTt3VsW7aU3o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747339105; c=relaxed/simple; bh=kSM1bMW0+DdV7v7mJM3vOo2rB0NxykmWPI2GBmXW580=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=JpMgL+3S89Lbo6Qzgp1pVIgpeagGmfKwE6hvMEugn/gxJbQbfogVM+GtyvNk0o89FnIGtxssovskaxG8oQPW9f36YRspRPafM+rStNr/dyzJnNnB+o2yXRFUeJz9xdbD26qDEuHbxwo1QGjVInF8wJqpfYZ5kzvzGDLMBs++aMo= 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=JSV+bIcU; 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="JSV+bIcU" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1747339092; bh=kSM1bMW0+DdV7v7mJM3vOo2rB0NxykmWPI2GBmXW580=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=JSV+bIcUPO2ZGvCByrzetPHwmG2F0KwurIrITftorgw2nkuqrLaVmIRGmt7JdtZnP zXZBVXD4iIeZBTq998BMJE3Kq8EE2qAv2t5lVMQLsooOxr/Ylmmj1L0B7o3mVvt02a IzpHUnFCCYXeY6V3hovIrf2Fqx9/W3w9ZjwWYVjg= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Thu, 15 May 2025 21:57:47 +0200 Subject: [PATCH 1/9] tools/nolibc: move ioctl() to sys/ioctl.h Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250515-nolibc-sys-v1-1-74f82eea3b59@weissschuh.net> References: <20250515-nolibc-sys-v1-0-74f82eea3b59@weissschuh.net> In-Reply-To: <20250515-nolibc-sys-v1-0-74f82eea3b59@weissschuh.net> To: Willy Tarreau , Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1747339091; l=2838; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=kSM1bMW0+DdV7v7mJM3vOo2rB0NxykmWPI2GBmXW580=; b=xdJfwjYCyN0LOEllnfA0IzlQCNpGMTh01WdmXuSRwrGbv2rIrDbF9EZji13+Z+v/wTo7cbqXQ X+yB9na3+5WBb4AixxJeHEEeg0Bs6E+ObS64cAXkcIKfwEGXwg00n1U X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= This is the location regular userspace expects this definition. Signed-off-by: Thomas Weißschuh --- tools/include/nolibc/Makefile | 1 + tools/include/nolibc/nolibc.h | 1 + tools/include/nolibc/sys.h | 12 ------------ tools/include/nolibc/sys/ioctl.h | 29 +++++++++++++++++++++++++++++ 4 files changed, 31 insertions(+), 12 deletions(-) diff --git a/tools/include/nolibc/Makefile b/tools/include/nolibc/Makefile index 4c4b7b5ff605ac5dde11628331378489d76d4466..7d66847df91a94ca784c04ced278eb6d7099bab4 100644 --- a/tools/include/nolibc/Makefile +++ b/tools/include/nolibc/Makefile @@ -49,6 +49,7 @@ all_files := \ string.h \ sys.h \ sys/auxv.h \ + sys/ioctl.h \ sys/mman.h \ sys/random.h \ sys/stat.h \ diff --git a/tools/include/nolibc/nolibc.h b/tools/include/nolibc/nolibc.h index 51c423a36b5957e2528e94d717d88e2383230cba..d6048d1e9ea5d4b5d504e156aafc5651dcd6b8c1 100644 --- a/tools/include/nolibc/nolibc.h +++ b/tools/include/nolibc/nolibc.h @@ -97,6 +97,7 @@ #include "types.h" #include "sys.h" #include "sys/auxv.h" +#include "sys/ioctl.h" #include "sys/mman.h" #include "sys/random.h" #include "sys/stat.h" diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h index 5733fe54911dca44c7423951ff85fb166d95c06f..313c210173c804f728b0be4ab8e67542bb3a7219 100644 --- a/tools/include/nolibc/sys.h +++ b/tools/include/nolibc/sys.h @@ -517,18 +517,6 @@ uid_t getuid(void) } -/* - * int ioctl(int fd, unsigned long cmd, ... arg); - */ - -static __attribute__((unused)) -long sys_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg) -{ - return my_syscall3(__NR_ioctl, fd, cmd, arg); -} - -#define ioctl(fd, cmd, arg) __sysret(sys_ioctl(fd, cmd, (unsigned long)(arg))) - /* * int kill(pid_t pid, int signal); */ diff --git a/tools/include/nolibc/sys/ioctl.h b/tools/include/nolibc/sys/ioctl.h new file mode 100644 index 0000000000000000000000000000000000000000..cb34be92a5f96aa566afa53a0f19932c2d5fe1eb --- /dev/null +++ b/tools/include/nolibc/sys/ioctl.h @@ -0,0 +1,29 @@ +/* SPDX-License-Identifier: LGPL-2.1 OR MIT */ +/* + * Ioctl definitions for NOLIBC + * Copyright (C) 2017-2021 Willy Tarreau + */ + +/* make sure to include all global symbols */ +#include "nolibc.h" + +#ifndef _NOLIBC_SYS_IOCTL_H +#define _NOLIBC_SYS_IOCTL_H + +#include "../sys.h" + +#include + +/* + * int ioctl(int fd, unsigned long cmd, ... arg); + */ + +static __attribute__((unused)) +long sys_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg) +{ + return my_syscall3(__NR_ioctl, fd, cmd, arg); +} + +#define ioctl(fd, cmd, arg) __sysret(sys_ioctl(fd, cmd, (unsigned long)(arg))) + +#endif /* _NOLIBC_SYS_IOCTL_H */ From patchwork Thu May 15 19:57:48 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 890419 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 27FD01E480; Thu, 15 May 2025 19:58:20 +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=1747339103; cv=none; b=gImD4lzuXElw+WromB9Yfe25tUodzAYY/eOPwS7gwAlFa6KIrMugiPZTEio3BCthJOHvbljj6LSqAmb5DaPKmV9YI54FyMHV+FlzAYimNQIX+smvy6+B/KcDXibFHKHIb/HYZz1nhCJqONr40fz3uKG9j/dY6QJeFvDYGkrwKgk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747339103; c=relaxed/simple; bh=TvfFTWUEfp0HIUC1UiK0IdPOdFMzIQJdjD0UUr/+o0E=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=KTg11gh8NpbGoFBGYomH3vQgst2ytH+ajWu/F7ezeBPvf2Vn+U5599YjGIyWZNqZaJCzAOkDFc+kSnuPTAyaHB6PuiFiLhRT+pYLfELywl556lcuN331TRBm6jhUGbPRmf65n29hLzzPHerE7vzOfIAD4qMeD4mnwcz6iuc8Wa4= 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=onIOrrC/; 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="onIOrrC/" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1747339092; bh=TvfFTWUEfp0HIUC1UiK0IdPOdFMzIQJdjD0UUr/+o0E=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=onIOrrC/+PZ1lzbUoLwawy8U4RH/ZtuU/8dRKSoWIXcADDuulEl2wcEjKtUwJZ58A OQ4w8PzPRkUZIqmEOxP6Aph1pMFtoBqwmjgZ887ipTHWbH4wtPHFEi3I7p10WsGHIg zw4YVkf7Z7XQQprD82QR/dbZrLbx+DSHkstElIFg= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Thu, 15 May 2025 21:57:48 +0200 Subject: [PATCH 2/9] tools/nolibc: move mount() to sys/mount.h Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250515-nolibc-sys-v1-2-74f82eea3b59@weissschuh.net> References: <20250515-nolibc-sys-v1-0-74f82eea3b59@weissschuh.net> In-Reply-To: <20250515-nolibc-sys-v1-0-74f82eea3b59@weissschuh.net> To: Willy Tarreau , Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1747339091; l=3542; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=TvfFTWUEfp0HIUC1UiK0IdPOdFMzIQJdjD0UUr/+o0E=; b=3/DdAFeh3tu/36+3/jAUkeF62jqtj70ad4s9nUWZmK/Uc1wpKjwUdm10kEnVnEN/OOD+FAhGG /sqeusOOkUDBl2wShHHSSINDHBnZdH0TaucQ+jK6TMgT0G7BUpMjaGl X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= This is the location regular userspace expects this definition. Signed-off-by: Thomas Weißschuh --- tools/include/nolibc/Makefile | 1 + tools/include/nolibc/nolibc.h | 1 + tools/include/nolibc/sys.h | 20 -------------------- tools/include/nolibc/sys/mount.h | 37 +++++++++++++++++++++++++++++++++++++ 4 files changed, 39 insertions(+), 20 deletions(-) diff --git a/tools/include/nolibc/Makefile b/tools/include/nolibc/Makefile index 7d66847df91a94ca784c04ced278eb6d7099bab4..aa14dfddd77deb5442a6be65dee5684b6d218da7 100644 --- a/tools/include/nolibc/Makefile +++ b/tools/include/nolibc/Makefile @@ -51,6 +51,7 @@ all_files := \ sys/auxv.h \ sys/ioctl.h \ sys/mman.h \ + sys/mount.h \ sys/random.h \ sys/stat.h \ sys/syscall.h \ diff --git a/tools/include/nolibc/nolibc.h b/tools/include/nolibc/nolibc.h index d6048d1e9ea5d4b5d504e156aafc5651dcd6b8c1..690368f8e46c33df37c824429cf89dd0e95bb806 100644 --- a/tools/include/nolibc/nolibc.h +++ b/tools/include/nolibc/nolibc.h @@ -99,6 +99,7 @@ #include "sys/auxv.h" #include "sys/ioctl.h" #include "sys/mman.h" +#include "sys/mount.h" #include "sys/random.h" #include "sys/stat.h" #include "sys/syscall.h" diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h index 313c210173c804f728b0be4ab8e67542bb3a7219..e66dd6e760557333353d98da2627b038dffe7f93 100644 --- a/tools/include/nolibc/sys.h +++ b/tools/include/nolibc/sys.h @@ -672,26 +672,6 @@ int mknod(const char *path, mode_t mode, dev_t dev) return __sysret(sys_mknod(path, mode, dev)); } -/* - * int mount(const char *source, const char *target, - * const char *fstype, unsigned long flags, - * const void *data); - */ -static __attribute__((unused)) -int sys_mount(const char *src, const char *tgt, const char *fst, - unsigned long flags, const void *data) -{ - return my_syscall5(__NR_mount, src, tgt, fst, flags, data); -} - -static __attribute__((unused)) -int mount(const char *src, const char *tgt, - const char *fst, unsigned long flags, - const void *data) -{ - return __sysret(sys_mount(src, tgt, fst, flags, data)); -} - /* * int pipe2(int pipefd[2], int flags); diff --git a/tools/include/nolibc/sys/mount.h b/tools/include/nolibc/sys/mount.h new file mode 100644 index 0000000000000000000000000000000000000000..5129420e716d0a7e75c32a5bbc8f4e9f0e21b03b --- /dev/null +++ b/tools/include/nolibc/sys/mount.h @@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: LGPL-2.1 OR MIT */ +/* + * Mount definitions for NOLIBC + * Copyright (C) 2017-2021 Willy Tarreau + */ + +/* make sure to include all global symbols */ +#include "nolibc.h" + +#ifndef _NOLIBC_SYS_MOUNT_H +#define _NOLIBC_SYS_MOUNT_H + +#include "../sys.h" + +#include + +/* + * int mount(const char *source, const char *target, + * const char *fstype, unsigned long flags, + * const void *data); + */ +static __attribute__((unused)) +int sys_mount(const char *src, const char *tgt, const char *fst, + unsigned long flags, const void *data) +{ + return my_syscall5(__NR_mount, src, tgt, fst, flags, data); +} + +static __attribute__((unused)) +int mount(const char *src, const char *tgt, + const char *fst, unsigned long flags, + const void *data) +{ + return __sysret(sys_mount(src, tgt, fst, flags, data)); +} + +#endif /* _NOLIBC_SYS_MOUNT_H */ From patchwork Thu May 15 19:57:50 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 890418 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 2809825A646; Thu, 15 May 2025 19:58:20 +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=1747339104; cv=none; b=kpBfkENUyIaxX+dJzGtrvyU7akIvDOhGL92IzT7NIZmhPIur3Z0Rc52z1g8OE2ujiSSKLVxa+VSSxDcF2bXC2f5j4NrOJmCcBxvJRstL04sw+Ycf1qbJB8s8Stbfo+eAr6gRsPQ8ugvjaq33dEw5IcbzhHL2Ra09YQ0Ca8YD3+I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747339104; c=relaxed/simple; bh=Pg5hG2NXJIJ2AsojvxyH+DEumI/6ZQZsHN1YJrvIni4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=YmKsga/GzL21hovK4gk/YXlaPpRkHfbboJKQ47zdopB/0RReYmhf49hDfPFrjSEShegu2SkrRYx8LHGUz9SX+xtkCdRJWBnZcqlAbXdQJtM2Yutm5wmpRevdh/TYkXwvr7oM91tcOA0aDK9AUcxCgJQkQJ6FQIV4/yPO8onJm9I= 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=Oete7QE9; 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="Oete7QE9" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1747339092; bh=Pg5hG2NXJIJ2AsojvxyH+DEumI/6ZQZsHN1YJrvIni4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Oete7QE9FEy5ARoDlAAWYcFZ+QJWuJ3IO3NylIUU1Ff+JUNVWUFO1hYTw0uXoteYW rBYLiFPr/LZIud10uikynE7UtEMPHAzehHC1/jujNc5oNyYSGNg4kGQZX4qph/mnti Y6V1wPkoGbxNgwgeVaNIkIAU+eLlRhHmwdMdHyEA= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Thu, 15 May 2025 21:57:50 +0200 Subject: [PATCH 4/9] tools/nolibc: move reboot() to sys/reboot.h Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250515-nolibc-sys-v1-4-74f82eea3b59@weissschuh.net> References: <20250515-nolibc-sys-v1-0-74f82eea3b59@weissschuh.net> In-Reply-To: <20250515-nolibc-sys-v1-0-74f82eea3b59@weissschuh.net> To: Willy Tarreau , Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1747339091; l=3644; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=Pg5hG2NXJIJ2AsojvxyH+DEumI/6ZQZsHN1YJrvIni4=; b=TXd33KbCdsy+Zqu3NmNWddnRa1h3aM9OEjjUt42dUhnIxfEm+M4UhoPoO/m/Fs4rLG4aqsr3J GJT56Y8bS46AfNRjiQtZjGLW2IjERegD1KrQ+IHbZ+SH0LnR1vmw6zc X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= This is the location regular userspace expects this definition. Signed-off-by: Thomas Weißschuh --- tools/include/nolibc/Makefile | 1 + tools/include/nolibc/nolibc.h | 1 + tools/include/nolibc/sys.h | 18 ------------------ tools/include/nolibc/sys/reboot.h | 34 ++++++++++++++++++++++++++++++++++ tools/include/nolibc/types.h | 1 - 5 files changed, 36 insertions(+), 19 deletions(-) diff --git a/tools/include/nolibc/Makefile b/tools/include/nolibc/Makefile index 35cfbc84d499b0a57689bdfed95a45023904d256..4850501b8d53be6b603ecbb04d6f952cd5370cf0 100644 --- a/tools/include/nolibc/Makefile +++ b/tools/include/nolibc/Makefile @@ -54,6 +54,7 @@ all_files := \ sys/mount.h \ sys/prctl.h \ sys/random.h \ + sys/reboot.h \ sys/stat.h \ sys/syscall.h \ sys/time.h \ diff --git a/tools/include/nolibc/nolibc.h b/tools/include/nolibc/nolibc.h index 1c159e32a248d46fa4d36a2c35e92eb9da91e9f6..36ea7a02c7434cc006a7b12d413add04a2f85565 100644 --- a/tools/include/nolibc/nolibc.h +++ b/tools/include/nolibc/nolibc.h @@ -102,6 +102,7 @@ #include "sys/mount.h" #include "sys/prctl.h" #include "sys/random.h" +#include "sys/reboot.h" #include "sys/stat.h" #include "sys/syscall.h" #include "sys/time.h" diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h index a17fe98968a29081661eaf235111482a543f87ba..6c89dd0316dd0ebf03ebde6fa5c14273df6a0c62 100644 --- a/tools/include/nolibc/sys.h +++ b/tools/include/nolibc/sys.h @@ -730,24 +730,6 @@ ssize_t read(int fd, void *buf, size_t count) } -/* - * int reboot(int cmd); - * is among LINUX_REBOOT_CMD_* - */ - -static __attribute__((unused)) -ssize_t sys_reboot(int magic1, int magic2, int cmd, void *arg) -{ - return my_syscall4(__NR_reboot, magic1, magic2, cmd, arg); -} - -static __attribute__((unused)) -int reboot(int cmd) -{ - return __sysret(sys_reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, cmd, 0)); -} - - /* * int getrlimit(int resource, struct rlimit *rlim); * int setrlimit(int resource, const struct rlimit *rlim); diff --git a/tools/include/nolibc/sys/reboot.h b/tools/include/nolibc/sys/reboot.h new file mode 100644 index 0000000000000000000000000000000000000000..727363fbfd8a6f8994a0cf13829b7347ced198bb --- /dev/null +++ b/tools/include/nolibc/sys/reboot.h @@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: LGPL-2.1 OR MIT */ +/* + * Reboot definitions for NOLIBC + * Copyright (C) 2017-2021 Willy Tarreau + */ + +/* make sure to include all global symbols */ +#include "nolibc.h" + +#ifndef _NOLIBC_SYS_REBOOT_H +#define _NOLIBC_SYS_REBOOT_H + +#include "../sys.h" + +#include + +/* + * int reboot(int cmd); + * is among LINUX_REBOOT_CMD_* + */ + +static __attribute__((unused)) +ssize_t sys_reboot(int magic1, int magic2, int cmd, void *arg) +{ + return my_syscall4(__NR_reboot, magic1, magic2, cmd, arg); +} + +static __attribute__((unused)) +int reboot(int cmd) +{ + return __sysret(sys_reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, cmd, 0)); +} + +#endif /* _NOLIBC_SYS_REBOOT_H */ diff --git a/tools/include/nolibc/types.h b/tools/include/nolibc/types.h index 93da29fe7719c9f196fba38d1f3f31cad0fc02f1..74c7694b2d5e54f7a86854697ac32a2ea2b62e86 100644 --- a/tools/include/nolibc/types.h +++ b/tools/include/nolibc/types.h @@ -12,7 +12,6 @@ #include "std.h" #include -#include /* for LINUX_REBOOT_* */ #include #include #include From patchwork Thu May 15 19:57:52 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 890415 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 7E23429B79B; Thu, 15 May 2025 19:58: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=1747339108; cv=none; b=lYM4Vn2P3/fDJYxWEgLlrT9Dnuf83Vtb19YZy39EwwQ8CRW0vJoRxv/EuQUrMjJ/3uHN1uz3YrXs9cDcANM+mpW1O6zNhYEndTlPfk0ZaNspZSv41NasJwTfXyQPrPKl1duBO1vZ00N+EQz86lC/Df7CwSW2hFsmzHcP6LCiUP4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747339108; c=relaxed/simple; bh=CEjTUvBGsnd69Gkp4Kcg41wqhm8jvAm1b9FkzCvqtDU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=tPXAUKRA0imz2i8h301T4B3MVMXKqQxW349HXu2XuZ9GZxk3lYkCWsdd+Kv4gixd25zRfRoB2dgH0bM9a57vgASJVRsrVg4lcNh3sCte21WlzzR47HL6+meocbccJbInCb6Tiq0faXKrDKXAQ6lyfCvouYmrLPqW81/NZEICDXg= 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=uT7Yn/JH; 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="uT7Yn/JH" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1747339094; bh=CEjTUvBGsnd69Gkp4Kcg41wqhm8jvAm1b9FkzCvqtDU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=uT7Yn/JHVpJOQTD9dj7EN5XnGoXwXqhmNRvJUUQq0K5ZNNLJMzGT3NPoedHqaaC0D FL4Jjvu76p9qhG3uApaVsEXEBoYgzM+XxsbCZsEhwSIqTFI5e90xODgF3okFCDAg4f kEK85uwl85hdObNm/YgUv5YpWfeaqPAYqwqvq4Io= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Thu, 15 May 2025 21:57:52 +0200 Subject: [PATCH 6/9] tools/nolibc: move makedev() and friends to sys/sysmacros.h Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250515-nolibc-sys-v1-6-74f82eea3b59@weissschuh.net> References: <20250515-nolibc-sys-v1-0-74f82eea3b59@weissschuh.net> In-Reply-To: <20250515-nolibc-sys-v1-0-74f82eea3b59@weissschuh.net> To: Willy Tarreau , Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1747339091; l=2913; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=CEjTUvBGsnd69Gkp4Kcg41wqhm8jvAm1b9FkzCvqtDU=; b=tLPjHehGTm0gr5f1D8hEuXArffa0vPCMgKHd0jfciSsFm3GwJESOOCMXYbIisD9hNj9RcAjIy UOV712DOT5ICiq0JTFIiMfldNmSNhSp2wRNuCtn8oAGNqS6OgjUi1mK X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= This is the location regular userspace expects these definitions. Signed-off-by: Thomas Weißschuh --- tools/include/nolibc/Makefile | 1 + tools/include/nolibc/nolibc.h | 1 + tools/include/nolibc/sys/sysmacros.h | 20 ++++++++++++++++++++ tools/include/nolibc/types.h | 5 ----- 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/tools/include/nolibc/Makefile b/tools/include/nolibc/Makefile index cc82399e940e53940061b60588566db51f2e191a..ae04de46cdfeb2080d95b60c3d16e1c9f3692c9c 100644 --- a/tools/include/nolibc/Makefile +++ b/tools/include/nolibc/Makefile @@ -58,6 +58,7 @@ all_files := \ sys/resource.h \ sys/stat.h \ sys/syscall.h \ + sys/sysmacros.h \ sys/time.h \ sys/timerfd.h \ sys/types.h \ diff --git a/tools/include/nolibc/nolibc.h b/tools/include/nolibc/nolibc.h index 7d151776e47a30080dc3d961bcdeacd6ab558629..182dcfce126638db1cc9fd3fa79ab99835b42c26 100644 --- a/tools/include/nolibc/nolibc.h +++ b/tools/include/nolibc/nolibc.h @@ -106,6 +106,7 @@ #include "sys/resource.h" #include "sys/stat.h" #include "sys/syscall.h" +#include "sys/sysmacros.h" #include "sys/time.h" #include "sys/timerfd.h" #include "sys/wait.h" diff --git a/tools/include/nolibc/sys/sysmacros.h b/tools/include/nolibc/sys/sysmacros.h new file mode 100644 index 0000000000000000000000000000000000000000..e7e24dda1dbb51df92307def00f3670459b2409c --- /dev/null +++ b/tools/include/nolibc/sys/sysmacros.h @@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: LGPL-2.1 OR MIT */ +/* + * Sysmacro definitions for NOLIBC + * Copyright (C) 2017-2021 Willy Tarreau + */ + +/* make sure to include all global symbols */ +#include "nolibc.h" + +#ifndef _NOLIBC_SYS_SYSMACROS_H +#define _NOLIBC_SYS_SYSMACROS_H + +#include "../std.h" + +/* WARNING, it only deals with the 4096 first majors and 256 first minors */ +#define makedev(major, minor) ((dev_t)((((major) & 0xfff) << 8) | ((minor) & 0xff))) +#define major(dev) ((unsigned int)(((dev) >> 8) & 0xfff)) +#define minor(dev) ((unsigned int)((dev) & 0xff)) + +#endif /* _NOLIBC_SYS_SYSMACROS_H */ diff --git a/tools/include/nolibc/types.h b/tools/include/nolibc/types.h index 2225c9388a46480a18e9ce603b08d846e5276bab..0071bfbc23154cf9b47b0bd747101fea4955018d 100644 --- a/tools/include/nolibc/types.h +++ b/tools/include/nolibc/types.h @@ -188,11 +188,6 @@ struct stat { typedef __kernel_clockid_t clockid_t; typedef int timer_t; -/* WARNING, it only deals with the 4096 first majors and 256 first minors */ -#define makedev(major, minor) ((dev_t)((((major) & 0xfff) << 8) | ((minor) & 0xff))) -#define major(dev) ((unsigned int)(((dev) >> 8) & 0xfff)) -#define minor(dev) ((unsigned int)((dev) & 0xff)) - #ifndef offsetof #define offsetof(TYPE, FIELD) ((size_t) &((TYPE *)0)->FIELD) #endif From patchwork Thu May 15 19:57:54 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 890416 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 8EC4D29B76F; Thu, 15 May 2025 19:58:25 +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=1747339107; cv=none; b=hBlmj7RkUJoRbyYwZqsDyJDHLgtrjkzaOXECmv3fXv5q+9FzoOoxTRaNc736n/+N6e3rpYmbjBLX8WdWJ83Xf9zB3CDT2o6UiL4z2LcOSdLjh5ZG9Bx+0o2pKkK8v7bLlJ42UCAmmM90IKIUlc7gF2znW9l8a35DjkCnuEsKD/g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747339107; c=relaxed/simple; bh=0mUa7QIK52LFZ5X4Py+boeWdALPA3eeNNCjqgmKvvE0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=pXOtaYalHRxWmJtSgtVtYDmRIvUdBkJi5N/6E65OAq22fwxQdCKWk2BUhtClrEnLgjcDaVmW3cM+GRWw6T4JE1e+xApoIZ+vX0mh++nAW4qisWiyGxSLIXOt/tJF9Vj10tI8H91VpQrxHiU7zybYitPbUE9OI9kDpfPHIOf9XA0= 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=rH2X/+Az; 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="rH2X/+Az" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1747339094; bh=0mUa7QIK52LFZ5X4Py+boeWdALPA3eeNNCjqgmKvvE0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=rH2X/+Az5uUP7XoRLT8SXA54BpMrre2+Detrzbnc2uWAQ8u6+wnTOdrTWMlWY5zuD +gVKPoc5KoEB3oL8FiiRCUrUH1gYwkCgczfBR3/ECfRoBJvGWDQAmnaZRgAknXVUaV nSZNzPZUWM/e/kYCAmfnYVqzWDCGD0dg2RuGjvXA= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Thu, 15 May 2025 21:57:54 +0200 Subject: [PATCH 8/9] tools/nolibc: move NULL and offsetof() to sys/stddef.h Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250515-nolibc-sys-v1-8-74f82eea3b59@weissschuh.net> References: <20250515-nolibc-sys-v1-0-74f82eea3b59@weissschuh.net> In-Reply-To: <20250515-nolibc-sys-v1-0-74f82eea3b59@weissschuh.net> To: Willy Tarreau , Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1747339091; l=2694; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=0mUa7QIK52LFZ5X4Py+boeWdALPA3eeNNCjqgmKvvE0=; b=aUalZNrMbnWgHJrEn8oTpfJ68qOXis1S1o0rQvrjZrrFqVyYaJtwi8yRxUN/hXtejpJ4n1mQc y7o6s4xMsFtCzMIOXJ4W0J5GPlaIV5UGUNmW/kR8cPqWEcu2zWC3Qri X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= This is the location regular userspace expects these definitions. Signed-off-by: Thomas Weißschuh --- tools/include/nolibc/Makefile | 1 + tools/include/nolibc/std.h | 6 +----- tools/include/nolibc/stddef.h | 24 ++++++++++++++++++++++++ tools/include/nolibc/types.h | 4 ---- 4 files changed, 26 insertions(+), 9 deletions(-) diff --git a/tools/include/nolibc/Makefile b/tools/include/nolibc/Makefile index 0ff06374577df457b0611d91dcfe637a05476364..c4615bed731ced75a00867fdeb455d72652a7e42 100644 --- a/tools/include/nolibc/Makefile +++ b/tools/include/nolibc/Makefile @@ -44,6 +44,7 @@ all_files := \ std.h \ stdarg.h \ stdbool.h \ + stddef.h \ stdint.h \ stdlib.h \ string.h \ diff --git a/tools/include/nolibc/std.h b/tools/include/nolibc/std.h index 933bc0be7e1c6be3b7909efc127f1d3b9c611135..adda7333d12e7d2c336938ede1aaf215b4b93165 100644 --- a/tools/include/nolibc/std.h +++ b/tools/include/nolibc/std.h @@ -13,12 +13,8 @@ * syscall-specific stuff, as this file is expected to be included very early. */ -/* note: may already be defined */ -#ifndef NULL -#define NULL ((void *)0) -#endif - #include "stdint.h" +#include "stddef.h" /* those are commonly provided by sys/types.h */ typedef unsigned int dev_t; diff --git a/tools/include/nolibc/stddef.h b/tools/include/nolibc/stddef.h new file mode 100644 index 0000000000000000000000000000000000000000..ecbd13eab1f5190fd0e90a07699c2f06dbde8916 --- /dev/null +++ b/tools/include/nolibc/stddef.h @@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: LGPL-2.1 OR MIT */ +/* + * Stddef definitions for NOLIBC + * Copyright (C) 2017-2021 Willy Tarreau + */ + +/* make sure to include all global symbols */ +#include "nolibc.h" + +#ifndef _NOLIBC_STDDEF_H +#define _NOLIBC_STDDEF_H + +#include "stdint.h" + +/* note: may already be defined */ +#ifndef NULL +#define NULL ((void *)0) +#endif + +#ifndef offsetof +#define offsetof(TYPE, FIELD) ((size_t) &((TYPE *)0)->FIELD) +#endif + +#endif /* _NOLIBC_STDDEF_H */ diff --git a/tools/include/nolibc/types.h b/tools/include/nolibc/types.h index 0071bfbc23154cf9b47b0bd747101fea4955018d..30904be544ed01b212042ebc0f4dab610f64b216 100644 --- a/tools/include/nolibc/types.h +++ b/tools/include/nolibc/types.h @@ -188,10 +188,6 @@ struct stat { typedef __kernel_clockid_t clockid_t; typedef int timer_t; -#ifndef offsetof -#define offsetof(TYPE, FIELD) ((size_t) &((TYPE *)0)->FIELD) -#endif - #ifndef container_of #define container_of(PTR, TYPE, FIELD) ({ \ __typeof__(((TYPE *)0)->FIELD) *__FIELD_PTR = (PTR); \