Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests/namespaces: add listns() wrapper

Add a wrapper for the listns() system call.

Link: https://patch.msgid.link/20251029-work-namespace-nstree-listns-v4-38-2e6f823ebdc0@kernel.org
Tested-by: syzbot@syzkaller.appspotmail.com
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Christian Brauner <brauner@kernel.org>

+35
+35
tools/testing/selftests/namespaces/wrappers.h
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + 3 + #include <linux/nsfs.h> 4 + #include <linux/types.h> 5 + #include <sys/syscall.h> 6 + #include <unistd.h> 7 + 8 + #ifndef __SELFTESTS_NAMESPACES_WRAPPERS_H__ 9 + #define __SELFTESTS_NAMESPACES_WRAPPERS_H__ 10 + 11 + #ifndef __NR_listns 12 + #if defined __alpha__ 13 + #define __NR_listns 580 14 + #elif defined _MIPS_SIM 15 + #if _MIPS_SIM == _MIPS_SIM_ABI32 /* o32 */ 16 + #define __NR_listns 4470 17 + #endif 18 + #if _MIPS_SIM == _MIPS_SIM_NABI32 /* n32 */ 19 + #define __NR_listns 6470 20 + #endif 21 + #if _MIPS_SIM == _MIPS_SIM_ABI64 /* n64 */ 22 + #define __NR_listns 5470 23 + #endif 24 + #else 25 + #define __NR_listns 470 26 + #endif 27 + #endif 28 + 29 + static inline int sys_listns(const struct ns_id_req *req, __u64 *ns_ids, 30 + size_t nr_ns_ids, unsigned int flags) 31 + { 32 + return syscall(__NR_listns, req, ns_ids, nr_ns_ids, flags); 33 + } 34 + 35 + #endif /* __SELFTESTS_NAMESPACES_WRAPPERS_H__ */