diff --git a/Cargo.lock b/Cargo.lock index 62277a370f8..20cc053047c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3367,6 +3367,7 @@ dependencies = [ "clap", "codspeed-divan-compat", "fluent", + "nix", "tempfile", "thiserror 2.0.18", "unicode-width 0.2.2", diff --git a/src/uu/df/Cargo.toml b/src/uu/df/Cargo.toml index 48b793145e0..9b99baa9287 100644 --- a/src/uu/df/Cargo.toml +++ b/src/uu/df/Cargo.toml @@ -25,6 +25,9 @@ unicode-width = { workspace = true } thiserror = { workspace = true } fluent = { workspace = true } +[target.'cfg(unix)'.dependencies] +nix = { workspace = true, features = ["fs"] } + [dev-dependencies] divan = { workspace = true } tempfile = { workspace = true } diff --git a/src/uu/df/src/df.rs b/src/uu/df/src/df.rs index e0133805f97..51b950dd460 100644 --- a/src/uu/df/src/df.rs +++ b/src/uu/df/src/df.rs @@ -301,12 +301,7 @@ fn get_all_filesystems(opt: &Options) -> UResult> { // Run a sync call before any operation if so instructed. if opt.sync { #[cfg(not(any(windows, target_os = "redox")))] - unsafe { - #[cfg(not(target_os = "android"))] - uucore::libc::sync(); - #[cfg(target_os = "android")] - uucore::libc::syscall(uucore::libc::SYS_sync); - } + nix::unistd::sync(); } let mut mounts = vec![];