fix(ksud): fix print sth. is usize
Signed-off-by: Tools-app <localhost.hutao@gmail.com>
This commit is contained in:
@@ -522,7 +522,7 @@ pub fn run() -> Result<()> {
|
|||||||
Susfs::Status => {
|
Susfs::Status => {
|
||||||
println!("{}", susfs::get_susfs_status())
|
println!("{}", susfs::get_susfs_status())
|
||||||
}
|
}
|
||||||
Susfs::Features => susfs::get_susfs_features(),
|
Susfs::Features => println!("{}", susfs::get_susfs_features()),
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ mod cli;
|
|||||||
mod debug;
|
mod debug;
|
||||||
mod defs;
|
mod defs;
|
||||||
mod feature;
|
mod feature;
|
||||||
mod susfs;
|
|
||||||
mod init_event;
|
mod init_event;
|
||||||
#[cfg(target_arch = "aarch64")]
|
#[cfg(target_arch = "aarch64")]
|
||||||
mod kpm;
|
mod kpm;
|
||||||
@@ -29,6 +28,7 @@ mod profile;
|
|||||||
mod restorecon;
|
mod restorecon;
|
||||||
mod sepolicy;
|
mod sepolicy;
|
||||||
mod su;
|
mod su;
|
||||||
|
mod susfs;
|
||||||
#[cfg(target_os = "android")]
|
#[cfg(target_os = "android")]
|
||||||
mod uid_scanner;
|
mod uid_scanner;
|
||||||
mod umount_manager;
|
mod umount_manager;
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
use anyhow::Result;
|
|
||||||
use libc::SYS_reboot;
|
use libc::SYS_reboot;
|
||||||
|
|
||||||
const SUSFS_MAX_VERSION_BUFSIZE: usize = 16;
|
const SUSFS_MAX_VERSION_BUFSIZE: usize = 16;
|
||||||
@@ -21,7 +20,7 @@ struct SusfsFeatures {
|
|||||||
err: i32,
|
err: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_susfs_version() -> usize {
|
pub fn get_susfs_version() -> String {
|
||||||
let mut cmd = SusfsVersion {
|
let mut cmd = SusfsVersion {
|
||||||
susfs_version: [0; SUSFS_MAX_VERSION_BUFSIZE],
|
susfs_version: [0; SUSFS_MAX_VERSION_BUFSIZE],
|
||||||
err: ERR_CMD_NOT_SUPPORTED,
|
err: ERR_CMD_NOT_SUPPORTED,
|
||||||
@@ -38,20 +37,22 @@ pub fn get_susfs_version() -> usize {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if ret < 0 {
|
if ret < 0 {
|
||||||
return 0;
|
return "unsupport".to_string();
|
||||||
}
|
}
|
||||||
|
|
||||||
let ver = cmd.susfs_version.iter().position(|&b| b == 0).unwrap_or(16);
|
let ver = cmd.susfs_version.iter().position(|&b| b == 0).unwrap_or(16);
|
||||||
std::str::from_utf8(&cmd.susfs_version[..ver]).unwrap_or("<invalid>");
|
String::from_utf8((&cmd.susfs_version[..ver]).to_vec()).unwrap_or("<invalid>".to_string())
|
||||||
|
|
||||||
ver
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_susfs_status() -> bool {
|
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 {
|
let mut cmd = SusfsFeatures {
|
||||||
enabled_features: [0; SUSFS_ENABLED_FEATURES_SIZE],
|
enabled_features: [0; SUSFS_ENABLED_FEATURES_SIZE],
|
||||||
err: ERR_CMD_NOT_SUPPORTED,
|
err: ERR_CMD_NOT_SUPPORTED,
|
||||||
@@ -68,7 +69,7 @@ pub fn get_susfs_features() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if ret < 0 {
|
if ret < 0 {
|
||||||
return;
|
return String::new();
|
||||||
}
|
}
|
||||||
|
|
||||||
let features = cmd
|
let features = cmd
|
||||||
@@ -76,6 +77,6 @@ pub fn get_susfs_features() {
|
|||||||
.iter()
|
.iter()
|
||||||
.position(|&b| b == 0)
|
.position(|&b| b == 0)
|
||||||
.unwrap_or(16);
|
.unwrap_or(16);
|
||||||
std::str::from_utf8(&cmd.enabled_features[..features]).unwrap_or("<invalid>");
|
String::from_utf8((&cmd.enabled_features[..features]).to_vec())
|
||||||
println!("{}", features);
|
.unwrap_or("<invalid>".to_string())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user