Skip to content

Commit 967750b

Browse files
5ec1cffbackslashxx
authored andcommitted
ksud: make tmpfs and magic mount optional
- Create /data/adb/ksu/{.notmpfs,.nomount} to disable them.
1 parent 76b8f91 commit 967750b

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

userspace/ksud/src/defs.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,6 @@ pub const VERSION_NAME: &str = include_str!(concat!(env!("OUT_DIR"), "/VERSION_N
4141
pub const KSU_BACKUP_DIR: &str = WORKING_DIR;
4242
pub const KSU_BACKUP_FILE_PREFIX: &str = "ksu_backup_";
4343
pub const BACKUP_FILENAME: &str = "stock_image.sha1";
44+
45+
pub const NO_TMPFS_PATH: &str = concatcp!(WORKING_DIR, ".notmpfs");
46+
pub const NO_MOUNT_PATH: &str = concatcp!(WORKING_DIR, ".nomount");

userspace/ksud/src/init_event.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::defs::{KSU_MOUNT_SOURCE, TEMP_DIR};
1+
use crate::defs::{KSU_MOUNT_SOURCE, NO_MOUNT_PATH, NO_TMPFS_PATH, TEMP_DIR};
22
use crate::module::{handle_updated_modules, prune_modules};
33
use crate::{assets, defs, ksucalls, restorecon, utils};
44
use anyhow::{Context, Result};
@@ -68,8 +68,12 @@ pub fn on_post_data_fs() -> Result<()> {
6868
}
6969

7070
// mount temp dir
71-
if let Err(e) = mount(KSU_MOUNT_SOURCE, TEMP_DIR, "tmpfs", MountFlags::empty(), "") {
72-
warn!("do temp dir mount failed: {}", e);
71+
if !Path::new(NO_TMPFS_PATH).exists() {
72+
if let Err(e) = mount(KSU_MOUNT_SOURCE, TEMP_DIR, "tmpfs", MountFlags::empty(), "") {
73+
warn!("do temp dir mount failed: {}", e);
74+
}
75+
} else {
76+
info!("no tmpfs requested");
7377
}
7478

7579
// exec modules post-fs-data scripts
@@ -84,8 +88,12 @@ pub fn on_post_data_fs() -> Result<()> {
8488
}
8589

8690
// mount module systemlessly by magic mount
87-
if let Err(e) = mount_modules_systemlessly() {
88-
warn!("do systemless mount failed: {}", e);
91+
if !Path::new(NO_MOUNT_PATH).exists() {
92+
if let Err(e) = mount_modules_systemlessly() {
93+
warn!("do systemless mount failed: {}", e);
94+
}
95+
} else {
96+
info!("no mount requested");
8997
}
9098

9199
run_stage("post-mount", true);

0 commit comments

Comments
 (0)