Skip to content

Commit

Permalink
add syncfs on linux
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveLauC committed Oct 5, 2022
1 parent 76f04df commit d514ab2
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/unistd.rs
Expand Up @@ -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)
Expand Down

0 comments on commit d514ab2

Please sign in to comment.