1 /* SPDX-License-Identifier: GPL-2.0 */
2
3 #ifndef __STATMOUNT_H
4 #define __STATMOUNT_H
5
6 #include <stdint.h>
7 #include <linux/mount.h>
8 #include <asm/unistd.h>
9
10 #ifndef __NR_statmount
11 #if defined __alpha__
12 #define __NR_statmount 567
13 #elif defined _MIPS_SIM
14 #if _MIPS_SIM == _MIPS_SIM_ABI32 /* o32 */
15 #define __NR_statmount 4457
16 #endif
17 #if _MIPS_SIM == _MIPS_SIM_NABI32 /* n32 */
18 #define __NR_statmount 6457
19 #endif
20 #if _MIPS_SIM == _MIPS_SIM_ABI64 /* n64 */
21 #define __NR_statmount 5457
22 #endif
23 #else
24 #define __NR_statmount 457
25 #endif
26 #endif
27
28 #ifndef __NR_listmount
29 #if defined __alpha__
30 #define __NR_listmount 568
31 #elif defined _MIPS_SIM
32 #if _MIPS_SIM == _MIPS_SIM_ABI32 /* o32 */
33 #define __NR_listmount 4458
34 #endif
35 #if _MIPS_SIM == _MIPS_SIM_NABI32 /* n32 */
36 #define __NR_listmount 6458
37 #endif
38 #if _MIPS_SIM == _MIPS_SIM_ABI64 /* n64 */
39 #define __NR_listmount 5458
40 #endif
41 #else
42 #define __NR_listmount 458
43 #endif
44 #endif
45
statmount(uint64_t mnt_id,uint64_t mnt_ns_id,uint32_t fd,uint64_t mask,struct statmount * buf,size_t bufsize,unsigned int flags)46 static inline int statmount(uint64_t mnt_id, uint64_t mnt_ns_id, uint32_t fd,
47 uint64_t mask, struct statmount *buf, size_t bufsize,
48 unsigned int flags)
49 {
50 struct mnt_id_req req = {
51 .size = MNT_ID_REQ_SIZE_VER0,
52 .param = mask,
53 };
54
55 if (flags & STATMOUNT_BY_FD) {
56 req.size = MNT_ID_REQ_SIZE_VER1;
57 req.mnt_fd = fd;
58 } else {
59 req.mnt_id = mnt_id;
60 if (mnt_ns_id) {
61 req.size = MNT_ID_REQ_SIZE_VER1;
62 req.mnt_ns_id = mnt_ns_id;
63 }
64 }
65
66 return syscall(__NR_statmount, &req, buf, bufsize, flags);
67 }
68
listmount(uint64_t mnt_id,uint64_t mnt_ns_id,uint64_t last_mnt_id,uint64_t list[],size_t num,unsigned int flags)69 static inline ssize_t listmount(uint64_t mnt_id, uint64_t mnt_ns_id,
70 uint64_t last_mnt_id, uint64_t list[], size_t num,
71 unsigned int flags)
72 {
73 struct mnt_id_req req = {
74 .size = MNT_ID_REQ_SIZE_VER0,
75 .mnt_id = mnt_id,
76 .param = last_mnt_id,
77 };
78
79 if (mnt_ns_id) {
80 req.size = MNT_ID_REQ_SIZE_VER1;
81 req.mnt_ns_id = mnt_ns_id;
82 }
83
84 return syscall(__NR_listmount, &req, list, num, flags);
85 }
86
87 #endif /* __STATMOUNT_H */
88