1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
use crate::backend::c;
use bitflags::bitflags;

bitflags! {
    /// `MS_*` constants for use with [`mount`].
    ///
    /// [`mount`]: crate::mount::mount
    #[repr(transparent)]
    #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
    pub struct MountFlags: c::c_uint {
        /// `MS_BIND`
        const BIND = linux_raw_sys::general::MS_BIND;

        /// `MS_DIRSYNC`
        const DIRSYNC = linux_raw_sys::general::MS_DIRSYNC;

        /// `MS_LAZYTIME`
        const LAZYTIME = linux_raw_sys::general::MS_LAZYTIME;

        /// `MS_MANDLOCK`
        #[doc(alias = "MANDLOCK")]
        const PERMIT_MANDATORY_FILE_LOCKING = linux_raw_sys::general::MS_MANDLOCK;

        /// `MS_NOATIME`
        const NOATIME = linux_raw_sys::general::MS_NOATIME;

        /// `MS_NODEV`
        const NODEV = linux_raw_sys::general::MS_NODEV;

        /// `MS_NODIRATIME`
        const NODIRATIME = linux_raw_sys::general::MS_NODIRATIME;

        /// `MS_NOEXEC`
        const NOEXEC = linux_raw_sys::general::MS_NOEXEC;

        /// `MS_NOSUID`
        const NOSUID = linux_raw_sys::general::MS_NOSUID;

        /// `MS_RDONLY`
        const RDONLY = linux_raw_sys::general::MS_RDONLY;

        /// `MS_REC`
        const REC = linux_raw_sys::general::MS_REC;

        /// `MS_RELATIME`
        const RELATIME = linux_raw_sys::general::MS_RELATIME;

        /// `MS_SILENT`
        const SILENT = linux_raw_sys::general::MS_SILENT;

        /// `MS_STRICTATIME`
        const STRICTATIME = linux_raw_sys::general::MS_STRICTATIME;

        /// `MS_SYNCHRONOUS`
        const SYNCHRONOUS = linux_raw_sys::general::MS_SYNCHRONOUS;

        /// `MS_NOSYMFOLLOW`
        const NOSYMFOLLOW = linux_raw_sys::general::MS_NOSYMFOLLOW;

        /// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags>
        const _ = !0;
    }
}

bitflags! {
    /// `MNT_*` constants for use with [`unmount`].
    ///
    /// [`unmount`]: crate::mount::unmount
    #[repr(transparent)]
    #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
    pub struct UnmountFlags: c::c_uint {
        /// `MNT_FORCE`
        const FORCE = linux_raw_sys::general::MNT_FORCE;
        /// `MNT_DETACH`
        const DETACH = linux_raw_sys::general::MNT_DETACH;
        /// `MNT_EXPIRE`
        const EXPIRE = linux_raw_sys::general::MNT_EXPIRE;
        /// `UMOUNT_NOFOLLOW`
        const NOFOLLOW = linux_raw_sys::general::UMOUNT_NOFOLLOW;

        /// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags>
        const _ = !0;
    }
}

#[cfg(feature = "mount")]
bitflags! {
    /// `FSOPEN_*` constants for use with [`fsopen`].
    ///
    /// [`fsopen`]: crate::mount::fsopen
    #[repr(transparent)]
    #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
    pub struct FsOpenFlags: c::c_uint {
        /// `FSOPEN_CLOEXEC`
        const FSOPEN_CLOEXEC = linux_raw_sys::general::FSOPEN_CLOEXEC;

        /// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags>
        const _ = !0;
    }
}

#[cfg(feature = "mount")]
bitflags! {
    /// `FSMOUNT_*` constants for use with [`fsmount`].
    ///
    /// [`fsmount`]: crate::mount::fsmount
    #[repr(transparent)]
    #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
    pub struct FsMountFlags: c::c_uint {
        /// `FSMOUNT_CLOEXEC`
        const FSMOUNT_CLOEXEC = linux_raw_sys::general::FSMOUNT_CLOEXEC;

        /// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags>
        const _ = !0;
    }
}

/// `FSCONFIG_*` constants for use with the `fsconfig` syscall.
#[cfg(feature = "mount")]
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
#[repr(u32)]
pub(crate) enum FsConfigCmd {
    /// `FSCONFIG_SET_FLAG`
    SetFlag = linux_raw_sys::general::fsconfig_command::FSCONFIG_SET_FLAG as u32,

    /// `FSCONFIG_SET_STRING`
    SetString = linux_raw_sys::general::fsconfig_command::FSCONFIG_SET_STRING as u32,

    /// `FSCONFIG_SET_BINARY`
    SetBinary = linux_raw_sys::general::fsconfig_command::FSCONFIG_SET_BINARY as u32,

    /// `FSCONFIG_SET_PATH`
    SetPath = linux_raw_sys::general::fsconfig_command::FSCONFIG_SET_PATH as u32,

    /// `FSCONFIG_SET_PATH_EMPTY`
    SetPathEmpty = linux_raw_sys::general::fsconfig_command::FSCONFIG_SET_PATH_EMPTY as u32,

    /// `FSCONFIG_SET_FD`
    SetFd = linux_raw_sys::general::fsconfig_command::FSCONFIG_SET_FD as u32,

    /// `FSCONFIG_CMD_CREATE`
    Create = linux_raw_sys::general::fsconfig_command::FSCONFIG_CMD_CREATE as u32,

    /// `FSCONFIG_CMD_RECONFIGURE`
    Reconfigure = linux_raw_sys::general::fsconfig_command::FSCONFIG_CMD_RECONFIGURE as u32,
}

#[cfg(feature = "mount")]
bitflags! {
    /// `MOUNT_ATTR_*` constants for use with [`fsmount`].
    ///
    /// [`fsmount`]: crate::mount::fsmount
    #[repr(transparent)]
    #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
    pub struct MountAttrFlags: c::c_uint {
        /// `MOUNT_ATTR_RDONLY`
        const MOUNT_ATTR_RDONLY = linux_raw_sys::general::MOUNT_ATTR_RDONLY;

        /// `MOUNT_ATTR_NOSUID`
        const MOUNT_ATTR_NOSUID = linux_raw_sys::general::MOUNT_ATTR_NOSUID;

        /// `MOUNT_ATTR_NODEV`
        const MOUNT_ATTR_NODEV = linux_raw_sys::general::MOUNT_ATTR_NODEV;

        /// `MOUNT_ATTR_NOEXEC`
        const MOUNT_ATTR_NOEXEC = linux_raw_sys::general::MOUNT_ATTR_NOEXEC;

        /// `MOUNT_ATTR__ATIME`
        const MOUNT_ATTR__ATIME = linux_raw_sys::general::MOUNT_ATTR__ATIME;

        /// `MOUNT_ATTR_RELATIME`
        const MOUNT_ATTR_RELATIME = linux_raw_sys::general::MOUNT_ATTR_RELATIME;

        /// `MOUNT_ATTR_NOATIME`
        const MOUNT_ATTR_NOATIME = linux_raw_sys::general::MOUNT_ATTR_NOATIME;

        /// `MOUNT_ATTR_STRICTATIME`
        const MOUNT_ATTR_STRICTATIME = linux_raw_sys::general::MOUNT_ATTR_STRICTATIME;

        /// `MOUNT_ATTR_NODIRATIME`
        const MOUNT_ATTR_NODIRATIME = linux_raw_sys::general::MOUNT_ATTR_NODIRATIME;

        /// `MOUNT_ATTR_NOUSER`
        const MOUNT_ATTR_IDMAP = linux_raw_sys::general::MOUNT_ATTR_IDMAP;

        /// `MOUNT_ATTR__ATIME_FLAGS`
        const MOUNT_ATTR_NOSYMFOLLOW = linux_raw_sys::general::MOUNT_ATTR_NOSYMFOLLOW;

        /// `MOUNT_ATTR__ATIME_FLAGS`
        const MOUNT_ATTR_SIZE_VER0 = linux_raw_sys::general::MOUNT_ATTR_SIZE_VER0;

        /// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags>
        const _ = !0;
    }
}

#[cfg(feature = "mount")]
bitflags! {
    /// `MOVE_MOUNT_*` constants for use with [`move_mount`].
    ///
    /// [`move_mount`]: crate::mount::move_mount
    #[repr(transparent)]
    #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
    pub struct MoveMountFlags: c::c_uint {
        /// `MOVE_MOUNT_F_EMPTY_PATH`
        const MOVE_MOUNT_F_SYMLINKS = linux_raw_sys::general::MOVE_MOUNT_F_SYMLINKS;

        /// `MOVE_MOUNT_F_AUTOMOUNTS`
        const MOVE_MOUNT_F_AUTOMOUNTS = linux_raw_sys::general::MOVE_MOUNT_F_AUTOMOUNTS;

        /// `MOVE_MOUNT_F_EMPTY_PATH`
        const MOVE_MOUNT_F_EMPTY_PATH = linux_raw_sys::general::MOVE_MOUNT_F_EMPTY_PATH;

        /// `MOVE_MOUNT_T_SYMLINKS`
        const MOVE_MOUNT_T_SYMLINKS = linux_raw_sys::general::MOVE_MOUNT_T_SYMLINKS;

        /// `MOVE_MOUNT_T_AUTOMOUNTS`
        const MOVE_MOUNT_T_AUTOMOUNTS = linux_raw_sys::general::MOVE_MOUNT_T_AUTOMOUNTS;

        /// `MOVE_MOUNT_T_EMPTY_PATH`
        const MOVE_MOUNT_T_EMPTY_PATH = linux_raw_sys::general::MOVE_MOUNT_T_EMPTY_PATH;

        /// `MOVE_MOUNT__MASK`
        const MOVE_MOUNT_SET_GROUP = linux_raw_sys::general::MOVE_MOUNT_SET_GROUP;

        /// `MOVE_MOUNT_BENEATH` (since Linux 6.5)
        const MOVE_MOUNT_BENEATH = c::MOVE_MOUNT_BENEATH;

        /// `MOVE_MOUNT__MASK`
        const MOVE_MOUNT__MASK = linux_raw_sys::general::MOVE_MOUNT__MASK;

        /// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags>
        const _ = !0;
    }
}

#[cfg(feature = "mount")]
bitflags! {
    /// `OPENTREE_*` constants for use with [`open_tree`].
    ///
    /// [`open_tree`]: crate::mount::open_tree
    #[repr(transparent)]
    #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
    pub struct OpenTreeFlags: c::c_uint {
        /// `OPENTREE_CLONE`
        const OPEN_TREE_CLONE = linux_raw_sys::general::OPEN_TREE_CLONE;

        /// `OPENTREE_CLOEXEC`
        const OPEN_TREE_CLOEXEC = linux_raw_sys::general::OPEN_TREE_CLOEXEC;

        /// `AT_EMPTY_PATH`
        const AT_EMPTY_PATH = linux_raw_sys::general::AT_EMPTY_PATH;

        /// `AT_NO_AUTOMOUNT`
        const AT_NO_AUTOMOUNT = linux_raw_sys::general::AT_NO_AUTOMOUNT;

        /// `AT_RECURSIVE`
        const AT_RECURSIVE = linux_raw_sys::general::AT_RECURSIVE;

        /// `AT_SYMLINK_NOFOLLOW`
        const AT_SYMLINK_NOFOLLOW = linux_raw_sys::general::AT_SYMLINK_NOFOLLOW;

        /// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags>
        const _ = !0;
    }
}

#[cfg(feature = "mount")]
bitflags! {
    /// `FSPICK_*` constants for use with [`fspick`].
    ///
    /// [`fspick`]: crate::mount::fspick
    #[repr(transparent)]
    #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
    pub struct FsPickFlags: c::c_uint {
        /// `FSPICK_CLOEXEC`
        const FSPICK_CLOEXEC = linux_raw_sys::general::FSPICK_CLOEXEC;

        /// `FSPICK_SYMLINK_NOFOLLOW`
        const FSPICK_SYMLINK_NOFOLLOW = linux_raw_sys::general::FSPICK_SYMLINK_NOFOLLOW;

        /// `FSPICK_NO_AUTOMOUNT`
        const FSPICK_NO_AUTOMOUNT = linux_raw_sys::general::FSPICK_NO_AUTOMOUNT;

        /// `FSPICK_EMPTY_PATH`
        const FSPICK_EMPTY_PATH = linux_raw_sys::general::FSPICK_EMPTY_PATH;

        /// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags>
        const _ = !0;
    }
}

bitflags! {
    /// `MS_*` constants for use with [`mount_change`].
    ///
    /// [`mount_change`]: crate::mount::mount_change
    #[repr(transparent)]
    #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
    pub struct MountPropagationFlags: c::c_uint {
        /// `MS_SILENT`
        const SILENT = linux_raw_sys::general::MS_SILENT;
        /// `MS_SHARED`
        const SHARED = linux_raw_sys::general::MS_SHARED;
        /// `MS_PRIVATE`
        const PRIVATE = linux_raw_sys::general::MS_PRIVATE;
        /// `MS_SLAVE`
        const SLAVE = linux_raw_sys::general::MS_SLAVE;
        /// `MS_UNBINDABLE`
        const UNBINDABLE = linux_raw_sys::general::MS_UNBINDABLE;
        /// `MS_REC`
        const REC = linux_raw_sys::general::MS_REC;

        /// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags>
        const _ = !0;
    }
}

bitflags! {
    #[repr(transparent)]
    #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
    pub(crate) struct InternalMountFlags: c::c_uint {
        const REMOUNT = linux_raw_sys::general::MS_REMOUNT;
        const MOVE = linux_raw_sys::general::MS_MOVE;

        /// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags>
        const _ = !0;
    }
}

#[repr(transparent)]
pub(crate) struct MountFlagsArg(pub(crate) c::c_uint);