Fix temp dir on Android 10 or below (#1250)
Co-authored-by: Ylarod <me@ylarod.cn>
This commit is contained in:
@@ -48,6 +48,9 @@ enum Commands {
|
|||||||
command: Profile,
|
command: Profile,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/// Print KernelSU tmpfs path
|
||||||
|
Path,
|
||||||
|
|
||||||
/// For developers
|
/// For developers
|
||||||
Debug {
|
Debug {
|
||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
@@ -228,6 +231,10 @@ pub fn run() -> Result<()> {
|
|||||||
Profile::DeleteTemplate { id } => crate::profile::delete_template(id),
|
Profile::DeleteTemplate { id } => crate::profile::delete_template(id),
|
||||||
Profile::ListTemplates => crate::profile::list_templates(),
|
Profile::ListTemplates => crate::profile::list_templates(),
|
||||||
},
|
},
|
||||||
|
Commands::Path => {
|
||||||
|
println!("{}", utils::get_tmp_path());
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
Commands::Debug { command } => match command {
|
Commands::Debug { command } => match command {
|
||||||
Debug::SetManager { apk } => debug::set_manager(&apk),
|
Debug::SetManager { apk } => debug::set_manager(&apk),
|
||||||
|
|||||||
@@ -25,7 +25,8 @@ pub const MODULE_UPDATE_TMP_IMG: &str = concatcp!(WORKING_DIR, "update_tmp.img")
|
|||||||
// warning: this directory should not change, or you need to change the code in module_installer.sh!!!
|
// warning: this directory should not change, or you need to change the code in module_installer.sh!!!
|
||||||
pub const MODULE_UPDATE_TMP_DIR: &str = concatcp!(ADB_DIR, "modules_update/");
|
pub const MODULE_UPDATE_TMP_DIR: &str = concatcp!(ADB_DIR, "modules_update/");
|
||||||
|
|
||||||
pub const TEMP_DIR: &str = "/debug_ramdisk/";
|
pub const TEMP_DIR: &str = "/debug_ramdisk";
|
||||||
|
pub const TEMP_DIR_LEGACY: &str = "/sbin";
|
||||||
|
|
||||||
pub const DISABLE_FILE_NAME: &str = "disable";
|
pub const DISABLE_FILE_NAME: &str = "disable";
|
||||||
pub const UPDATE_FILE_NAME: &str = "update";
|
pub const UPDATE_FILE_NAME: &str = "update";
|
||||||
|
|||||||
@@ -179,7 +179,7 @@ pub fn on_post_data_fs() -> Result<()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// mount temp dir
|
// mount temp dir
|
||||||
if let Err(e) = mount::mount_tmpfs(defs::TEMP_DIR) {
|
if let Err(e) = mount::mount_tmpfs(utils::get_tmp_path()) {
|
||||||
warn!("do temp dir mount failed: {}", e);
|
warn!("do temp dir mount failed: {}", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ use std::{
|
|||||||
path::Path,
|
path::Path,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use crate::defs;
|
||||||
|
use std::fs::metadata;
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
use std::fs::{set_permissions, Permissions};
|
use std::fs::{set_permissions, Permissions};
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
@@ -163,3 +165,13 @@ pub fn umask(_mask: u32) {
|
|||||||
pub fn has_magisk() -> bool {
|
pub fn has_magisk() -> bool {
|
||||||
which::which("magisk").is_ok()
|
which::which("magisk").is_ok()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_tmp_path() -> &'static str {
|
||||||
|
if metadata(defs::TEMP_DIR_LEGACY).is_ok() {
|
||||||
|
return defs::TEMP_DIR_LEGACY;
|
||||||
|
}
|
||||||
|
if metadata(defs::TEMP_DIR).is_ok() {
|
||||||
|
return defs::TEMP_DIR;
|
||||||
|
}
|
||||||
|
""
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user