Skip to content

Commit

Permalink
Auto merge of #3060 - shikhapanwar:sycfs_for_android, r=JohnTitor
Browse files Browse the repository at this point in the history
ANDROID: Add syncfs API in liblibc

This is required to sync everything in a single filesystem. Other solutions like sync() flushes all filesystems which is unnecessary, it is also impractical to call fsync on all files of the filesystem.
  • Loading branch information
bors committed Jan 20, 2023
2 parents 8958df1 + fde1ddf commit ad91645
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1511,6 +1511,7 @@ fn test_android(target: &str) {
t => panic!("unsupported target: {}", t),
};
let x86 = target.contains("i686") || target.contains("x86_64");
let arm = target.contains("arm") || target.contains("aarch64");

let mut cfg = ctest_cfg();
cfg.define("_GNU_SOURCE", None);
Expand Down Expand Up @@ -1813,6 +1814,9 @@ fn test_android(target: &str) {
// Added in API level 28, but some tests use level 24.
"getrandom" => true,

// Added in API level 28, but some tests use level 24.
"syncfs" if arm => true,

_ => false,
}
});
Expand Down
1 change: 1 addition & 0 deletions libc-test/semver/android.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3530,6 +3530,7 @@ swapoff
swapon
symlink
symlinkat
syncfs
syscall
sysconf
sysinfo
Expand Down
2 changes: 2 additions & 0 deletions src/unix/linux_like/android/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3510,6 +3510,8 @@ extern "C" {
longopts: *const option,
longindex: *mut ::c_int,
) -> ::c_int;

pub fn syncfs(fd: ::c_int) -> ::c_int;
}

cfg_if! {
Expand Down

0 comments on commit ad91645

Please sign in to comment.