ksud: refine mount

- `magic_mount` now takes the tmp_path from its argument
- `.notmpfs` and `.nomount` now behave the same

skip:
ksud: cache tmp path (74ce44de21963fddc83897846eed28eca89d78aa)

Co-authored-by: shatyuka <shatyuka@qq.com>
Signed-off-by: Faris <rsuntk@yukiprjkt.my.id>
This commit is contained in:
5ec1cff
2025-10-19 03:00:52 +07:00
committed by ShirkNeko
parent cc0a3590ce
commit b1564b77a2
3 changed files with 16 additions and 15 deletions

View File

@@ -7,6 +7,7 @@ use crate::{
module::{handle_updated_modules, prune_modules},
restorecon, uid_scanner, utils,
};
use crate::utils::find_tmp_path;
use anyhow::{Context, Result};
use log::{info, warn};
use rustix::fs::{MountFlags, mount};
@@ -86,11 +87,15 @@ pub fn on_post_data_fs() -> Result<()> {
warn!("KPM: Failed to load KPM modules: {}", e);
}
let tmpfs_path = find_tmp_path();
// for compatibility
let no_mount = Path::new(NO_TMPFS_PATH).exists() || Path::new(NO_MOUNT_PATH).exists();
// mount temp dir
if !Path::new(NO_TMPFS_PATH).exists() {
if !no_mount {
if let Err(e) = mount(
KSU_MOUNT_SOURCE,
utils::get_tmp_path(),
&tmpfs_path,
"tmpfs",
MountFlags::empty(),
"",
@@ -113,9 +118,10 @@ pub fn on_post_data_fs() -> Result<()> {
}
// mount module systemlessly by magic mount
if !Path::new(NO_MOUNT_PATH).exists() {
if let Err(e) = mount_modules_systemlessly() {
warn!("do systemless mount failed: {}", e);
#[cfg(target_os = "android")]
if !no_mount {
if let Err(e) = crate::magic_mount::magic_mount(&tmpfs_path) {
warn!("do systemless mount failed: {e}");
}
} else {
info!("no mount requested");
@@ -148,7 +154,7 @@ pub fn on_post_data_fs() -> Result<()> {
#[cfg(target_os = "android")]
pub fn mount_modules_systemlessly() -> Result<()> {
crate::magic_mount::magic_mount()
crate::magic_mount::magic_mount(&find_tmp_path())
}
#[cfg(not(target_os = "android"))]