Skip to content

Commit

Permalink
ksud: make tmpfs and magic mount optional
Browse files Browse the repository at this point in the history
- Create /data/adb/ksu/{.notmpfs,.nomount} to disable them.
  • Loading branch information
5ec1cff authored and selfmusing committed Feb 4, 2025
1 parent 8b42690 commit fb4982d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
3 changes: 3 additions & 0 deletions userspace/ksud/src/defs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,6 @@ pub const VERSION_NAME: &str = include_str!(concat!(env!("OUT_DIR"), "/VERSION_N
pub const KSU_BACKUP_DIR: &str = WORKING_DIR;
pub const KSU_BACKUP_FILE_PREFIX: &str = "ksu_backup_";
pub const BACKUP_FILENAME: &str = "stock_image.sha1";

pub const NO_TMPFS_PATH: &str = concatcp!(WORKING_DIR, ".notmpfs");
pub const NO_MOUNT_PATH: &str = concatcp!(WORKING_DIR, ".nomount");
18 changes: 13 additions & 5 deletions userspace/ksud/src/init_event.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::defs::{KSU_MOUNT_SOURCE, TEMP_DIR};
use crate::defs::{KSU_MOUNT_SOURCE, NO_MOUNT_PATH, NO_TMPFS_PATH, TEMP_DIR};
use crate::module::{handle_updated_modules, prune_modules};
use crate::{assets, defs, ksucalls, restorecon, utils};
use anyhow::{Context, Result};
Expand Down Expand Up @@ -68,8 +68,12 @@ pub fn on_post_data_fs() -> Result<()> {
}

// mount temp dir
if let Err(e) = mount(KSU_MOUNT_SOURCE, TEMP_DIR, "tmpfs", MountFlags::empty(), "") {
warn!("do temp dir mount failed: {}", e);
if !Path::new(NO_TMPFS_PATH).exists() {
if let Err(e) = mount(KSU_MOUNT_SOURCE, TEMP_DIR, "tmpfs", MountFlags::empty(), "") {
warn!("do temp dir mount failed: {}", e);
}
} else {
info!("no tmpfs requested");
}

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

// mount module systemlessly by magic mount
if let Err(e) = mount_modules_systemlessly() {
warn!("do systemless mount failed: {}", e);
if !Path::new(NO_MOUNT_PATH).exists() {
if let Err(e) = mount_modules_systemlessly() {
warn!("do systemless mount failed: {}", e);
}
} else {
info!("no mount requested");
}

run_stage("post-mount", true);
Expand Down

0 comments on commit fb4982d

Please sign in to comment.