xref: /linux/tools/testing/selftests/namespaces/wrappers.h (revision 7fc2cd2e4b398c57c9cf961cfea05eadbf34c05c)
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__ */
36