Migrate magiskinit selinux.cpp to Rust

This commit is contained in:
topjohnwu
2025-04-06 02:04:59 -07:00
committed by John Wu
parent 83e66767ff
commit d4a0286e13
10 changed files with 361 additions and 260 deletions

View File

@@ -1,4 +1,4 @@
use crate::{FsPath, LibcReturn};
use crate::{FsPath, LibcReturn, Utf8CStr};
use libc::c_ulong;
use std::ptr;
@@ -29,6 +29,19 @@ impl FsPath {
}
}
pub fn remount_with_data(&self, data: &Utf8CStr) -> std::io::Result<()> {
unsafe {
libc::mount(
ptr::null(),
self.as_ptr(),
ptr::null(),
libc::MS_REMOUNT,
data.as_ptr().cast(),
)
.as_os_err()
}
}
pub fn move_mount_to(&self, path: &FsPath) -> std::io::Result<()> {
unsafe {
libc::mount(