ksud: determine modules's size by checking partion size

This commit is contained in:
weishu 2025-02-17 21:05:13 +08:00
parent 4ede20ef83
commit 38dc2eb4f0
3 changed files with 15 additions and 2 deletions

View File

@ -1,6 +1,6 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
version = 4
[[package]]
name = "addr2line"
@ -591,6 +591,16 @@ dependencies = [
"miniz_oxide",
]
[[package]]
name = "fs4"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c29c30684418547d476f0b48e84f4821639119c483b1eccd566c8cd0cd05f521"
dependencies = [
"rustix 0.38.41",
"windows-sys 0.52.0",
]
[[package]]
name = "generic-array"
version = "0.14.7"
@ -806,6 +816,7 @@ dependencies = [
"encoding_rs",
"env_logger",
"extattr",
"fs4",
"getopts",
"hole-punch",
"humansize",

View File

@ -43,6 +43,7 @@ tempfile = "3.14"
chrono = "0.4"
hole-punch = { git = "https://github.com/tiann/hole-punch" }
regex-lite = "0.1"
fs4 = "0.12"
[target.'cfg(any(target_os = "android", target_os = "linux"))'.dependencies]
rustix = { git = "https://github.com/Kernel-SU/rustix.git", branch = "main", features = [

View File

@ -375,7 +375,8 @@ fn _install_module(zip: &str) -> Result<()> {
humansize::format_size(zip_uncompressed_size, humansize::DECIMAL)
);
let sparse_image_size = 1 << 40; // 1T
let data_vfs = fs4::statvfs("/data").with_context(|| "Failed to stat /data".to_string())?;
let sparse_image_size = data_vfs.total_space();
if !modules_img_exist && !modules_update_img_exist {
// if no modules and modules_update, it is brand new installation, we should create a new img
// create a tmp module img and mount it to modules_update