summaryrefslogtreecommitdiff
path: root/src/unistd.rs
diff options
context:
space:
mode:
authorRoey Darwish Dror <roey.ghost@gmail.com>2018-11-01 22:05:34 +0200
committerRoey Darwish Dror <roey.ghost@gmail.com>2018-11-02 16:23:13 +0200
commita37f845ebbea35cefc43f3efbb681c0428ffec78 (patch)
treeb2f1074fa93903b4b5c3db53226d092bdd4a7719 /src/unistd.rs
parentbd05d7242799e4b09c612f5059a1b817454aa21a (diff)
downloadnix-a37f845ebbea35cefc43f3efbb681c0428ffec78.zip
Add sync (fix #959)
Diffstat (limited to 'src/unistd.rs')
-rw-r--r--src/unistd.rs14
1 files changed, 14 insertions, 0 deletions
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)