You've already forked Magisk
mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-09-06 06:36:58 +00:00
Replace rust inner functions to try blocks
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
#![feature(format_args_nl)]
|
||||
#![feature(once_cell_try)]
|
||||
#![feature(try_blocks)]
|
||||
|
||||
use logging::setup_klog;
|
||||
use mount::{is_device_mounted, switch_root};
|
||||
use rootdir::{inject_magisk_rc, collect_overlay_contexts, reset_overlay_contexts};
|
||||
use rootdir::{collect_overlay_contexts, inject_magisk_rc, reset_overlay_contexts};
|
||||
// Has to be pub so all symbols in that crate is included
|
||||
pub use magiskpolicy;
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ use base::{
|
||||
};
|
||||
|
||||
pub fn switch_root(path: &Utf8CStr) {
|
||||
fn inner(path: &Utf8CStr) -> LoggedResult<()> {
|
||||
let res: LoggedResult<()> = try {
|
||||
debug!("Switch root to {}", path);
|
||||
let mut mounts = BTreeSet::new();
|
||||
let mut rootfs = Directory::open(cstr!("/"))?;
|
||||
@@ -55,9 +55,8 @@ pub fn switch_root(path: &Utf8CStr) {
|
||||
|
||||
debug!("Cleaning rootfs");
|
||||
rootfs.remove_all()?;
|
||||
Ok(())
|
||||
}
|
||||
inner(path).ok();
|
||||
};
|
||||
res.ok();
|
||||
}
|
||||
|
||||
pub fn is_device_mounted(dev: u64, target: Pin<&mut CxxString>) -> bool {
|
||||
|
||||
Reference in New Issue
Block a user