ksud: probe for more workdir candidates (#12)

- reuses old ksu functions
- makes sure its an empty dir
- adapted from https://github.com/rsuntk/KernelSU/commit/141f010 71cb86c2e9

Co-authored-by: powellnorma <101364699+powellnorma@users.noreply.github.com>
Co-authored-by: Rissu <90097027+rsuntk@users.noreply.github.com>
This commit is contained in:
backslashxx
2025-03-09 17:00:03 +08:00
committed by GitHub
parent 9ff996b805
commit b28789ac7a
4 changed files with 38 additions and 8 deletions

View File

@@ -1,9 +1,9 @@
use crate::defs::{
DISABLE_FILE_NAME, KSU_MOUNT_SOURCE, MAGIC_MOUNT_WORK_DIR, MODULE_DIR, SKIP_MOUNT_FILE_NAME,
DISABLE_FILE_NAME, KSU_MOUNT_SOURCE, MODULE_DIR, SKIP_MOUNT_FILE_NAME,
};
use crate::magic_mount::NodeFileType::{Directory, RegularFile, Symlink, Whiteout};
use crate::restorecon::{lgetfilecon, lsetfilecon};
use crate::utils::ensure_dir_exists;
use crate::utils::{ensure_dir_exists, get_work_dir};
use anyhow::{Context, Result, bail};
use extattr::lgetxattr;
use rustix::fs::{
@@ -417,7 +417,7 @@ fn do_magic_mount<P: AsRef<Path>, WP: AsRef<Path>>(
pub fn magic_mount() -> Result<()> {
if let Some(root) = collect_module_files()? {
log::debug!("collected: {:#?}", root);
let tmp_dir = PathBuf::from(MAGIC_MOUNT_WORK_DIR);
let tmp_dir = PathBuf::from(get_work_dir());
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")?;