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 /src/unistd.rs | |
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>
Diffstat (limited to 'src/unistd.rs')
-rw-r--r-- | src/unistd.rs | 11 |
1 files changed, 11 insertions, 0 deletions
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) |