Skip to content

df: replace unsafe libc sync with nix crate#11279

Open
mattsu2020 wants to merge 1 commit intouutils:mainfrom
mattsu2020:df_sync
Open

df: replace unsafe libc sync with nix crate#11279
mattsu2020 wants to merge 1 commit intouutils:mainfrom
mattsu2020:df_sync

Conversation

@mattsu2020
Copy link
Contributor

Replace the unsafe libc sync call with the nix crate's sync_filesystems function for safer filesystem synchronization. This change improves code safety by using a well-maintained Rust wrapper instead of direct unsafe libc calls.

Replace the unsafe libc sync call with the nix crate's sync_filesystems function for safer filesystem synchronization. This change improves code safety by using a well-maintained Rust wrapper instead of direct unsafe libc calls.
@mattsu2020 mattsu2020 changed the title refactor(df): replace unsafe libc sync with nix crate df: replace unsafe libc sync with nix crate Mar 10, 2026
@github-actions
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/pr/bounded-memory (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/date/date-locale-hour (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/date/resolution (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/rm/isatty is no longer failing!
Congrats! The gnu test tests/tail/retry is no longer failing!

@xtqqczze
Copy link
Contributor

libc added sync support for android in v0.2.142 (rust-lang/libc@0ba1fc4), so this should be fine.

#[cfg(target_os = "android")]
uucore::libc::syscall(uucore::libc::SYS_sync);
}
sync_filesystems();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
sync_filesystems();
nix::unistd::sync();

fully qualified is more more clear than type alias

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants