diff --git a/Cargo.lock b/Cargo.lock index df6843364331a..91ae9ab422c3e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2557,6 +2557,17 @@ dependencies = [ "winapi", ] +[[package]] +name = "fs4" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ea55201cc351fdb478217c0fb641b59813da9b4efe4c414a9d8f989a657d149" +dependencies = [ + "libc", + "rustix 0.35.13", + "winapi", +] + [[package]] name = "fs_extra" version = "1.3.0" @@ -3282,6 +3293,12 @@ dependencies = [ "webrtc-util", ] +[[package]] +name = "io-lifetimes" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59ce5ef949d49ee85593fc4d3f3f95ad61657076395cbbce23e2121fc5542074" + [[package]] name = "io-lifetimes" version = "1.0.5" @@ -3323,8 +3340,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22e18b0a45d56fe973d6db23972bf5bc46f988a4a2385deac9cc29572f09daef" dependencies = [ "hermit-abi 0.3.0", - "io-lifetimes", - "rustix", + "io-lifetimes 1.0.5", + "rustix 0.36.8", "windows-sys 0.45.0", ] @@ -4222,6 +4239,12 @@ dependencies = [ "nalgebra", ] +[[package]] +name = "linux-raw-sys" +version = "0.0.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4d2456c373231a208ad294c33dc5bff30051eafd954cd4caae83a712b12854d" + [[package]] name = "linux-raw-sys" version = "0.1.4" @@ -4372,7 +4395,7 @@ version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b20a59d985586e4a5aef64564ac77299f8586d8be6cf9106a5a40207e8908efb" dependencies = [ - "rustix", + "rustix 0.36.8", ] [[package]] @@ -7830,6 +7853,20 @@ dependencies = [ "nom", ] +[[package]] +name = "rustix" +version = "0.35.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "727a1a6d65f786ec22df8a81ca3121107f235970dc1705ed681d3e6e8b9cd5f9" +dependencies = [ + "bitflags", + "errno", + "io-lifetimes 0.7.5", + "libc", + "linux-raw-sys 0.0.46", + "windows-sys 0.42.0", +] + [[package]] name = "rustix" version = "0.36.8" @@ -7838,9 +7875,9 @@ checksum = "f43abb88211988493c1abb44a70efa56ff0ce98f233b7b276146f1f3f7ba9644" dependencies = [ "bitflags", "errno", - "io-lifetimes", + "io-lifetimes 1.0.5", "libc", - "linux-raw-sys", + "linux-raw-sys 0.1.4", "windows-sys 0.45.0", ] @@ -8538,7 +8575,7 @@ dependencies = [ "once_cell", "parity-scale-codec", "paste", - "rustix", + "rustix 0.36.8", "sc-allocator", "sc-executor-common", "sc-runtime-test", @@ -9098,9 +9135,9 @@ name = "sc-storage-monitor" version = "0.1.0" dependencies = [ "clap 4.1.4", + "fs4", "futures", "log", - "nix 0.26.2", "sc-client-db", "sc-utils", "sp-core", @@ -12055,7 +12092,7 @@ dependencies = [ "directories-next", "file-per-thread-logger", "log", - "rustix", + "rustix 0.36.8", "serde", "sha2 0.10.6", "toml", @@ -12135,7 +12172,7 @@ checksum = "f76ef2e410329aaf8555ac6571d6fe07711be0646dcdf7ff3ab750a42ed2e583" dependencies = [ "object 0.29.0", "once_cell", - "rustix", + "rustix 0.36.8", ] [[package]] @@ -12166,7 +12203,7 @@ dependencies = [ "memoffset 0.6.5", "paste", "rand 0.8.5", - "rustix", + "rustix 0.36.8", "wasmtime-asm-macros", "wasmtime-environ", "wasmtime-jit-debug", diff --git a/client/storage-monitor/src/lib.rs b/client/storage-monitor/src/lib.rs index 94c0cc14eb58b..277a74de08baf 100644 --- a/client/storage-monitor/src/lib.rs +++ b/client/storage-monitor/src/lib.rs @@ -17,7 +17,6 @@ // along with this program. If not, see . use clap::Args; -use fs4::statvfs; use sc_client_db::DatabaseSource; use sp_core::traits::SpawnEssentialNamed; use std::{ @@ -118,8 +117,7 @@ impl StorageMonitorService { /// Returns free space in MB, or error if statvfs failed. fn free_space(path: &Path) -> Result { - let amount = statvfs(path)?; - Ok(amount.available_space() / (1024 * 1024)) + Ok(fs4::available_space(path).map(|s| s / 1_000_000)?) } /// Checks if the amount of free space for given `path` is above given `threshold`.