Skip to content

Commit

Permalink
Merge #961
Browse files Browse the repository at this point in the history
961: Add sync (fix #959) r=asomers a=r-darwish



Co-authored-by: Roey Darwish Dror <roey.ghost@gmail.com>
  • Loading branch information
bors[bot] and r-darwish committed Nov 2, 2018
2 parents bd05d72 + a37f845 commit 5fbdb8a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -6,6 +6,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
## [Unreleased]

### Added
- Added a `sync` wrapper.
([#961](https://github.com/nix-rust/nix/pull/961))
- Added a `sysinfo` wrapper.
([#922](https://github.com/nix-rust/nix/pull/922))
- Support the `SO_PEERCRED` socket option and the `UnixCredentials` type on all Linux and Android targets.
Expand Down
14 changes: 14 additions & 0 deletions src/unistd.rs
Expand Up @@ -1101,6 +1101,20 @@ pub fn chroot<P: ?Sized + NixPath>(path: &P) -> Result<()> {
Errno::result(res).map(drop)
}

/// Commit filesystem caches to disk
///
/// See also [sync(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/sync.html)
#[cfg(any(
target_os = "dragonfly",
target_os = "freebsd",
target_os = "linux",
target_os = "netbsd",
target_os = "openbsd"
))]
pub fn sync() -> () {
unsafe { libc::sync() };
}

/// Synchronize changes to a file
///
/// See also [fsync(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/fsync.html)
Expand Down

0 comments on commit 5fbdb8a

Please sign in to comment.