rustix/backend/linux_raw/mount/
types.rs

1use crate::backend::c;
2use bitflags::bitflags;
3
4bitflags! {
5    /// `MS_*` constants for use with [`mount`].
6    ///
7    /// [`mount`]: crate::mount::mount
8    #[repr(transparent)]
9    #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
10    pub struct MountFlags: c::c_uint {
11        /// `MS_BIND`
12        const BIND = linux_raw_sys::general::MS_BIND;
13
14        /// `MS_DIRSYNC`
15        const DIRSYNC = linux_raw_sys::general::MS_DIRSYNC;
16
17        /// `MS_LAZYTIME`
18        const LAZYTIME = linux_raw_sys::general::MS_LAZYTIME;
19
20        /// `MS_MANDLOCK`
21        #[doc(alias = "MANDLOCK")]
22        const PERMIT_MANDATORY_FILE_LOCKING = linux_raw_sys::general::MS_MANDLOCK;
23
24        /// `MS_NOATIME`
25        const NOATIME = linux_raw_sys::general::MS_NOATIME;
26
27        /// `MS_NODEV`
28        const NODEV = linux_raw_sys::general::MS_NODEV;
29
30        /// `MS_NODIRATIME`
31        const NODIRATIME = linux_raw_sys::general::MS_NODIRATIME;
32
33        /// `MS_NOEXEC`
34        const NOEXEC = linux_raw_sys::general::MS_NOEXEC;
35
36        /// `MS_NOSUID`
37        const NOSUID = linux_raw_sys::general::MS_NOSUID;
38
39        /// `MS_RDONLY`
40        const RDONLY = linux_raw_sys::general::MS_RDONLY;
41
42        /// `MS_REC`
43        const REC = linux_raw_sys::general::MS_REC;
44
45        /// `MS_RELATIME`
46        const RELATIME = linux_raw_sys::general::MS_RELATIME;
47
48        /// `MS_SILENT`
49        const SILENT = linux_raw_sys::general::MS_SILENT;
50
51        /// `MS_STRICTATIME`
52        const STRICTATIME = linux_raw_sys::general::MS_STRICTATIME;
53
54        /// `MS_SYNCHRONOUS`
55        const SYNCHRONOUS = linux_raw_sys::general::MS_SYNCHRONOUS;
56
57        /// `MS_NOSYMFOLLOW`
58        const NOSYMFOLLOW = linux_raw_sys::general::MS_NOSYMFOLLOW;
59
60        /// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags>
61        const _ = !0;
62    }
63}
64
65bitflags! {
66    /// `MNT_*` constants for use with [`unmount`].
67    ///
68    /// [`unmount`]: crate::mount::unmount
69    #[repr(transparent)]
70    #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
71    pub struct UnmountFlags: c::c_uint {
72        /// `MNT_FORCE`
73        const FORCE = linux_raw_sys::general::MNT_FORCE;
74        /// `MNT_DETACH`
75        const DETACH = linux_raw_sys::general::MNT_DETACH;
76        /// `MNT_EXPIRE`
77        const EXPIRE = linux_raw_sys::general::MNT_EXPIRE;
78        /// `UMOUNT_NOFOLLOW`
79        const NOFOLLOW = linux_raw_sys::general::UMOUNT_NOFOLLOW;
80
81        /// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags>
82        const _ = !0;
83    }
84}
85
86#[cfg(feature = "mount")]
87bitflags! {
88    /// `FSOPEN_*` constants for use with [`fsopen`].
89    ///
90    /// [`fsopen`]: crate::mount::fsopen
91    #[repr(transparent)]
92    #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
93    pub struct FsOpenFlags: c::c_uint {
94        /// `FSOPEN_CLOEXEC`
95        const FSOPEN_CLOEXEC = linux_raw_sys::general::FSOPEN_CLOEXEC;
96
97        /// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags>
98        const _ = !0;
99    }
100}
101
102#[cfg(feature = "mount")]
103bitflags! {
104    /// `FSMOUNT_*` constants for use with [`fsmount`].
105    ///
106    /// [`fsmount`]: crate::mount::fsmount
107    #[repr(transparent)]
108    #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
109    pub struct FsMountFlags: c::c_uint {
110        /// `FSMOUNT_CLOEXEC`
111        const FSMOUNT_CLOEXEC = linux_raw_sys::general::FSMOUNT_CLOEXEC;
112
113        /// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags>
114        const _ = !0;
115    }
116}
117
118/// `FSCONFIG_*` constants for use with the `fsconfig` syscall.
119#[cfg(feature = "mount")]
120#[derive(Debug, Copy, Clone, Eq, PartialEq)]
121#[repr(u32)]
122pub(crate) enum FsConfigCmd {
123    /// `FSCONFIG_SET_FLAG`
124    SetFlag = linux_raw_sys::general::fsconfig_command::FSCONFIG_SET_FLAG as u32,
125
126    /// `FSCONFIG_SET_STRING`
127    SetString = linux_raw_sys::general::fsconfig_command::FSCONFIG_SET_STRING as u32,
128
129    /// `FSCONFIG_SET_BINARY`
130    SetBinary = linux_raw_sys::general::fsconfig_command::FSCONFIG_SET_BINARY as u32,
131
132    /// `FSCONFIG_SET_PATH`
133    SetPath = linux_raw_sys::general::fsconfig_command::FSCONFIG_SET_PATH as u32,
134
135    /// `FSCONFIG_SET_PATH_EMPTY`
136    SetPathEmpty = linux_raw_sys::general::fsconfig_command::FSCONFIG_SET_PATH_EMPTY as u32,
137
138    /// `FSCONFIG_SET_FD`
139    SetFd = linux_raw_sys::general::fsconfig_command::FSCONFIG_SET_FD as u32,
140
141    /// `FSCONFIG_CMD_CREATE`
142    Create = linux_raw_sys::general::fsconfig_command::FSCONFIG_CMD_CREATE as u32,
143
144    /// `FSCONFIG_CMD_RECONFIGURE`
145    Reconfigure = linux_raw_sys::general::fsconfig_command::FSCONFIG_CMD_RECONFIGURE as u32,
146}
147
148#[cfg(feature = "mount")]
149bitflags! {
150    /// `MOUNT_ATTR_*` constants for use with [`fsmount`].
151    ///
152    /// [`fsmount`]: crate::mount::fsmount
153    #[repr(transparent)]
154    #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
155    pub struct MountAttrFlags: c::c_uint {
156        /// `MOUNT_ATTR_RDONLY`
157        const MOUNT_ATTR_RDONLY = linux_raw_sys::general::MOUNT_ATTR_RDONLY;
158
159        /// `MOUNT_ATTR_NOSUID`
160        const MOUNT_ATTR_NOSUID = linux_raw_sys::general::MOUNT_ATTR_NOSUID;
161
162        /// `MOUNT_ATTR_NODEV`
163        const MOUNT_ATTR_NODEV = linux_raw_sys::general::MOUNT_ATTR_NODEV;
164
165        /// `MOUNT_ATTR_NOEXEC`
166        const MOUNT_ATTR_NOEXEC = linux_raw_sys::general::MOUNT_ATTR_NOEXEC;
167
168        /// `MOUNT_ATTR__ATIME`
169        const MOUNT_ATTR__ATIME = linux_raw_sys::general::MOUNT_ATTR__ATIME;
170
171        /// `MOUNT_ATTR_RELATIME`
172        const MOUNT_ATTR_RELATIME = linux_raw_sys::general::MOUNT_ATTR_RELATIME;
173
174        /// `MOUNT_ATTR_NOATIME`
175        const MOUNT_ATTR_NOATIME = linux_raw_sys::general::MOUNT_ATTR_NOATIME;
176
177        /// `MOUNT_ATTR_STRICTATIME`
178        const MOUNT_ATTR_STRICTATIME = linux_raw_sys::general::MOUNT_ATTR_STRICTATIME;
179
180        /// `MOUNT_ATTR_NODIRATIME`
181        const MOUNT_ATTR_NODIRATIME = linux_raw_sys::general::MOUNT_ATTR_NODIRATIME;
182
183        /// `MOUNT_ATTR_NOUSER`
184        const MOUNT_ATTR_IDMAP = linux_raw_sys::general::MOUNT_ATTR_IDMAP;
185
186        /// `MOUNT_ATTR__ATIME_FLAGS`
187        const MOUNT_ATTR_NOSYMFOLLOW = linux_raw_sys::general::MOUNT_ATTR_NOSYMFOLLOW;
188
189        /// `MOUNT_ATTR__ATIME_FLAGS`
190        const MOUNT_ATTR_SIZE_VER0 = linux_raw_sys::general::MOUNT_ATTR_SIZE_VER0;
191
192        /// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags>
193        const _ = !0;
194    }
195}
196
197#[cfg(feature = "mount")]
198bitflags! {
199    /// `MOVE_MOUNT_*` constants for use with [`move_mount`].
200    ///
201    /// [`move_mount`]: crate::mount::move_mount
202    #[repr(transparent)]
203    #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
204    pub struct MoveMountFlags: c::c_uint {
205        /// `MOVE_MOUNT_F_EMPTY_PATH`
206        const MOVE_MOUNT_F_SYMLINKS = linux_raw_sys::general::MOVE_MOUNT_F_SYMLINKS;
207
208        /// `MOVE_MOUNT_F_AUTOMOUNTS`
209        const MOVE_MOUNT_F_AUTOMOUNTS = linux_raw_sys::general::MOVE_MOUNT_F_AUTOMOUNTS;
210
211        /// `MOVE_MOUNT_F_EMPTY_PATH`
212        const MOVE_MOUNT_F_EMPTY_PATH = linux_raw_sys::general::MOVE_MOUNT_F_EMPTY_PATH;
213
214        /// `MOVE_MOUNT_T_SYMLINKS`
215        const MOVE_MOUNT_T_SYMLINKS = linux_raw_sys::general::MOVE_MOUNT_T_SYMLINKS;
216
217        /// `MOVE_MOUNT_T_AUTOMOUNTS`
218        const MOVE_MOUNT_T_AUTOMOUNTS = linux_raw_sys::general::MOVE_MOUNT_T_AUTOMOUNTS;
219
220        /// `MOVE_MOUNT_T_EMPTY_PATH`
221        const MOVE_MOUNT_T_EMPTY_PATH = linux_raw_sys::general::MOVE_MOUNT_T_EMPTY_PATH;
222
223        /// `MOVE_MOUNT__MASK`
224        const MOVE_MOUNT_SET_GROUP = linux_raw_sys::general::MOVE_MOUNT_SET_GROUP;
225
226        /// `MOVE_MOUNT_BENEATH` (since Linux 6.5)
227        const MOVE_MOUNT_BENEATH = c::MOVE_MOUNT_BENEATH;
228
229        /// `MOVE_MOUNT__MASK`
230        const MOVE_MOUNT__MASK = linux_raw_sys::general::MOVE_MOUNT__MASK;
231
232        /// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags>
233        const _ = !0;
234    }
235}
236
237#[cfg(feature = "mount")]
238bitflags! {
239    /// `OPENTREE_*` constants for use with [`open_tree`].
240    ///
241    /// [`open_tree`]: crate::mount::open_tree
242    #[repr(transparent)]
243    #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
244    pub struct OpenTreeFlags: c::c_uint {
245        /// `OPENTREE_CLONE`
246        const OPEN_TREE_CLONE = linux_raw_sys::general::OPEN_TREE_CLONE;
247
248        /// `OPENTREE_CLOEXEC`
249        const OPEN_TREE_CLOEXEC = linux_raw_sys::general::OPEN_TREE_CLOEXEC;
250
251        /// `AT_EMPTY_PATH`
252        const AT_EMPTY_PATH = linux_raw_sys::general::AT_EMPTY_PATH;
253
254        /// `AT_NO_AUTOMOUNT`
255        const AT_NO_AUTOMOUNT = linux_raw_sys::general::AT_NO_AUTOMOUNT;
256
257        /// `AT_RECURSIVE`
258        const AT_RECURSIVE = linux_raw_sys::general::AT_RECURSIVE;
259
260        /// `AT_SYMLINK_NOFOLLOW`
261        const AT_SYMLINK_NOFOLLOW = linux_raw_sys::general::AT_SYMLINK_NOFOLLOW;
262
263        /// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags>
264        const _ = !0;
265    }
266}
267
268#[cfg(feature = "mount")]
269bitflags! {
270    /// `FSPICK_*` constants for use with [`fspick`].
271    ///
272    /// [`fspick`]: crate::mount::fspick
273    #[repr(transparent)]
274    #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
275    pub struct FsPickFlags: c::c_uint {
276        /// `FSPICK_CLOEXEC`
277        const FSPICK_CLOEXEC = linux_raw_sys::general::FSPICK_CLOEXEC;
278
279        /// `FSPICK_SYMLINK_NOFOLLOW`
280        const FSPICK_SYMLINK_NOFOLLOW = linux_raw_sys::general::FSPICK_SYMLINK_NOFOLLOW;
281
282        /// `FSPICK_NO_AUTOMOUNT`
283        const FSPICK_NO_AUTOMOUNT = linux_raw_sys::general::FSPICK_NO_AUTOMOUNT;
284
285        /// `FSPICK_EMPTY_PATH`
286        const FSPICK_EMPTY_PATH = linux_raw_sys::general::FSPICK_EMPTY_PATH;
287
288        /// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags>
289        const _ = !0;
290    }
291}
292
293bitflags! {
294    /// `MS_*` constants for use with [`mount_change`].
295    ///
296    /// [`mount_change`]: crate::mount::mount_change
297    #[repr(transparent)]
298    #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
299    pub struct MountPropagationFlags: c::c_uint {
300        /// `MS_SILENT`
301        const SILENT = linux_raw_sys::general::MS_SILENT;
302        /// `MS_SHARED`
303        const SHARED = linux_raw_sys::general::MS_SHARED;
304        /// `MS_PRIVATE`
305        const PRIVATE = linux_raw_sys::general::MS_PRIVATE;
306        /// `MS_SLAVE`
307        const SLAVE = linux_raw_sys::general::MS_SLAVE;
308        /// `MS_UNBINDABLE`
309        const UNBINDABLE = linux_raw_sys::general::MS_UNBINDABLE;
310        /// `MS_REC`
311        const REC = linux_raw_sys::general::MS_REC;
312
313        /// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags>
314        const _ = !0;
315    }
316}
317
318bitflags! {
319    #[repr(transparent)]
320    #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
321    pub(crate) struct InternalMountFlags: c::c_uint {
322        const REMOUNT = linux_raw_sys::general::MS_REMOUNT;
323        const MOVE = linux_raw_sys::general::MS_MOVE;
324
325        /// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags>
326        const _ = !0;
327    }
328}
329
330#[repr(transparent)]
331pub(crate) struct MountFlagsArg(pub(crate) c::c_uint);