diff --git a/userspace/ksud/src/cli.rs b/userspace/ksud/src/cli.rs index dde5f986..86483398 100644 --- a/userspace/ksud/src/cli.rs +++ b/userspace/ksud/src/cli.rs @@ -186,16 +186,6 @@ enum Module { /// Shrink module image size Shrink, - - /// Link modules for manager - LinkManager { - /// module id - mid: String, - /// Manager's pid - pid: i32, - /// Manager's package name - pkg: String, - }, } #[derive(clap::Subcommand, Debug)] @@ -276,9 +266,6 @@ pub fn run() -> Result<()> { Module::Disable { id } => module::disable_module(&id), Module::List => module::list_modules(), Module::Shrink => module::shrink_ksu_images(), - Module::LinkManager { mid, pid, pkg } => { - module::link_module_for_manager(pid, &pkg, &mid) - } } } Commands::Install => event::install(), diff --git a/userspace/ksud/src/ksu.rs b/userspace/ksud/src/ksu.rs index 30f9aa55..5570d77f 100644 --- a/userspace/ksud/src/ksu.rs +++ b/userspace/ksud/src/ksu.rs @@ -53,7 +53,7 @@ pub fn grant_root(global_mnt: bool) -> Result<()> { } #[cfg(not(any(target_os = "linux", target_os = "android")))] -pub fn grant_root() -> Result<()> { +pub fn grant_root(_global_mnt: bool) -> Result<()> { unimplemented!("grant_root is only available on android"); } diff --git a/userspace/ksud/src/module.rs b/userspace/ksud/src/module.rs index f34850be..70822f76 100644 --- a/userspace/ksud/src/module.rs +++ b/userspace/ksud/src/module.rs @@ -11,8 +11,6 @@ use const_format::concatcp; use is_executable::is_executable; use java_properties::PropertiesIter; use log::{info, warn}; -#[cfg(any(target_os = "linux", target_os = "android"))] -use rustix::{fd::AsFd, fs::CWD, mount::*}; use std::{ collections::HashMap, @@ -706,60 +704,3 @@ pub fn shrink_ksu_images() -> Result<()> { } Ok(()) } - -#[cfg(any(target_os = "linux", target_os = "android"))] -pub fn link_module_for_manager(pid: i32, pkg: &str, mid: &str) -> Result<()> { - let from = PathBuf::from(defs::MODULE_DIR) - .join(mid) - .join(defs::MODULE_WEB_DIR); - - let to = PathBuf::from("/data/data").join(pkg).join("webroot"); - - if let Result::Ok(tree) = open_tree( - rustix::fs::CWD, - &from, - OpenTreeFlags::OPEN_TREE_CLOEXEC - | OpenTreeFlags::OPEN_TREE_CLONE - | OpenTreeFlags::AT_RECURSIVE, - ) { - switch_mnt_ns(pid)?; - - // umount previous mount - let _ = mount::umount_dir(&to); - - if let Err(e) = move_mount( - tree.as_fd(), - "", - CWD, - &to, - MoveMountFlags::MOVE_MOUNT_F_EMPTY_PATH, - ) { - log::error!("move_mount failed: {}", e); - } - } else { - log::info!("fallback to bind mount"); - // switch to manager's mnt ns - utils::switch_mnt_ns(pid)?; - if !Path::new(&from).exists() { - // maybe it is umounted, mount it back - log::info!("module web dir not exists, try to mount it back."); - mount::AutoMountExt4::try_new(defs::MODULE_IMG, defs::MODULE_DIR, false) - .with_context(|| "mount module image failed".to_string())?; - } - - // umount previous mount - let _ = mount::umount_dir(&to); - - if let Err(e) = rustix::mount::mount(&from, &to, "", MountFlags::BIND | MountFlags::REC, "") - { - log::error!("mount failed: {}", e); - } - } - - Ok(()) -} - -#[cfg(not(any(target_os = "linux", target_os = "android")))] -pub fn link_module_for_manager(_pid: i32, _pkg: &str, _mid: &str) -> Result<()> { - unimplemented!() -}