ksud: don't reclaim when enable/disable modules
This commit is contained in:
10
justfile
Normal file
10
justfile
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
alias bk := build_ksud
|
||||||
|
alias bm := build_manager
|
||||||
|
|
||||||
|
build_ksud:
|
||||||
|
cross build --target aarch64-linux-android --release --manifest-path ./userspace/ksud/Cargo.toml
|
||||||
|
|
||||||
|
build_manager: build_ksud
|
||||||
|
cp userspace/ksud/target/aarch64-linux-android/release/ksud manager/app/src/main/jniLibs/arm64-v8a/libksud.so
|
||||||
|
cd manager && ./gradlew aDebug
|
||||||
|
|
||||||
@@ -475,7 +475,7 @@ pub fn install_module(zip: &str) -> Result<()> {
|
|||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_module<F>(update_dir: &str, id: &str, func: F) -> Result<()>
|
fn update_module<F>(update_dir: &str, id: &str, punch_hole: bool, func: F) -> Result<()>
|
||||||
where
|
where
|
||||||
F: Fn(&str, &str) -> Result<()>,
|
F: Fn(&str, &str) -> Result<()>,
|
||||||
{
|
{
|
||||||
@@ -511,8 +511,10 @@ where
|
|||||||
// call the operation func
|
// call the operation func
|
||||||
let result = func(id, update_dir);
|
let result = func(id, update_dir);
|
||||||
|
|
||||||
if let Err(e) = utils::punch_hole(modules_update_tmp_img) {
|
if punch_hole {
|
||||||
warn!("Failed to punch hole: {}", e);
|
if let Err(e) = utils::punch_hole(modules_update_tmp_img) {
|
||||||
|
warn!("Failed to punch hole: {}", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Err(e) = std::fs::rename(modules_update_tmp_img, defs::MODULE_UPDATE_IMG) {
|
if let Err(e) = std::fs::rename(modules_update_tmp_img, defs::MODULE_UPDATE_IMG) {
|
||||||
@@ -528,7 +530,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn uninstall_module(id: &str) -> Result<()> {
|
pub fn uninstall_module(id: &str) -> Result<()> {
|
||||||
update_module(defs::MODULE_UPDATE_TMP_DIR, id, |mid, update_dir| {
|
update_module(defs::MODULE_UPDATE_TMP_DIR, id, true, |mid, update_dir| {
|
||||||
let dir = Path::new(update_dir);
|
let dir = Path::new(update_dir);
|
||||||
ensure!(dir.exists(), "No module installed");
|
ensure!(dir.exists(), "No module installed");
|
||||||
|
|
||||||
@@ -594,13 +596,13 @@ fn _enable_module(module_dir: &str, mid: &str, enable: bool) -> Result<()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn enable_module(id: &str) -> Result<()> {
|
pub fn enable_module(id: &str) -> Result<()> {
|
||||||
update_module(defs::MODULE_UPDATE_TMP_DIR, id, |mid, update_dir| {
|
update_module(defs::MODULE_UPDATE_TMP_DIR, id, false, |mid, update_dir| {
|
||||||
_enable_module(update_dir, mid, true)
|
_enable_module(update_dir, mid, true)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn disable_module(id: &str) -> Result<()> {
|
pub fn disable_module(id: &str) -> Result<()> {
|
||||||
update_module(defs::MODULE_UPDATE_TMP_DIR, id, |mid, update_dir| {
|
update_module(defs::MODULE_UPDATE_TMP_DIR, id, false, |mid, update_dir| {
|
||||||
_enable_module(update_dir, mid, false)
|
_enable_module(update_dir, mid, false)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -232,6 +232,7 @@ pub fn copy_sparse_file<P: AsRef<Path>, Q: AsRef<Path>>(src: P, dst: Q) -> Resul
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||||
pub fn punch_hole(src: impl AsRef<Path>) -> Result<()> {
|
pub fn punch_hole(src: impl AsRef<Path>) -> Result<()> {
|
||||||
let mut src_file = OpenOptions::new().write(true).read(true).open(src)?;
|
let mut src_file = OpenOptions::new().write(true).read(true).open(src)?;
|
||||||
|
|
||||||
@@ -316,3 +317,8 @@ pub fn punch_hole(src: impl AsRef<Path>) -> Result<()> {
|
|||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(any(target_os = "linux", target_os = "android")))]
|
||||||
|
pub fn punch_hole(src: impl AsRef<Path>) -> Result<()> {
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user