Skip to content
This repository was archived by the owner on Oct 30, 2025. It is now read-only.

Commit 511b874

Browse files
committed
ksud: add cmd for add-try-umount (5ec1cff#16)
int main(int argc, char *argv[]) { if (argc != 4) { printf("Usage: %s <option> <option> <string>\n", argv[0]); return 1; } unsigned long option = strtoul(argv[1], NULL, 0); unsigned long arg2 = strtoul(argv[2], NULL, 0); const char *arg3 = argv[3]; unsigned long arg4 = 0; unsigned long arg5 = 0; printf("SYS_prctl(%lu, %lu, %p, %p, %p)\n", option, arg2, &arg3, &arg4, &arg5); syscall(SYS_prctl, option, arg2, arg3, &arg4, &arg5); printf("arg3: %lu\n", (unsigned long)arg3); printf("arg4: %lu\n", arg4); printf("arg5: 0x%lx\n", arg5); return 0; }
1 parent 0f68d54 commit 511b874

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

userspace/ksud/src/cli.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ use log::LevelFilter;
1010
use crate::defs::KSUD_VERBOSE_LOG_FILE;
1111
use crate::{apk_sign, assets, debug, defs, init_event, ksucalls, module, utils};
1212

13+
use std::ffi::CString;
14+
1315
/// KernelSU userspace cli
1416
#[derive(Parser, Debug)]
1517
#[command(author, version = defs::VERSION_NAME, about, long_about = None)]
@@ -29,6 +31,11 @@ enum Commands {
2931
command: Module,
3032
},
3133

34+
/// Add custom try umount path
35+
AddTryUmount {
36+
path: PathBuf,
37+
},
38+
3239
/// Trigger `post-fs-data` event
3340
PostFsData,
3441

@@ -309,6 +316,22 @@ pub fn run() -> Result<()> {
309316
Module::List => module::list_modules(),
310317
}
311318
}
319+
Commands::AddTryUmount { path } => {
320+
match CString::new(path.to_string_lossy().as_ref()) {
321+
std::result::Result::Ok(c_path) => {
322+
let mut dummy: u32 = 0;
323+
unsafe {
324+
libc::prctl(0xDEADBEEFu32 as i32, 10001, c_path.as_ptr() as libc::c_ulong,
325+
&mut dummy as *mut u32 as libc::c_ulong,
326+
&mut dummy as *mut u32 as libc::c_ulong);
327+
}
328+
}
329+
std::result::Result::Err(e) => {
330+
eprintln!("Failed to create CString: {}", e);
331+
}
332+
}
333+
Ok(())
334+
}
312335
Commands::Install { magiskboot } => utils::install(magiskboot),
313336
Commands::Uninstall { magiskboot } => utils::uninstall(magiskboot),
314337
Commands::Sepolicy { command } => match command {

0 commit comments

Comments
 (0)