Skip to content

Commit

Permalink
feat: sync APIs for more platforms (#2379)
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveLauC committed Apr 21, 2024
1 parent 1c2cad8 commit 0a566eb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions changelog/2379.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add `sync(2)` for `apple_targets/solarish/haiku/aix/hurd`, `syncfs(2)` for `hurd` and `fdatasync(2)` for `aix/hurd`
6 changes: 4 additions & 2 deletions src/unistd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1377,7 +1377,7 @@ pub fn chroot<P: ?Sized + NixPath>(path: &P) -> Result<()> {
/// Commit filesystem caches to disk
///
/// See also [sync(2)](https://pubs.opengroup.org/onlinepubs/9699919799/functions/sync.html)
#[cfg(any(freebsdlike, linux_android, netbsdlike))]
#[cfg(any(bsd, linux_android, solarish, target_os = "haiku", target_os = "aix", target_os = "hurd"))]
pub fn sync() {
unsafe { libc::sync() };
}
Expand All @@ -1386,7 +1386,7 @@ pub fn sync() {
/// descriptor `fd` to disk
///
/// See also [syncfs(2)](https://man7.org/linux/man-pages/man2/sync.2.html)
#[cfg(linux_android)]
#[cfg(any(linux_android, target_os = "hurd"))]
pub fn syncfs(fd: RawFd) -> Result<()> {
let res = unsafe { libc::syncfs(fd) };

Expand Down Expand Up @@ -1414,6 +1414,8 @@ pub fn fsync(fd: RawFd) -> Result<()> {
target_os = "freebsd",
target_os = "emscripten",
target_os = "fuchsia",
target_os = "aix",
target_os = "hurd",
))]
#[inline]
pub fn fdatasync(fd: RawFd) -> Result<()> {
Expand Down

0 comments on commit 0a566eb

Please sign in to comment.