Skip to content

Commit

Permalink
ksud: don't patch if it's already patched
Browse files Browse the repository at this point in the history
  • Loading branch information
tiann committed Mar 11, 2024
1 parent 22a1276 commit ce5aa99
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions userspace/ksud/src/boot_patch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,13 @@ pub fn patch(
.status()?;
ensure!(status.success(), "magiskboot unpack failed");

let status = do_cpio_cmd(&magiskboot, workding_dir.path(), "exists init");
if status.is_ok() {
// init exist, backup it.
do_cpio_cmd(&magiskboot, workding_dir.path(), "mv init init.real")?;
let is_kernelsu_patched = do_cpio_cmd(&magiskboot, workding_dir.path(), "exists kernelsu.ko").is_ok();
if !is_kernelsu_patched {
// kernelsu.ko is not exist, backup init if necessary
let status = do_cpio_cmd(&magiskboot, workding_dir.path(), "exists init");
if status.is_ok() {
do_cpio_cmd(&magiskboot, workding_dir.path(), "mv init init.real")?;
}
}

do_cpio_cmd(&magiskboot, workding_dir.path(), "add 0755 init init")?;
Expand Down

0 comments on commit ce5aa99

Please sign in to comment.