|
3 | 3 | use crate::backend::mount::types::{
|
4 | 4 | InternalMountFlags, MountFlags, MountFlagsArg, MountPropagationFlags, UnmountFlags,
|
5 | 5 | };
|
6 |
| -use crate::{backend, io, path}; |
| 6 | +use crate::{ |
| 7 | + backend, |
| 8 | + ffi::CStr, |
| 9 | + io, |
| 10 | + path::{self, option_into_with_c_str}, |
| 11 | +}; |
7 | 12 |
|
8 | 13 | /// `mount(source, target, filesystemtype, mountflags, data)`
|
9 | 14 | ///
|
@@ -36,6 +41,35 @@ pub fn mount<Source: path::Arg, Target: path::Arg, Fs: path::Arg, Data: path::Ar
|
36 | 41 | })
|
37 | 42 | }
|
38 | 43 |
|
| 44 | +/// `mount2(source, target, filesystemtype, mountflags, data)` |
| 45 | +/// |
| 46 | +/// # References |
| 47 | +/// - [Linux] |
| 48 | +/// |
| 49 | +/// [Linux]: https://man7.org/linux/man-pages/man2/mount.2.html |
| 50 | +#[inline] |
| 51 | +pub fn mount2<Source: path::Arg, Target: path::Arg, Fs: path::Arg>( |
| 52 | + source: Option<Source>, |
| 53 | + target: Target, |
| 54 | + file_system_type: Option<Fs>, |
| 55 | + flags: MountFlags, |
| 56 | + data: Option<&CStr>, |
| 57 | +) -> io::Result<()> { |
| 58 | + option_into_with_c_str(source, |source| { |
| 59 | + target.into_with_c_str(|target| { |
| 60 | + option_into_with_c_str(file_system_type, |file_system_type| { |
| 61 | + backend::mount::syscalls::mount( |
| 62 | + source, |
| 63 | + target, |
| 64 | + file_system_type, |
| 65 | + MountFlagsArg(flags.bits()), |
| 66 | + data, |
| 67 | + ) |
| 68 | + }) |
| 69 | + }) |
| 70 | + }) |
| 71 | +} |
| 72 | + |
39 | 73 | /// `mount(NULL, target, NULL, MS_REMOUNT | mountflags, data)`
|
40 | 74 | ///
|
41 | 75 | /// # References
|
|
0 commit comments