Migrate module mounting to Rust

This commit is contained in:
topjohnwu
2025-05-08 21:00:40 -07:00
committed by John Wu
parent 4c89c7e2b3
commit 527bbc0368
11 changed files with 615 additions and 675 deletions

View File

@@ -3,13 +3,14 @@ use libc::c_ulong;
use std::ptr;
impl Utf8CStr {
pub fn bind_mount_to<'a>(&'a self, path: &'a Utf8CStr) -> OsResult<'a, ()> {
pub fn bind_mount_to<'a>(&'a self, path: &'a Utf8CStr, rec: bool) -> OsResult<'a, ()> {
let flag = if rec { libc::MS_REC } else { 0 };
unsafe {
libc::mount(
self.as_ptr(),
path.as_ptr(),
ptr::null(),
libc::MS_BIND,
libc::MS_BIND | flag,
ptr::null(),
)
.check_os_err("bind_mount", Some(self), Some(path))