diff options
author | Roey Darwish Dror <roey.ghost@gmail.com> | 2018-11-01 22:05:34 +0200 |
---|---|---|
committer | Roey Darwish Dror <roey.ghost@gmail.com> | 2018-11-02 16:23:13 +0200 |
commit | a37f845ebbea35cefc43f3efbb681c0428ffec78 (patch) | |
tree | b2f1074fa93903b4b5c3db53226d092bdd4a7719 /src/unistd.rs | |
parent | bd05d7242799e4b09c612f5059a1b817454aa21a (diff) | |
download | nix-a37f845ebbea35cefc43f3efbb681c0428ffec78.zip |
Add sync (fix #959)
Diffstat (limited to 'src/unistd.rs')
-rw-r--r-- | src/unistd.rs | 14 |
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) |