Skip to content

Commit

Permalink
Add sync (fix #959)
Browse files Browse the repository at this point in the history
  • Loading branch information
r-darwish committed Nov 2, 2018
1 parent bd05d72 commit a37f845
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 a37f845

Please sign in to comment.