diff --git a/userspace/ksud/src/cli.rs b/userspace/ksud/src/cli.rs index e9456ad5..ce9f4c23 100644 --- a/userspace/ksud/src/cli.rs +++ b/userspace/ksud/src/cli.rs @@ -522,7 +522,7 @@ pub fn run() -> Result<()> { Susfs::Status => { println!("{}", susfs::get_susfs_status()) } - Susfs::Features => susfs::get_susfs_features(), + Susfs::Features => println!("{}", susfs::get_susfs_features()), } Ok(()) } diff --git a/userspace/ksud/src/main.rs b/userspace/ksud/src/main.rs index 041dc3f2..cc3ee99a 100644 --- a/userspace/ksud/src/main.rs +++ b/userspace/ksud/src/main.rs @@ -17,7 +17,6 @@ mod cli; mod debug; mod defs; mod feature; -mod susfs; mod init_event; #[cfg(target_arch = "aarch64")] mod kpm; @@ -29,6 +28,7 @@ mod profile; mod restorecon; mod sepolicy; mod su; +mod susfs; #[cfg(target_os = "android")] mod uid_scanner; mod umount_manager; diff --git a/userspace/ksud/src/susfs.rs b/userspace/ksud/src/susfs.rs index 76991210..cc0252e0 100644 --- a/userspace/ksud/src/susfs.rs +++ b/userspace/ksud/src/susfs.rs @@ -1,4 +1,3 @@ -use anyhow::Result; use libc::SYS_reboot; const SUSFS_MAX_VERSION_BUFSIZE: usize = 16; @@ -21,7 +20,7 @@ struct SusfsFeatures { err: i32, } -pub fn get_susfs_version() -> usize { +pub fn get_susfs_version() -> String { let mut cmd = SusfsVersion { susfs_version: [0; SUSFS_MAX_VERSION_BUFSIZE], err: ERR_CMD_NOT_SUPPORTED, @@ -38,20 +37,22 @@ pub fn get_susfs_version() -> usize { }; if ret < 0 { - return 0; + return "unsupport".to_string(); } let ver = cmd.susfs_version.iter().position(|&b| b == 0).unwrap_or(16); - std::str::from_utf8(&cmd.susfs_version[..ver]).unwrap_or(""); - - ver + String::from_utf8((&cmd.susfs_version[..ver]).to_vec()).unwrap_or("".to_string()) } pub fn get_susfs_status() -> bool { - if get_susfs_version() < 0 { false } else { true } + if get_susfs_version() == "unsupport" { + false + } else { + true + } } -pub fn get_susfs_features() { +pub fn get_susfs_features() -> String { let mut cmd = SusfsFeatures { enabled_features: [0; SUSFS_ENABLED_FEATURES_SIZE], err: ERR_CMD_NOT_SUPPORTED, @@ -68,7 +69,7 @@ pub fn get_susfs_features() { }; if ret < 0 { - return; + return String::new(); } let features = cmd @@ -76,6 +77,6 @@ pub fn get_susfs_features() { .iter() .position(|&b| b == 0) .unwrap_or(16); - std::str::from_utf8(&cmd.enabled_features[..features]).unwrap_or(""); - println!("{}", features); + String::from_utf8((&cmd.enabled_features[..features]).to_vec()) + .unwrap_or("".to_string()) }