Skip to content

Commit 0a566eb

Browse files
authored
feat: sync APIs for more platforms (#2379)
1 parent 1c2cad8 commit 0a566eb

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

changelog/2379.added.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add `sync(2)` for `apple_targets/solarish/haiku/aix/hurd`, `syncfs(2)` for `hurd` and `fdatasync(2)` for `aix/hurd`

src/unistd.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,7 +1377,7 @@ pub fn chroot<P: ?Sized + NixPath>(path: &P) -> Result<()> {
13771377
/// Commit filesystem caches to disk
13781378
///
13791379
/// See also [sync(2)](https://pubs.opengroup.org/onlinepubs/9699919799/functions/sync.html)
1380-
#[cfg(any(freebsdlike, linux_android, netbsdlike))]
1380+
#[cfg(any(bsd, linux_android, solarish, target_os = "haiku", target_os = "aix", target_os = "hurd"))]
13811381
pub fn sync() {
13821382
unsafe { libc::sync() };
13831383
}
@@ -1386,7 +1386,7 @@ pub fn sync() {
13861386
/// descriptor `fd` to disk
13871387
///
13881388
/// See also [syncfs(2)](https://man7.org/linux/man-pages/man2/sync.2.html)
1389-
#[cfg(linux_android)]
1389+
#[cfg(any(linux_android, target_os = "hurd"))]
13901390
pub fn syncfs(fd: RawFd) -> Result<()> {
13911391
let res = unsafe { libc::syncfs(fd) };
13921392

@@ -1414,6 +1414,8 @@ pub fn fsync(fd: RawFd) -> Result<()> {
14141414
target_os = "freebsd",
14151415
target_os = "emscripten",
14161416
target_os = "fuchsia",
1417+
target_os = "aix",
1418+
target_os = "hurd",
14171419
))]
14181420
#[inline]
14191421
pub fn fdatasync(fd: RawFd) -> Result<()> {

0 commit comments

Comments
 (0)