]>
Commit | Line | Data |
---|---|---|
faeb1b64 KZ |
1 | /* |
2 | * No copyright is claimed. This code is in the public domain; do with | |
3 | * it what you wish. | |
4 | */ | |
013e0db4 CB |
5 | #ifndef UTIL_LINUX_MOUNT_API_UTILS |
6 | #define UTIL_LINUX_MOUNT_API_UTILS | |
7 | ||
5502e73d | 8 | #if defined(HAVE_MOUNTFD_API) && defined(HAVE_LINUX_MOUNT_H) |
9040c090 | 9 | |
013e0db4 | 10 | #include <sys/syscall.h> |
10efb9ea | 11 | #include <linux/mount.h> |
013e0db4 | 12 | |
013e0db4 CB |
13 | /* Accepted by both open_tree() and mount_setattr(). */ |
14 | #ifndef AT_RECURSIVE | |
1e5381cb | 15 | # define AT_RECURSIVE 0x8000 |
013e0db4 CB |
16 | #endif |
17 | ||
18 | #ifndef OPEN_TREE_CLONE | |
1e5381cb | 19 | # define OPEN_TREE_CLONE 1 |
013e0db4 CB |
20 | #endif |
21 | ||
22 | #ifndef OPEN_TREE_CLOEXEC | |
1e5381cb | 23 | # define OPEN_TREE_CLOEXEC O_CLOEXEC |
013e0db4 CB |
24 | #endif |
25 | ||
e087a188 | 26 | #if !defined(HAVE_OPEN_TREE) && defined(SYS_open_tree) |
013e0db4 CB |
27 | static inline int open_tree(int dfd, const char *filename, unsigned int flags) |
28 | { | |
e087a188 | 29 | return syscall(SYS_open_tree, dfd, filename, flags); |
013e0db4 | 30 | } |
1e5381cb | 31 | #endif |
013e0db4 CB |
32 | |
33 | #ifndef MOVE_MOUNT_F_SYMLINKS | |
1e5381cb | 34 | # define MOVE_MOUNT_F_SYMLINKS 0x00000001 /* Follow symlinks on from path */ |
013e0db4 CB |
35 | #endif |
36 | ||
37 | #ifndef MOVE_MOUNT_F_AUTOMOUNTS | |
1e5381cb | 38 | # define MOVE_MOUNT_F_AUTOMOUNTS 0x00000002 /* Follow automounts on from path */ |
013e0db4 CB |
39 | #endif |
40 | ||
41 | #ifndef MOVE_MOUNT_F_EMPTY_PATH | |
1e5381cb | 42 | # define MOVE_MOUNT_F_EMPTY_PATH 0x00000004 /* Empty from path permitted */ |
013e0db4 CB |
43 | #endif |
44 | ||
45 | #ifndef MOVE_MOUNT_T_SYMLINKS | |
1e5381cb | 46 | # define MOVE_MOUNT_T_SYMLINKS 0x00000010 /* Follow symlinks on to path */ |
013e0db4 CB |
47 | #endif |
48 | ||
49 | #ifndef MOVE_MOUNT_T_AUTOMOUNTS | |
1e5381cb | 50 | # define MOVE_MOUNT_T_AUTOMOUNTS 0x00000020 /* Follow automounts on to path */ |
013e0db4 CB |
51 | #endif |
52 | ||
53 | #ifndef MOVE_MOUNT_T_EMPTY_PATH | |
1e5381cb | 54 | # define MOVE_MOUNT_T_EMPTY_PATH 0x00000040 /* Empty to path permitted */ |
013e0db4 CB |
55 | #endif |
56 | ||
92ba5cb2 KZ |
57 | #ifndef MOVE_MOUNT_SET_GROUP |
58 | # define MOVE_MOUNT_SET_GROUP 0x00000100 /* Set sharing group instead */ | |
59 | #endif | |
60 | ||
013e0db4 | 61 | #ifndef MOVE_MOUNT__MASK |
1e5381cb | 62 | # define MOVE_MOUNT__MASK 0x00000077 |
013e0db4 CB |
63 | #endif |
64 | ||
e087a188 | 65 | #if !defined(HAVE_MOVE_MOUNT) && defined(SYS_move_mount) |
013e0db4 CB |
66 | static inline int move_mount(int from_dfd, const char *from_pathname, int to_dfd, |
67 | const char *to_pathname, unsigned int flags) | |
68 | { | |
e087a188 | 69 | return syscall(SYS_move_mount, from_dfd, from_pathname, to_dfd, |
013e0db4 CB |
70 | to_pathname, flags); |
71 | } | |
1e5381cb | 72 | #endif |
013e0db4 CB |
73 | |
74 | #ifndef MOUNT_ATTR_RDONLY | |
1e5381cb | 75 | # define MOUNT_ATTR_RDONLY 0x00000001 |
013e0db4 CB |
76 | #endif |
77 | ||
78 | #ifndef MOUNT_ATTR_NOSUID | |
1e5381cb | 79 | # define MOUNT_ATTR_NOSUID 0x00000002 |
013e0db4 CB |
80 | #endif |
81 | ||
0749b362 KZ |
82 | #ifndef MOUNT_ATTR_NODEV |
83 | # define MOUNT_ATTR_NODEV 0x00000004 | |
84 | #endif | |
85 | ||
013e0db4 | 86 | #ifndef MOUNT_ATTR_NOEXEC |
1e5381cb | 87 | # define MOUNT_ATTR_NOEXEC 0x00000008 |
013e0db4 CB |
88 | #endif |
89 | ||
013e0db4 | 90 | #ifndef MOUNT_ATTR__ATIME |
1e5381cb | 91 | # define MOUNT_ATTR__ATIME 0x00000070 |
013e0db4 CB |
92 | #endif |
93 | ||
94 | #ifndef MOUNT_ATTR_RELATIME | |
1e5381cb | 95 | # define MOUNT_ATTR_RELATIME 0x00000000 |
013e0db4 CB |
96 | #endif |
97 | ||
98 | #ifndef MOUNT_ATTR_NOATIME | |
1e5381cb | 99 | # define MOUNT_ATTR_NOATIME 0x00000010 |
013e0db4 CB |
100 | #endif |
101 | ||
102 | #ifndef MOUNT_ATTR_STRICTATIME | |
1e5381cb | 103 | # define MOUNT_ATTR_STRICTATIME 0x00000020 |
013e0db4 CB |
104 | #endif |
105 | ||
9cb77c87 KZ |
106 | #ifndef MOUNT_ATTR_NODIRATIME |
107 | # define MOUNT_ATTR_NODIRATIME 0x00000080 | |
108 | #endif | |
109 | ||
013e0db4 | 110 | #ifndef MOUNT_ATTR_IDMAP |
1e5381cb | 111 | # define MOUNT_ATTR_IDMAP 0x00100000 |
013e0db4 CB |
112 | #endif |
113 | ||
9cb77c87 KZ |
114 | #ifndef MOUNT_ATTR_NOSYMFOLLOW |
115 | # define MOUNT_ATTR_NOSYMFOLLOW 0x00200000 | |
116 | #endif | |
117 | ||
1e5381cb | 118 | #ifndef HAVE_STRUCT_MOUNT_ATTR |
26788963 | 119 | # ifndef MOUNT_ATTR_SIZE_VER0 /* For case mount.h comes from a place invisible for autotools/meson */ |
43d3c908 | 120 | # include <inttypes.h> |
013e0db4 | 121 | struct mount_attr { |
43d3c908 KZ |
122 | uint64_t attr_set; |
123 | uint64_t attr_clr; | |
124 | uint64_t propagation; | |
125 | uint64_t userns_fd; | |
013e0db4 | 126 | }; |
26788963 | 127 | # endif |
1e5381cb | 128 | #endif |
013e0db4 | 129 | |
e087a188 | 130 | #if !defined(HAVE_MOUNT_SETATTR) && defined(SYS_mount_setattr) |
013e0db4 CB |
131 | static inline int mount_setattr(int dfd, const char *path, unsigned int flags, |
132 | struct mount_attr *attr, size_t size) | |
133 | { | |
e087a188 | 134 | return syscall(SYS_mount_setattr, dfd, path, flags, attr, size); |
013e0db4 | 135 | } |
1e5381cb | 136 | #endif |
013e0db4 | 137 | |
0120be6f | 138 | #ifndef HAVE_ENUM_FSCONFIG_COMMAND |
26788963 | 139 | # ifndef FSOPEN_CLOEXEC /* For case mount.h comes from a place invisible for autotools/meson */ |
0120be6f KZ |
140 | enum fsconfig_command { |
141 | FSCONFIG_SET_FLAG = 0, /* Set parameter, supplying no value */ | |
142 | FSCONFIG_SET_STRING = 1, /* Set parameter, supplying a string value */ | |
143 | FSCONFIG_SET_BINARY = 2, /* Set parameter, supplying a binary blob value */ | |
144 | FSCONFIG_SET_PATH = 3, /* Set parameter, supplying an object by path */ | |
145 | FSCONFIG_SET_PATH_EMPTY = 4, /* Set parameter, supplying an object by (empty) path */ | |
146 | FSCONFIG_SET_FD = 5, /* Set parameter, supplying an object by fd */ | |
147 | FSCONFIG_CMD_CREATE = 6, /* Invoke superblock creation */ | |
148 | FSCONFIG_CMD_RECONFIGURE = 7, /* Invoke superblock reconfiguration */ | |
149 | }; | |
26788963 | 150 | # endif |
0120be6f KZ |
151 | #endif |
152 | ||
153 | #if !defined(HAVE_FSCONFIG) && defined(SYS_fsconfig) | |
154 | static inline int fsconfig(int fd, unsigned int cmd, const char *key, | |
155 | const void *value, int aux) | |
156 | { | |
157 | return syscall(SYS_fsconfig, fd, cmd, key, value, aux); | |
158 | } | |
159 | #endif | |
160 | ||
161 | #ifndef FSOPEN_CLOEXEC | |
162 | # define FSOPEN_CLOEXEC 0x00000001 | |
163 | #endif | |
164 | ||
165 | #if !defined(HAVE_FSOPEN) && defined(SYS_fsopen) | |
166 | static inline int fsopen(const char *fsname, unsigned int flags) | |
167 | { | |
168 | return syscall(SYS_fsopen, fsname, flags); | |
169 | } | |
170 | #endif | |
171 | ||
172 | #ifndef FSMOUNT_CLOEXEC | |
173 | # define FSMOUNT_CLOEXEC 0x00000001 | |
174 | #endif | |
175 | ||
176 | #if !defined(HAVE_FSMOUNT) && defined(SYS_fsmount) | |
177 | static inline int fsmount(int fd, unsigned int flags, unsigned int mount_attrs) | |
178 | { | |
179 | return syscall(SYS_fsmount, fd, flags, mount_attrs); | |
180 | } | |
181 | #endif | |
182 | ||
183 | #ifndef FSPICK_CLOEXEC | |
184 | # define FSPICK_CLOEXEC 0x00000001 | |
185 | #endif | |
186 | ||
187 | #ifndef FSPICK_SYMLINK_NOFOLLOW | |
188 | # define FSPICK_SYMLINK_NOFOLLOW 0x00000002 | |
189 | #endif | |
190 | ||
191 | #ifndef FSPICK_NO_AUTOMOUNT | |
192 | # define FSPICK_NO_AUTOMOUNT 0x00000004 | |
193 | #endif | |
194 | ||
195 | #ifdef FSPICK_EMPTY_PATH | |
196 | # define FSPICK_EMPTY_PATH 0x00000008 | |
197 | #endif | |
198 | ||
199 | #if !defined(HAVE_FSPICK) && defined(SYS_fspick) | |
200 | static inline int fspick(int dfd, const char *pathname, unsigned int flags) | |
201 | { | |
202 | return syscall(SYS_fspick, dfd, pathname, flags); | |
203 | } | |
204 | #endif | |
205 | ||
5502e73d | 206 | #endif /* HAVE_MOUNTFD_API && HAVE_LINUX_MOUNT_H */ |
013e0db4 CB |
207 | #endif /* UTIL_LINUX_MOUNT_API_UTILS */ |
208 |