|
1 | 1 | //! Linux `mount`.
|
2 | 2 |
|
3 | 3 | use crate::backend::fs::types::{
|
4 |
| - InternalMountFlags, MountFlags, MountFlagsArg, MountPropagationFlags, UnmountFlags, |
| 4 | + FsMountFlags, FsOpenFlags, FsPickFlags, InternalMountFlags, MountAttrFlags, MountFlags, |
| 5 | + MountFlagsArg, MountPropagationFlags, MoveMountFlags, OpenTreeFlags, UnmountFlags, |
5 | 6 | };
|
| 7 | +use crate::fd::{BorrowedFd, OwnedFd}; |
6 | 8 | use crate::{backend, io, path};
|
7 | 9 |
|
8 | 10 | /// `mount(source, target, filesystemtype, mountflags, data)`
|
@@ -164,3 +166,123 @@ pub fn move_mount<Source: path::Arg, Target: path::Arg>(
|
164 | 166 | pub fn unmount<Target: path::Arg>(target: Target, flags: UnmountFlags) -> io::Result<()> {
|
165 | 167 | target.into_with_c_str(|target| backend::fs::syscalls::unmount(target, flags))
|
166 | 168 | }
|
| 169 | + |
| 170 | +/// `fsopen(fs_name, flags)` |
| 171 | +pub fn fsopen<Fs: path::Arg>(fs_name: Fs, flags: FsOpenFlags) -> io::Result<OwnedFd> { |
| 172 | + fs_name.into_with_c_str(|fs_name| backend::fs::syscalls::fsopen(fs_name, flags)) |
| 173 | +} |
| 174 | + |
| 175 | +/// `fsmount(fs_fd, flags, attr_flags)` |
| 176 | +pub fn fsmount( |
| 177 | + fs_fd: BorrowedFd<'_>, |
| 178 | + flags: FsMountFlags, |
| 179 | + attr_flags: MountAttrFlags, |
| 180 | +) -> io::Result<()> { |
| 181 | + backend::fs::syscalls::fsmount(fs_fd, flags, attr_flags) |
| 182 | +} |
| 183 | + |
| 184 | +/// `move_mount(from_dfd, from_pathname, to_dfd, to_pathname, flags)` |
| 185 | +pub fn move_mount_<From: path::Arg, To: path::Arg>( |
| 186 | + from_dfd: BorrowedFd<'_>, |
| 187 | + from_pathname: From, |
| 188 | + to_dfd: BorrowedFd<'_>, |
| 189 | + to_pathname: To, |
| 190 | + flags: MoveMountFlags, |
| 191 | +) -> io::Result<()> { |
| 192 | + from_pathname.into_with_c_str(|from_pathname| { |
| 193 | + to_pathname.into_with_c_str(|to_pathname| { |
| 194 | + backend::fs::syscalls::move_mount(from_dfd, from_pathname, to_dfd, to_pathname, flags) |
| 195 | + }) |
| 196 | + }) |
| 197 | +} |
| 198 | + |
| 199 | +/// `open_tree(dfd, filename, flags)` |
| 200 | +pub fn open_tree<Path: path::Arg>( |
| 201 | + dfd: BorrowedFd<'_>, |
| 202 | + filename: Path, |
| 203 | + flags: OpenTreeFlags, |
| 204 | +) -> io::Result<OwnedFd> { |
| 205 | + filename.into_with_c_str(|filename| backend::fs::syscalls::open_tree(dfd, filename, flags)) |
| 206 | +} |
| 207 | + |
| 208 | +/// `fspick(dfd, path, flags)` |
| 209 | +pub fn fspick<Path: path::Arg>( |
| 210 | + dfd: BorrowedFd<'_>, |
| 211 | + path: Path, |
| 212 | + flags: FsPickFlags, |
| 213 | +) -> io::Result<OwnedFd> { |
| 214 | + path.into_with_c_str(|path| backend::fs::syscalls::fspick(dfd, path, flags)) |
| 215 | +} |
| 216 | + |
| 217 | +/// `fsconfig(fs_fd, FSCONFIG_SET_FLAG, key, NULL, 0)` |
| 218 | +#[doc(alias = "fsconfig")] |
| 219 | +pub fn fsconfig_set_flag<Key: path::Arg>(fs_fd: BorrowedFd<'_>, key: Key) -> io::Result<()> { |
| 220 | + key.into_with_c_str(|key| backend::fs::syscalls::fsconfig_set_flag(fs_fd, key)) |
| 221 | +} |
| 222 | + |
| 223 | +/// `fsconfig(fs_fd, FSCONFIG_SET_STRING, key, value, 0)` |
| 224 | +#[doc(alias = "fsconfig")] |
| 225 | +pub fn fsconfig_set_string<Key: path::Arg, Value: path::Arg>( |
| 226 | + fs_fd: BorrowedFd<'_>, |
| 227 | + key: Key, |
| 228 | + value: Value, |
| 229 | +) -> io::Result<()> { |
| 230 | + key.into_with_c_str(|key| { |
| 231 | + value.into_with_c_str(|value| backend::fs::syscalls::fsconfig_set_string(fs_fd, key, value)) |
| 232 | + }) |
| 233 | +} |
| 234 | + |
| 235 | +/// `fsconfig(fs_fd, FSCONFIG_SET_BINARY, key, value, value.len())` |
| 236 | +#[doc(alias = "fsconfig")] |
| 237 | +pub fn fsconfig_set_binary<Key: path::Arg>( |
| 238 | + fs_fd: BorrowedFd<'_>, |
| 239 | + key: Key, |
| 240 | + value: &[u8], |
| 241 | +) -> io::Result<()> { |
| 242 | + key.into_with_c_str(|key| backend::fs::syscalls::fsconfig_set_binary(fs_fd, key, value)) |
| 243 | +} |
| 244 | + |
| 245 | +/// `fsconfig(fs_fd, FSCONFIG_SET_PATH, key, path, fd)` |
| 246 | +#[doc(alias = "fsconfig")] |
| 247 | +pub fn fsconfig_set_path<Key: path::Arg, Path: path::Arg>( |
| 248 | + fs_fd: BorrowedFd<'_>, |
| 249 | + key: Key, |
| 250 | + path: Path, |
| 251 | + fd: BorrowedFd<'_>, |
| 252 | +) -> io::Result<()> { |
| 253 | + key.into_with_c_str(|key| { |
| 254 | + path.into_with_c_str(|path| backend::fs::syscalls::fsconfig_set_path(fs_fd, key, path, fd)) |
| 255 | + }) |
| 256 | +} |
| 257 | + |
| 258 | +/// `fsconfig(fs_fd, FSCONFIG_SET_PATH_EMPTY, key, "", fd)` |
| 259 | +#[doc(alias = "fsconfig")] |
| 260 | +pub fn fsconfig_set_path_empty<Key: path::Arg>( |
| 261 | + fs_fd: BorrowedFd<'_>, |
| 262 | + key: Key, |
| 263 | + fd: BorrowedFd<'_>, |
| 264 | +) -> io::Result<()> { |
| 265 | + key.into_with_c_str(|key| backend::fs::syscalls::fsconfig_set_path_empty(fs_fd, key, fd)) |
| 266 | +} |
| 267 | + |
| 268 | +/// `fsconfig(fs_fd, FSCONFIG_SET_FD, key, NULL, fd)` |
| 269 | +#[doc(alias = "fsconfig")] |
| 270 | +pub fn fsconfig_set_fd<Key: path::Arg>( |
| 271 | + fs_fd: BorrowedFd<'_>, |
| 272 | + key: Key, |
| 273 | + fd: BorrowedFd<'_>, |
| 274 | +) -> io::Result<()> { |
| 275 | + key.into_with_c_str(|key| backend::fs::syscalls::fsconfig_set_fd(fs_fd, key, fd)) |
| 276 | +} |
| 277 | + |
| 278 | +/// `fsconfig(fs_fd, FSCONFIG_CMD_CREATE, key, NULL, 0)` |
| 279 | +#[doc(alias = "fsconfig")] |
| 280 | +pub fn fsconfig_create(fs_fd: BorrowedFd<'_>) -> io::Result<()> { |
| 281 | + backend::fs::syscalls::fsconfig_create(fs_fd) |
| 282 | +} |
| 283 | + |
| 284 | +/// `fsconfig(fs_fd, FSCONFIG_CMD_RECONFIGURE, key, NULL, 0)` |
| 285 | +#[doc(alias = "fsconfig")] |
| 286 | +pub fn fsconfig_reconfigure(fs_fd: BorrowedFd<'_>) -> io::Result<()> { |
| 287 | + backend::fs::syscalls::fsconfig_reconfigure(fs_fd) |
| 288 | +} |
0 commit comments