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
|
//! Linux `mount`.
use crate::backend::fs::types::{
InternalMountFlags, MountFlags, MountFlagsArg, MountPropagationFlags, UnmountFlags,
};
use crate::{backend, io, path};
/// `mount(source, target, filesystemtype, mountflags, data)`
///
/// # References
/// - [Linux]
///
/// [Linux]: https://man7.org/linux/man-pages/man2/mount.2.html
#[inline]
pub fn mount<Source: path::Arg, Target: path::Arg, Fs: path::Arg, Data: path::Arg>(
source: Source,
target: Target,
file_system_type: Fs,
flags: MountFlags,
data: Data,
) -> io::Result<()> {
source.into_with_c_str(|source| {
target.into_with_c_str(|target| {
file_system_type.into_with_c_str(|file_system_type| {
data.into_with_c_str(|data| {
backend::fs::syscalls::mount(
Some(source),
target,
Some(file_system_type),
MountFlagsArg(flags.bits()),
Some(data),
)
})
})
})
})
}
/// `mount(NULL, target, NULL, MS_REMOUNT | mountflags, data)`
///
/// # References
/// - [Linux]
///
/// [Linux]: https://man7.org/linux/man-pages/man2/mount.2.html
#[inline]
#[doc(alias = "mount")]
pub fn remount<Target: path::Arg, Data: path::Arg>(
target: Target,
flags: MountFlags,
data: Data,
) -> io::Result<()> {
target.into_with_c_str(|target| {
data.into_with_c_str(|data| {
backend::fs::syscalls::mount(
None,
target,
None,
MountFlagsArg(InternalMountFlags::REMOUNT.bits() | flags.bits()),
Some(data),
)
})
})
}
/// `mount(source, target, NULL, MS_BIND, NULL)`
///
/// # References
/// - [Linux]
///
/// [Linux]: https://man7.org/linux/man-pages/man2/mount.2.html
#[inline]
#[doc(alias = "mount")]
pub fn bind_mount<Source: path::Arg, Target: path::Arg>(
source: Source,
target: Target,
) -> io::Result<()> {
source.into_with_c_str(|source| {
target.into_with_c_str(|target| {
backend::fs::syscalls::mount(
Some(source),
target,
None,
MountFlagsArg(MountFlags::BIND.bits()),
None,
)
})
})
}
/// `mount(source, target, NULL, MS_BIND | MS_REC, NULL)`
///
/// # References
/// - [Linux]
///
/// [Linux]: https://man7.org/linux/man-pages/man2/mount.2.html
#[inline]
#[doc(alias = "mount")]
pub fn recursive_bind_mount<Source: path::Arg, Target: path::Arg>(
source: Source,
target: Target,
) -> io::Result<()> {
source.into_with_c_str(|source| {
target.into_with_c_str(|target| {
backend::fs::syscalls::mount(
Some(source),
target,
None,
MountFlagsArg(MountFlags::BIND.bits() | MountPropagationFlags::REC.bits()),
None,
)
})
})
}
/// `mount(NULL, target, NULL, mountflags, NULL)`
///
/// # References
/// - [Linux]
///
/// [Linux]: https://man7.org/linux/man-pages/man2/mount.2.html
#[inline]
#[doc(alias = "mount")]
pub fn change_mount<Target: path::Arg>(
target: Target,
flags: MountPropagationFlags,
) -> io::Result<()> {
target.into_with_c_str(|target| {
backend::fs::syscalls::mount(None, target, None, MountFlagsArg(flags.bits()), None)
})
}
/// `mount(source, target, NULL, MS_MOVE, NULL)`
///
/// # References
/// - [Linux]
///
/// [Linux]: https://man7.org/linux/man-pages/man2/mount.2.html
#[inline]
#[doc(alias = "mount")]
pub fn move_mount<Source: path::Arg, Target: path::Arg>(
source: Source,
target: Target,
) -> io::Result<()> {
source.into_with_c_str(|source| {
target.into_with_c_str(|target| {
backend::fs::syscalls::mount(
Some(source),
target,
None,
MountFlagsArg(InternalMountFlags::MOVE.bits()),
None,
)
})
})
}
/// `umount2(target, flags)`
///
/// # References
/// - [Linux]
///
/// [Linux]: https://man7.org/linux/man-pages/man2/umount.2.html
#[doc(alias = "umount", alias = "umount2")]
pub fn unmount<Target: path::Arg>(target: Target, flags: UnmountFlags) -> io::Result<()> {
target.into_with_c_str(|target| backend::fs::syscalls::unmount(target, flags))
}
|