diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2022-10-08 19:51:23 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-08 19:51:23 +0000 |
commit | 0eebf193fb7dbd1bb894bf5e607aa5c1454ebc0a (patch) | |
tree | aa208a3e16f7eaa3b81d918b0a5db3251175d5e2 | |
parent | 8341e4ff15ca3b3e9d77cc7546bbb36e43337e77 (diff) | |
parent | e7992231a34963a57d2297fe1ea7cdaf090efa8b (diff) | |
download | nix-0eebf193fb7dbd1bb894bf5e607aa5c1454ebc0a.zip |
Merge #1833
1833: add syncfs on linux r=rtzoeller a=SteveLauC
Fixes #1818
Change has not been added to `CHANGELOG.md`, will add it when #1831 is merged, or there will be a merge conflict
Co-authored-by: Steve Lau <stevelauc@outlook.com>
-rw-r--r-- | CHANGELOG.md | 2 | ||||
-rw-r--r-- | src/unistd.rs | 11 |
2 files changed, 13 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 080ea0e7..8678e3ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,8 @@ This project adheres to [Semantic Versioning](https://semver.org/). ([#1817](https://github.com/nix-rust/nix/pull/1817)) - Re-export `RLIM_INFINITY` from `libc` ([#1831](https://github.com/nix-rust/nix/pull/1831)) +- Added `syncfs(2)` on Linux + ([#1833](https://github.com/nix-rust/nix/pull/1833)) ### Changed diff --git a/src/unistd.rs b/src/unistd.rs index e7a64dab..daa76b74 100644 --- a/src/unistd.rs +++ b/src/unistd.rs @@ -1354,6 +1354,17 @@ pub fn sync() { unsafe { libc::sync() }; } +/// Commit filesystem caches containing file referred to by the open file +/// descriptor `fd` to disk +/// +/// See also [syncfs(2)](https://man7.org/linux/man-pages/man2/sync.2.html) +#[cfg(target_os = "linux")] +pub fn syncfs(fd: RawFd) -> Result<()> { + let res = unsafe { libc::syncfs(fd) }; + + Errno::result(res).map(drop) +} + /// Synchronize changes to a file /// /// See also [fsync(2)](https://pubs.opengroup.org/onlinepubs/9699919799/functions/fsync.html) |