xref: /linux/tools/testing/selftests/filesystems/statmount/statmount.h (revision a1ff5a7d78a036d6c2178ee5acd6ba4946243800)
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 
statmount(uint64_t mnt_id,uint64_t mnt_ns_id,uint64_t mask,struct statmount * buf,size_t bufsize,unsigned int flags)10 static inline int statmount(uint64_t mnt_id, uint64_t mnt_ns_id, uint64_t mask,
11 			    struct statmount *buf, size_t bufsize,
12 			    unsigned int flags)
13 {
14 	struct mnt_id_req req = {
15 		.size = MNT_ID_REQ_SIZE_VER0,
16 		.mnt_id = mnt_id,
17 		.param = mask,
18 	};
19 
20 	if (mnt_ns_id) {
21 		req.size = MNT_ID_REQ_SIZE_VER1;
22 		req.mnt_ns_id = mnt_ns_id;
23 	}
24 
25 	return syscall(__NR_statmount, &req, buf, bufsize, flags);
26 }
27 
listmount(uint64_t mnt_id,uint64_t mnt_ns_id,uint64_t last_mnt_id,uint64_t list[],size_t num,unsigned int flags)28 static ssize_t listmount(uint64_t mnt_id, uint64_t mnt_ns_id,
29 			 uint64_t last_mnt_id, uint64_t list[], size_t num,
30 			 unsigned int flags)
31 {
32 	struct mnt_id_req req = {
33 		.size = MNT_ID_REQ_SIZE_VER0,
34 		.mnt_id = mnt_id,
35 		.param = last_mnt_id,
36 	};
37 
38 	if (mnt_ns_id) {
39 		req.size = MNT_ID_REQ_SIZE_VER1;
40 		req.mnt_ns_id = mnt_ns_id;
41 	}
42 
43 	return syscall(__NR_listmount, &req, list, num, flags);
44 }
45 
46 #endif /* __STATMOUNT_H */
47