Skip to content

Commit 5fbdb8a

Browse files
bors[bot]r-darwish
andcommitted
Merge #961
961: Add sync (fix #959) r=asomers a=r-darwish Co-authored-by: Roey Darwish Dror <roey.ghost@gmail.com>
2 parents bd05d72 + a37f845 commit 5fbdb8a

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
66
## [Unreleased]
77

88
### Added
9+
- Added a `sync` wrapper.
10+
([#961](https://github.com/nix-rust/nix/pull/961))
911
- Added a `sysinfo` wrapper.
1012
([#922](https://github.com/nix-rust/nix/pull/922))
1113
- Support the `SO_PEERCRED` socket option and the `UnixCredentials` type on all Linux and Android targets.

src/unistd.rs

+14
Original file line numberDiff line numberDiff line change
@@ -1101,6 +1101,20 @@ pub fn chroot<P: ?Sized + NixPath>(path: &P) -> Result<()> {
11011101
Errno::result(res).map(drop)
11021102
}
11031103

1104+
/// Commit filesystem caches to disk
1105+
///
1106+
/// See also [sync(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/sync.html)
1107+
#[cfg(any(
1108+
target_os = "dragonfly",
1109+
target_os = "freebsd",
1110+
target_os = "linux",
1111+
target_os = "netbsd",
1112+
target_os = "openbsd"
1113+
))]
1114+
pub fn sync() -> () {
1115+
unsafe { libc::sync() };
1116+
}
1117+
11041118
/// Synchronize changes to a file
11051119
///
11061120
/// See also [fsync(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/fsync.html)

0 commit comments

Comments
 (0)