diff --git a/userspace/ksud/Cargo.lock b/userspace/ksud/Cargo.lock index defc97a4..d09f44d5 100644 --- a/userspace/ksud/Cargo.lock +++ b/userspace/ksud/Cargo.lock @@ -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", diff --git a/userspace/ksud/Cargo.toml b/userspace/ksud/Cargo.toml index 33786366..48347092 100644 --- a/userspace/ksud/Cargo.toml +++ b/userspace/ksud/Cargo.toml @@ -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 = [ diff --git a/userspace/ksud/src/module.rs b/userspace/ksud/src/module.rs index a10ab187..fb7604eb 100644 --- a/userspace/ksud/src/module.rs +++ b/userspace/ksud/src/module.rs @@ -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