From 86d2af6ca0dd770f9e1c87e431e3d6af7830cf0a Mon Sep 17 00:00:00 2001 From: Wildan M Date: Tue, 16 Dec 2025 05:27:09 +0700 Subject: [PATCH] Expose custom mount API and bump version --- Cargo.lock | 33 +++++++++++++++++++++++++----- Cargo.toml | 2 +- src/bin/installer_tui.rs | 2 +- src/installer.rs | 43 +++++++++++++++++++++++++--------------- 4 files changed, 57 insertions(+), 23 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 830d753382..d37534fa5e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -952,6 +952,15 @@ version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" +[[package]] +name = "humansize" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6cb51c9a029ddc91b07a787f1d86b53ccfa49b0e86688c946ebe8d3555685dd7" +dependencies = [ + "libm", +] + [[package]] name = "hyper" version = "1.7.0" @@ -1278,6 +1287,12 @@ version = "0.2.176" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "58f929b4d672ea937a23a1ab494143d968337a5f47e56d0815df1e0890ddf174" +[[package]] +name = "libm" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9fbbcab51052fe104eb5e5d351cf728d30a5be1fe14d9be8a3b097481fb97de" + [[package]] name = "libredox" version = "0.1.10" @@ -1408,6 +1423,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "parse-size" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "487f2ccd1e17ce8c1bfab3a65c89525af41cfad4c8659021a1e9a2aacd73b89b" + [[package]] name = "percent-encoding" version = "2.3.2" @@ -1578,7 +1599,7 @@ dependencies = [ "once_cell", "socket2", "tracing", - "windows-sys 0.60.2", + "windows-sys 0.52.0", ] [[package]] @@ -1697,7 +1718,7 @@ dependencies = [ [[package]] name = "redox_installer" -version = "0.2.37" +version = "0.2.38" dependencies = [ "anyhow", "arg_parser", @@ -1749,9 +1770,9 @@ dependencies = [ [[package]] name = "redoxfs" -version = "0.8.0" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "063eedabd74ddf71810e72aae1c73f3485ffc7b1e757d9466b9099046c05d7be" +checksum = "da25f807d736d169077c076bc44837ef250257680a91efedda6891474735a833" dependencies = [ "aes", "argon2", @@ -1761,10 +1782,12 @@ dependencies = [ "env_logger", "fuser", "getrandom 0.2.16", + "humansize", "libc", "libredox", "log", "lz4_flex", + "parse-size", "range-tree", "redox-path", "redox-scheme", @@ -2644,7 +2667,7 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" dependencies = [ - "windows-sys 0.60.2", + "windows-sys 0.52.0", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 0433fb0471..3416871ff7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "redox_installer" -version = "0.2.37" +version = "0.2.38" description = "A Redox filesystem builder" license = "MIT" authors = ["Jeremy Soller "] diff --git a/src/bin/installer_tui.rs b/src/bin/installer_tui.rs index af36648546..e9a2774f8e 100644 --- a/src/bin/installer_tui.rs +++ b/src/bin/installer_tui.rs @@ -338,7 +338,7 @@ fn main() { } // Slow install method via file copy - with_redoxfs_mount(fs, |mount_path| { + with_redoxfs_mount(fs, None, |mount_path| { let mut config: Config = Config::from_file(&root_path.join("filesystem.toml"))?; // Copy filesystem.toml, which is not packaged diff --git a/src/installer.rs b/src/installer.rs index 28d449d72d..727d8862ba 100644 --- a/src/installer.rs +++ b/src/installer.rs @@ -356,18 +356,29 @@ where callback(fs) } -pub fn with_redoxfs_mount(fs: FileSystem, callback: F) -> Result +fn decide_mount_path(mount_path: Option<&Path>) -> PathBuf { + let mount_path = mount_path.map(|p| p.to_path_buf()).unwrap_or_else(|| { + PathBuf::from(if cfg!(target_os = "redox") { + format!("file.redox_installer_{}", process::id()) + } else { + format!("/tmp/redox_installer_{}", process::id()) + }) + }); + mount_path +} + +pub fn with_redoxfs_mount( + fs: FileSystem, + mount_path: Option<&Path>, + callback: F, +) -> Result where D: Disk + Send + 'static, F: FnOnce(&Path) -> Result, { - let mount_path = if cfg!(target_os = "redox") { - format!("file.redox_installer_{}", process::id()) - } else { - format!("/tmp/redox_installer_{}", process::id()) - }; + let mount_path = decide_mount_path(mount_path); - if cfg!(not(target_os = "redox")) && !Path::new(&mount_path).exists() { + if cfg!(not(target_os = "redox")) && !mount_path.exists() { fs::create_dir(&mount_path)?; } @@ -401,7 +412,7 @@ where } }; - unmount_path(&mount_path)?; + unmount_path(&mount_path.as_os_str().to_str().unwrap())?; join_handle.join().unwrap(); @@ -412,16 +423,16 @@ where res } -pub fn with_redoxfs_ar(mut fs: FileSystem, callback: F) -> Result +pub fn with_redoxfs_ar( + mut fs: FileSystem, + mount_path: Option<&Path>, + callback: F, +) -> Result where D: Disk + Send + 'static, F: FnOnce(&Path) -> Result, { - let mount_path = if cfg!(target_os = "redox") { - format!("file.redox_installer_{}", process::id()) - } else { - format!("/tmp/redox_installer_{}", process::id()) - }; + let mount_path = decide_mount_path(mount_path); let res = callback(Path::new(&mount_path)); @@ -828,11 +839,11 @@ fn install_inner(config: Config, output: &Path) -> Result<()> { }; with_whole_disk(output, &disk_option, move |fs| { if config.general.no_mount.unwrap_or(false) { - with_redoxfs_ar(fs, move |mount_path| { + with_redoxfs_ar(fs, None, move |mount_path| { install_dir(config, mount_path, cookbook) }) } else { - with_redoxfs_mount(fs, move |mount_path| { + with_redoxfs_mount(fs, None, move |mount_path| { install_dir(config, mount_path, cookbook) }) }