Mount temp dir at /debug_ramdisk (#1226)
This commit is contained in:
@@ -569,6 +569,7 @@ int ksu_handle_setuid(struct cred *new, const struct cred *old)
|
|||||||
try_umount("/vendor", true, 0);
|
try_umount("/vendor", true, 0);
|
||||||
try_umount("/product", true, 0);
|
try_umount("/product", true, 0);
|
||||||
try_umount("/data/adb/modules", false, MNT_DETACH);
|
try_umount("/data/adb/modules", false, MNT_DETACH);
|
||||||
|
try_umount("/debug_ramdisk", false, MNT_DETACH);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ pub const MODULE_UPDATE_TMP_IMG: &str = concatcp!(WORKING_DIR, "update_tmp.img")
|
|||||||
// warning: this directory should not change, or you need to change the code in module_installer.sh!!!
|
// warning: this directory should not change, or you need to change the code in module_installer.sh!!!
|
||||||
pub const MODULE_UPDATE_TMP_DIR: &str = concatcp!(ADB_DIR, "modules_update/");
|
pub const MODULE_UPDATE_TMP_DIR: &str = concatcp!(ADB_DIR, "modules_update/");
|
||||||
|
|
||||||
|
pub const TEMP_DIR: &str = "/debug_ramdisk/";
|
||||||
|
|
||||||
pub const DISABLE_FILE_NAME: &str = "disable";
|
pub const DISABLE_FILE_NAME: &str = "disable";
|
||||||
pub const UPDATE_FILE_NAME: &str = "update";
|
pub const UPDATE_FILE_NAME: &str = "update";
|
||||||
pub const REMOVE_FILE_NAME: &str = "remove";
|
pub const REMOVE_FILE_NAME: &str = "remove";
|
||||||
|
|||||||
@@ -194,6 +194,11 @@ pub fn on_post_data_fs() -> Result<()> {
|
|||||||
warn!("do systemless mount failed: {}", e);
|
warn!("do systemless mount failed: {}", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// mount temp dir
|
||||||
|
if let Err(e) = mount::mount_tmpfs(defs::TEMP_DIR) {
|
||||||
|
warn!("do temp dir mount failed: {}", e);
|
||||||
|
}
|
||||||
|
|
||||||
run_stage("post-mount", true);
|
run_stage("post-mount", true);
|
||||||
|
|
||||||
std::env::set_current_dir("/").with_context(|| "failed to chdir to /")?;
|
std::env::set_current_dir("/").with_context(|| "failed to chdir to /")?;
|
||||||
|
|||||||
@@ -161,6 +161,16 @@ fn mount_overlayfs(
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||||
|
pub fn mount_tmpfs(dest: impl AsRef<Path>) -> Result<()> {
|
||||||
|
info!("mount tmpfs on {}", dest.as_ref().display());
|
||||||
|
Mount::builder()
|
||||||
|
.fstype(FilesystemType::from("tmpfs"))
|
||||||
|
.mount(KSU_OVERLAY_SOURCE, dest.as_ref())
|
||||||
|
.with_context(|| format!("mount tmpfs on {} failed", dest.as_ref().display()))?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||||
fn bind_mount(from: impl AsRef<Path>, to: impl AsRef<Path>) -> Result<()> {
|
fn bind_mount(from: impl AsRef<Path>, to: impl AsRef<Path>) -> Result<()> {
|
||||||
info!(
|
info!(
|
||||||
@@ -276,3 +286,8 @@ pub fn umount_dir(_src: &str) -> Result<()> {
|
|||||||
pub fn mount_overlay(_dest: &String, _lower_dirs: &Vec<String>) -> Result<()> {
|
pub fn mount_overlay(_dest: &String, _lower_dirs: &Vec<String>) -> Result<()> {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(any(target_os = "linux", target_os = "android")))]
|
||||||
|
pub fn mount_tmpfs(_dest: impl AsRef<Path>) -> Result<()> {
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user