Add log_ok() for log().ok()

This commit is contained in:
LoveSy
2025-02-04 21:15:16 +08:00
committed by John Wu
parent b1e17706a4
commit 9a74e19117
7 changed files with 36 additions and 30 deletions
+2 -2
View File
@@ -66,7 +66,7 @@ impl MagiskInit {
let orig_init = FsPath::from(unsafe { Utf8CStr::from_ptr_unchecked(self.backup_init()) });
if orig_init.exists() {
orig_init.rename_to(FsPath::from(cstr!("/init"))).log().ok();
orig_init.rename_to(FsPath::from(cstr!("/init"))).log_ok();
} else {
// If the backup init is missing, this means that the boot ramdisk
// was created from scratch, and the real init is in a separate CPIO,
@@ -151,7 +151,7 @@ pub unsafe extern "C" fn main(
}
if getpid() == 1 {
MagiskInit::new(argv).start().log().ok();
MagiskInit::new(argv).start().log_ok();
}
1
+13 -19
View File
@@ -76,26 +76,20 @@ pub fn is_device_mounted(dev: u64, target: Pin<&mut CxxString>) -> bool {
impl MagiskInit {
pub(crate) fn prepare_data(&self) {
debug!("Setup data tmp");
fn inner() -> LoggedResult<()> {
FsPath::from(cstr!("/data")).mkdir(0o755)?;
unsafe {
mount(
raw_cstr!("magisk"),
raw_cstr!("/data"),
raw_cstr!("tmpfs"),
0,
raw_cstr!("mode=755").cast(),
)
}
.as_os_err()?;
FsPath::from(cstr!("/data")).mkdir(0o755).log_ok();
unsafe {
mount(
raw_cstr!("magisk"),
raw_cstr!("/data"),
raw_cstr!("tmpfs"),
0,
raw_cstr!("mode=755").cast(),
)
}.as_os_err().log_ok();
FsPath::from(cstr!("/init")).copy_to(FsPath::from(cstr!("/data/magiskinit")))?;
FsPath::from(cstr!("/.backup")).copy_to(FsPath::from(cstr!("/data/.backup")))?;
FsPath::from(cstr!("/overlay.d")).copy_to(FsPath::from(cstr!("/data/overlay.d")))?;
Ok(())
}
inner().ok();
FsPath::from(cstr!("/init")).copy_to(FsPath::from(cstr!("/data/magiskinit"))).log_ok();
FsPath::from(cstr!("/.backup")).copy_to(FsPath::from(cstr!("/data/.backup"))).log_ok();
FsPath::from(cstr!("/overlay.d")).copy_to(FsPath::from(cstr!("/data/overlay.d"))).log_ok();
}
pub(crate) fn exec_init(&self) {
+2 -2
View File
@@ -116,14 +116,14 @@ impl MagiskInit {
debug!("Patch @ {:#010X} [{}] -> [{}]", off, from, to);
}
if let Ok(mut dest) = dest.create(O_CREAT | O_WRONLY, 0) {
dest.write_all(map.as_ref()).log().ok();
dest.write_all(map.as_ref()).log_ok();
} else {
error!("Failed to create {}", dest);
}
} else {
error!("Failed to open {} for hexpatch", src);
}
clone_attr(src, dest).log().ok();
clone_attr(src, dest).log_ok();
unsafe {
mount(dest.as_ptr(), src.as_ptr(), null(), MS_BIND, null())
.as_os_err()