mirror of
https://github.com/tiann/KernelSU.git
synced 2025-02-20 11:43:32 +08:00
ksud: e2fsck check image before mount
This commit is contained in:
parent
0a1247b835
commit
279b591200
@ -95,11 +95,8 @@ fn get_minimal_image_size(img: &str) -> Result<u64> {
|
|||||||
Ok(result)
|
Ok(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn grow_image_size(img: &str, extra_size: u64) -> Result<()> {
|
fn check_image(img: &str) -> Result<()> {
|
||||||
let minimal_size = get_minimal_image_size(img)?;
|
// trim image
|
||||||
let target_size = minimal_size + extra_size;
|
|
||||||
|
|
||||||
// trim image
|
|
||||||
let result = Command::new("e2fsck")
|
let result = Command::new("e2fsck")
|
||||||
.args(["-yf", img])
|
.args(["-yf", img])
|
||||||
.stdout(Stdio::null())
|
.stdout(Stdio::null())
|
||||||
@ -107,6 +104,15 @@ fn grow_image_size(img: &str, extra_size: u64) -> Result<()> {
|
|||||||
.status()
|
.status()
|
||||||
.with_context(|| format!("Failed exec e2fsck {}", img))?;
|
.with_context(|| format!("Failed exec e2fsck {}", img))?;
|
||||||
ensure!(result.success(), "f2fsck exec failed.");
|
ensure!(result.success(), "f2fsck exec failed.");
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn grow_image_size(img: &str, extra_size: u64) -> Result<()> {
|
||||||
|
let minimal_size = get_minimal_image_size(img)?;
|
||||||
|
let target_size = minimal_size + extra_size;
|
||||||
|
|
||||||
|
// check image
|
||||||
|
check_image(img)?;
|
||||||
|
|
||||||
let target_size = target_size / 1024 + 1;
|
let target_size = target_size / 1024 + 1;
|
||||||
println!("- Target size: {}K", target_size);
|
println!("- Target size: {}K", target_size);
|
||||||
@ -198,6 +204,8 @@ pub fn install_module(zip: String) -> Result<()> {
|
|||||||
.stderr(subprocess::Redirection::Merge)
|
.stderr(subprocess::Redirection::Merge)
|
||||||
.join()?;
|
.join()?;
|
||||||
ensure!(result.success(), "format ext4 image failed!");
|
ensure!(result.success(), "format ext4 image failed!");
|
||||||
|
|
||||||
|
check_image(tmp_module_img)?;
|
||||||
} else if modules_update_exist {
|
} else if modules_update_exist {
|
||||||
// modules_update.img exists, we should use it as tmp img
|
// modules_update.img exists, we should use it as tmp img
|
||||||
std::fs::copy(modules_update_img, tmp_module_img)?;
|
std::fs::copy(modules_update_img, tmp_module_img)?;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user