summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2018-11-02 15:43:30 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2018-11-02 15:43:30 +0000
commit5fbdb8a15d30d739dd67641ddd7d6c69483b57e7 (patch)
treeb2f1074fa93903b4b5c3db53226d092bdd4a7719
parentbd05d7242799e4b09c612f5059a1b817454aa21a (diff)
parenta37f845ebbea35cefc43f3efbb681c0428ffec78 (diff)
downloadnix-5fbdb8a15d30d739dd67641ddd7d6c69483b57e7.zip
Merge #961
961: Add sync (fix #959) r=asomers a=r-darwish Co-authored-by: Roey Darwish Dror <roey.ghost@gmail.com>
-rw-r--r--CHANGELOG.md2
-rw-r--r--src/unistd.rs14
2 files changed, 16 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index dd76763d..6688c8f8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -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.
diff --git a/src/unistd.rs b/src/unistd.rs
index c9c129c9..aadd3c6b 100644
--- a/src/unistd.rs
+++ b/src/unistd.rs
@@ -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)