Refactor sepolicy.rules resolve

We resolve available partitions for sepolicy.rules when patching
boot and bind mount the partition by magiskinit.

For older devices, the previous logic won't work because the part name
is never readable.

Co-authored-by: topjohnwu <topjohnwu@gmail.com>
This commit is contained in:
LoveSy
2023-02-12 16:36:38 +08:00
committed by GitHub
parent 03418ddcbf
commit 9e8c68af12
11 changed files with 151 additions and 144 deletions

View File

@@ -1,5 +1,9 @@
use std::ffi::CStr;
use std::fs::File;
use std::io;
use std::io::BufRead;
use std::os::unix::io::{AsRawFd, FromRawFd, OwnedFd, RawFd};
use std::path::Path;
use libc::{c_char, c_uint, mode_t, EEXIST, ENOENT, O_CLOEXEC, O_PATH};
@@ -131,3 +135,8 @@ pub extern "C" fn mkdirs(path: *const c_char, mode: mode_t) -> i32 {
0
}
}
pub fn read_lines<P: AsRef<Path>>(path: P) -> io::Result<io::Lines<io::BufReader<File>>> {
let file = File::open(path)?;
Ok(io::BufReader::new(file).lines())
}