Skip to content
This repository was archived by the owner on Nov 1, 2025. It is now read-only.

Commit 7baaad7

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

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

userspace/ksud/src/defs.rs

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

userspace/ksud/src/init_event.rs

Lines changed: 13 additions & 7 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 log::{info, warn};
44
use rustix::fs::{mount, MountFlags};
@@ -37,8 +37,6 @@ pub fn on_post_data_fs() -> Result<()> {
3737
let safe_mode = utils::is_safe_mode();
3838

3939
if safe_mode {
40-
// we should still mount modules.img to `/data/adb/modules` in safe mode
41-
// becuase we may need to operate the module dir in safe mode
4240
warn!("safe mode, skip common post-fs-data.d scripts");
4341
} else {
4442
// Then exec common post-fs-data scripts
@@ -83,8 +81,12 @@ pub fn on_post_data_fs() -> Result<()> {
8381
}
8482

8583
// mount temp dir
86-
if let Err(e) = mount(KSU_MOUNT_SOURCE, TEMP_DIR, "tmpfs", MountFlags::empty(), "") {
87-
warn!("do temp dir mount failed: {}", e);
84+
if !Path::new(NO_TMPFS_PATH).exists() {
85+
if let Err(e) = mount(KSU_MOUNT_SOURCE, TEMP_DIR, "tmpfs", MountFlags::empty(), "") {
86+
warn!("do temp dir mount failed: {}", e);
87+
}
88+
} else {
89+
info!("no tmpfs requested");
8890
}
8991

9092
// exec modules post-fs-data scripts
@@ -99,8 +101,12 @@ pub fn on_post_data_fs() -> Result<()> {
99101
}
100102

101103
// mount module systemlessly by magic mount
102-
if let Err(e) = mount_modules_systemlessly() {
103-
warn!("do systemless mount failed: {e}");
104+
if !Path::new(NO_MOUNT_PATH).exists() {
105+
if let Err(e) = mount_modules_systemlessly() {
106+
warn!("do systemless mount failed: {e}");
107+
}
108+
} else {
109+
info!("no mount requested");
104110
}
105111

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

0 commit comments

Comments
 (0)