fix(ksud): fix print sth. is usize

Signed-off-by: Tools-app <localhost.hutao@gmail.com>
This commit is contained in:
Tools-app
2025-11-30 08:54:02 +08:00
committed by 生于生时 亡于亡刻
parent f8a3a3aaf2
commit b9d8da3415
3 changed files with 14 additions and 13 deletions

View File

@@ -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(())
}

View File

@@ -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;

View File

@@ -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("<invalid>");
ver
String::from_utf8((&cmd.susfs_version[..ver]).to_vec()).unwrap_or("<invalid>".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("<invalid>");
println!("{}", features);
String::from_utf8((&cmd.enabled_features[..features]).to_vec())
.unwrap_or("<invalid>".to_string())
}