1 // SPDX-License-Identifier: GPL-2.0 2 // 3 #ifndef __SELFTEST_OVERLAYFS_WRAPPERS_H__ 4 #define __SELFTEST_OVERLAYFS_WRAPPERS_H__ 5 6 #define _GNU_SOURCE 7 8 #include <linux/types.h> 9 #include <linux/mount.h> 10 #include <sys/syscall.h> 11 12 #ifndef STATX_MNT_ID_UNIQUE 13 #define STATX_MNT_ID_UNIQUE 0x00004000U /* Want/got extended stx_mount_id */ 14 #endif 15 16 static inline int sys_fsopen(const char *fsname, unsigned int flags) 17 { 18 return syscall(__NR_fsopen, fsname, flags); 19 } 20 21 static inline int sys_fsconfig(int fd, unsigned int cmd, const char *key, 22 const char *value, int aux) 23 { 24 return syscall(__NR_fsconfig, fd, cmd, key, value, aux); 25 } 26 27 static inline int sys_fsmount(int fd, unsigned int flags, 28 unsigned int attr_flags) 29 { 30 return syscall(__NR_fsmount, fd, flags, attr_flags); 31 } 32 33 static inline int sys_mount(const char *src, const char *tgt, const char *fst, 34 unsigned long flags, const void *data) 35 { 36 return syscall(__NR_mount, src, tgt, fst, flags, data); 37 } 38 39 #ifndef MOVE_MOUNT_F_EMPTY_PATH 40 #define MOVE_MOUNT_F_EMPTY_PATH 0x00000004 /* Empty from path permitted */ 41 #endif 42 43 #ifndef MOVE_MOUNT_T_EMPTY_PATH 44 #define MOVE_MOUNT_T_EMPTY_PATH 0x00000040 /* Empty to path permitted */ 45 #endif 46 47 #ifndef __NR_move_mount 48 #if defined __alpha__ 49 #define __NR_move_mount 539 50 #elif defined _MIPS_SIM 51 #if _MIPS_SIM == _MIPS_SIM_ABI32 /* o32 */ 52 #define __NR_move_mount 4429 53 #endif 54 #if _MIPS_SIM == _MIPS_SIM_NABI32 /* n32 */ 55 #define __NR_move_mount 6429 56 #endif 57 #if _MIPS_SIM == _MIPS_SIM_ABI64 /* n64 */ 58 #define __NR_move_mount 5429 59 #endif 60 #else 61 #define __NR_move_mount 429 62 #endif 63 #endif 64 65 static inline int sys_move_mount(int from_dfd, const char *from_pathname, 66 int to_dfd, const char *to_pathname, 67 unsigned int flags) 68 { 69 return syscall(__NR_move_mount, from_dfd, from_pathname, to_dfd, 70 to_pathname, flags); 71 } 72 73 #ifndef OPEN_TREE_CLONE 74 #define OPEN_TREE_CLONE 1 75 #endif 76 77 #ifndef OPEN_TREE_CLOEXEC 78 #define OPEN_TREE_CLOEXEC O_CLOEXEC 79 #endif 80 81 #ifndef AT_RECURSIVE 82 #define AT_RECURSIVE 0x8000 /* Apply to the entire subtree */ 83 #endif 84 85 #ifndef __NR_open_tree 86 #if defined __alpha__ 87 #define __NR_open_tree 538 88 #elif defined _MIPS_SIM 89 #if _MIPS_SIM == _MIPS_SIM_ABI32 /* o32 */ 90 #define __NR_open_tree 4428 91 #endif 92 #if _MIPS_SIM == _MIPS_SIM_NABI32 /* n32 */ 93 #define __NR_open_tree 6428 94 #endif 95 #if _MIPS_SIM == _MIPS_SIM_ABI64 /* n64 */ 96 #define __NR_open_tree 5428 97 #endif 98 #else 99 #define __NR_open_tree 428 100 #endif 101 #endif 102 103 static inline int sys_open_tree(int dfd, const char *filename, unsigned int flags) 104 { 105 return syscall(__NR_open_tree, dfd, filename, flags); 106 } 107 108 #endif 109