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

@@ -21,7 +21,7 @@ use crate::{
defs::{DISABLE_FILE_NAME, KSU_MOUNT_SOURCE, MODULE_DIR, SKIP_MOUNT_FILE_NAME},
magic_mount::NodeFileType::{Directory, RegularFile, Symlink, Whiteout},
restorecon::{lgetfilecon, lsetfilecon},
utils::{ensure_dir_exists, get_work_dir},
utils::get_work_dir,
};
const REPLACE_DIR_XATTR: &str = "trusted.overlay.opaque";
@@ -435,10 +435,10 @@ fn do_magic_mount<P: AsRef<Path>, WP: AsRef<Path>>(
Ok(())
}
pub fn magic_mount() -> Result<()> {
pub fn magic_mount(tmp_path: &String) -> Result<()> {
if let Some(root) = collect_module_files()? {
log::debug!("collected: {:#?}", root);
let tmp_dir = PathBuf::from(get_work_dir());
let tmp_dir = Path::new(tmp_path).join("workdir");
ensure_dir_exists(&tmp_dir)?;
mount(KSU_MOUNT_SOURCE, &tmp_dir, "tmpfs", MountFlags::empty(), "").context("mount tmp")?;
mount_change(&tmp_dir, MountPropagationFlags::PRIVATE).context("make tmp private")?;