diff options
-rw-r--r-- | libc/SECCOMP_WHITELIST.TXT | 3 | ||||
-rw-r--r-- | libc/SYSCALLS.TXT | 1 | ||||
-rw-r--r-- | libc/arch-arm/syscalls/syncfs.S | 16 | ||||
-rw-r--r-- | libc/arch-arm64/syscalls/syncfs.S | 14 | ||||
-rw-r--r-- | libc/arch-mips/syscalls/syncfs.S | 19 | ||||
-rw-r--r-- | libc/arch-mips64/syscalls/syncfs.S | 25 | ||||
-rw-r--r-- | libc/arch-x86/syscalls/syncfs.S | 29 | ||||
-rw-r--r-- | libc/arch-x86_64/syscalls/syncfs.S | 15 | ||||
-rw-r--r-- | libc/include/unistd.h | 3 | ||||
-rw-r--r-- | libc/libc.arm.map | 7 | ||||
-rw-r--r-- | libc/libc.arm64.map | 7 | ||||
-rw-r--r-- | libc/libc.map.txt | 7 | ||||
-rw-r--r-- | libc/libc.mips.map | 7 | ||||
-rw-r--r-- | libc/libc.mips64.map | 7 | ||||
-rw-r--r-- | libc/libc.x86.map | 7 | ||||
-rw-r--r-- | libc/libc.x86_64.map | 7 | ||||
-rw-r--r-- | tests/unistd_test.cpp | 15 |
17 files changed, 162 insertions, 27 deletions
diff --git a/libc/SECCOMP_WHITELIST.TXT b/libc/SECCOMP_WHITELIST.TXT index 9e417c457..4df53f957 100644 --- a/libc/SECCOMP_WHITELIST.TXT +++ b/libc/SECCOMP_WHITELIST.TXT @@ -46,9 +46,6 @@ int perf_event_open:perf_event_open(struct perf_event_attr *attr, pid_t pid, int # Needed for strace int tkill:tkill(int tid, int sig) all -# b/35034743 -int syncfs:syncfs(int fd) all - # b/34763393 int seccomp:seccomp(unsigned int operation, unsigned int flags, void *args) all diff --git a/libc/SYSCALLS.TXT b/libc/SYSCALLS.TXT index d674630ac..a1d1af09d 100644 --- a/libc/SYSCALLS.TXT +++ b/libc/SYSCALLS.TXT @@ -131,6 +131,7 @@ int fdatasync(int) all int fchown:fchown32(int, uid_t, gid_t) arm,x86 int fchown:fchown(int, uid_t, gid_t) arm64,mips,mips64,x86_64 void sync(void) all +int syncfs(int) all int ___fsetxattr:fsetxattr(int, const char*, const void*, size_t, int) all ssize_t ___fgetxattr:fgetxattr(int, const char*, void*, size_t) all ssize_t ___flistxattr:flistxattr(int, char*, size_t) all diff --git a/libc/arch-arm/syscalls/syncfs.S b/libc/arch-arm/syscalls/syncfs.S new file mode 100644 index 000000000..26f2f1497 --- /dev/null +++ b/libc/arch-arm/syscalls/syncfs.S @@ -0,0 +1,16 @@ +/* Generated by gensyscalls.py. Do not edit. */ + +#include <private/bionic_asm.h> + +ENTRY(syncfs) + mov ip, r7 + .cfi_register r7, ip + ldr r7, =__NR_syncfs + swi #0 + mov r7, ip + .cfi_restore r7 + cmn r0, #(MAX_ERRNO + 1) + bxls lr + neg r0, r0 + b __set_errno_internal +END(syncfs) diff --git a/libc/arch-arm64/syscalls/syncfs.S b/libc/arch-arm64/syscalls/syncfs.S new file mode 100644 index 000000000..773c0cb45 --- /dev/null +++ b/libc/arch-arm64/syscalls/syncfs.S @@ -0,0 +1,14 @@ +/* Generated by gensyscalls.py. Do not edit. */ + +#include <private/bionic_asm.h> + +ENTRY(syncfs) + mov x8, __NR_syncfs + svc #0 + + cmn x0, #(MAX_ERRNO + 1) + cneg x0, x0, hi + b.hi __set_errno_internal + + ret +END(syncfs) diff --git a/libc/arch-mips/syscalls/syncfs.S b/libc/arch-mips/syscalls/syncfs.S new file mode 100644 index 000000000..cd87a61b9 --- /dev/null +++ b/libc/arch-mips/syscalls/syncfs.S @@ -0,0 +1,19 @@ +/* Generated by gensyscalls.py. Do not edit. */ + +#include <private/bionic_asm.h> + +ENTRY(syncfs) + .set noreorder + .cpload t9 + li v0, __NR_syncfs + syscall + bnez a3, 1f + move a0, v0 + j ra + nop +1: + la t9,__set_errno_internal + j t9 + nop + .set reorder +END(syncfs) diff --git a/libc/arch-mips64/syscalls/syncfs.S b/libc/arch-mips64/syscalls/syncfs.S new file mode 100644 index 000000000..504ca4ad9 --- /dev/null +++ b/libc/arch-mips64/syscalls/syncfs.S @@ -0,0 +1,25 @@ +/* Generated by gensyscalls.py. Do not edit. */ + +#include <private/bionic_asm.h> + +ENTRY(syncfs) + .set push + .set noreorder + li v0, __NR_syncfs + syscall + bnez a3, 1f + move a0, v0 + j ra + nop +1: + move t0, ra + bal 2f + nop +2: + .cpsetup ra, t1, 2b + LA t9,__set_errno_internal + .cpreturn + j t9 + move ra, t0 + .set pop +END(syncfs) diff --git a/libc/arch-x86/syscalls/syncfs.S b/libc/arch-x86/syscalls/syncfs.S new file mode 100644 index 000000000..c08688a10 --- /dev/null +++ b/libc/arch-x86/syscalls/syncfs.S @@ -0,0 +1,29 @@ +/* Generated by gensyscalls.py. Do not edit. */ + +#include <private/bionic_asm.h> + +ENTRY(syncfs) + pushl %ebx + .cfi_def_cfa_offset 8 + .cfi_rel_offset ebx, 0 + + call __kernel_syscall + pushl %eax + .cfi_adjust_cfa_offset 4 + .cfi_rel_offset eax, 0 + + mov 12(%esp), %ebx + movl $__NR_syncfs, %eax + call *(%esp) + addl $4, %esp + + cmpl $-MAX_ERRNO, %eax + jb 1f + negl %eax + pushl %eax + call __set_errno_internal + addl $4, %esp +1: + popl %ebx + ret +END(syncfs) diff --git a/libc/arch-x86_64/syscalls/syncfs.S b/libc/arch-x86_64/syscalls/syncfs.S new file mode 100644 index 000000000..12dee085e --- /dev/null +++ b/libc/arch-x86_64/syscalls/syncfs.S @@ -0,0 +1,15 @@ +/* Generated by gensyscalls.py. Do not edit. */ + +#include <private/bionic_asm.h> + +ENTRY(syncfs) + movl $__NR_syncfs, %eax + syscall + cmpq $-MAX_ERRNO, %rax + jb 1f + negl %eax + movl %eax, %edi + call __set_errno_internal +1: + ret +END(syncfs) diff --git a/libc/include/unistd.h b/libc/include/unistd.h index ff77421ed..a05fa5488 100644 --- a/libc/include/unistd.h +++ b/libc/include/unistd.h @@ -152,6 +152,9 @@ int lchown(const char* __path, uid_t __owner, gid_t __group); char* getcwd(char* __buf, size_t __size) __overloadable __RENAME_CLANG(getcwd); void sync(void); +#if defined(__USE_GNU) +int syncfs(int __fd) __INTRODUCED_IN_FUTURE; +#endif int close(int __fd); diff --git a/libc/libc.arm.map b/libc/libc.arm.map index 06856c8ba..0749fc873 100644 --- a/libc/libc.arm.map +++ b/libc/libc.arm.map @@ -1320,9 +1320,10 @@ LIBC_O { LIBC_P { global: - __freading; # future - __fwriting; # future - getlogin_r; # future + __freading; # introduced=P + __fwriting; # introduced=P + getlogin_r; # introduced=P + syncfs; # introduced=P } LIBC_O; LIBC_PRIVATE { diff --git a/libc/libc.arm64.map b/libc/libc.arm64.map index 50e4390b1..ce6f12de0 100644 --- a/libc/libc.arm64.map +++ b/libc/libc.arm64.map @@ -1240,9 +1240,10 @@ LIBC_O { LIBC_P { global: - __freading; # future - __fwriting; # future - getlogin_r; # future + __freading; # introduced=P + __fwriting; # introduced=P + getlogin_r; # introduced=P + syncfs; # introduced=P } LIBC_O; LIBC_PRIVATE { diff --git a/libc/libc.map.txt b/libc/libc.map.txt index 3e4d36eca..b35c72e2f 100644 --- a/libc/libc.map.txt +++ b/libc/libc.map.txt @@ -1345,9 +1345,10 @@ LIBC_O { LIBC_P { global: - __freading; # future - __fwriting; # future - getlogin_r; # future + __freading; # introduced=P + __fwriting; # introduced=P + getlogin_r; # introduced=P + syncfs; # introduced=P } LIBC_O; LIBC_PRIVATE { diff --git a/libc/libc.mips.map b/libc/libc.mips.map index 3fa7c9dea..051afaf5f 100644 --- a/libc/libc.mips.map +++ b/libc/libc.mips.map @@ -1304,9 +1304,10 @@ LIBC_O { LIBC_P { global: - __freading; # future - __fwriting; # future - getlogin_r; # future + __freading; # introduced=P + __fwriting; # introduced=P + getlogin_r; # introduced=P + syncfs; # introduced=P } LIBC_O; LIBC_PRIVATE { diff --git a/libc/libc.mips64.map b/libc/libc.mips64.map index 50e4390b1..ce6f12de0 100644 --- a/libc/libc.mips64.map +++ b/libc/libc.mips64.map @@ -1240,9 +1240,10 @@ LIBC_O { LIBC_P { global: - __freading; # future - __fwriting; # future - getlogin_r; # future + __freading; # introduced=P + __fwriting; # introduced=P + getlogin_r; # introduced=P + syncfs; # introduced=P } LIBC_O; LIBC_PRIVATE { diff --git a/libc/libc.x86.map b/libc/libc.x86.map index bd74fbe46..5f27643c2 100644 --- a/libc/libc.x86.map +++ b/libc/libc.x86.map @@ -1302,9 +1302,10 @@ LIBC_O { LIBC_P { global: - __freading; # future - __fwriting; # future - getlogin_r; # future + __freading; # introduced=P + __fwriting; # introduced=P + getlogin_r; # introduced=P + syncfs; # introduced=P } LIBC_O; LIBC_PRIVATE { diff --git a/libc/libc.x86_64.map b/libc/libc.x86_64.map index 50e4390b1..ce6f12de0 100644 --- a/libc/libc.x86_64.map +++ b/libc/libc.x86_64.map @@ -1240,9 +1240,10 @@ LIBC_O { LIBC_P { global: - __freading; # future - __fwriting; # future - getlogin_r; # future + __freading; # introduced=P + __fwriting; # introduced=P + getlogin_r; # introduced=P + syncfs; # introduced=P } LIBC_O; LIBC_PRIVATE { diff --git a/tests/unistd_test.cpp b/tests/unistd_test.cpp index 9b811ed4a..cd51e1bfb 100644 --- a/tests/unistd_test.cpp +++ b/tests/unistd_test.cpp @@ -375,7 +375,7 @@ TEST(UNISTD_TEST, clearenv) { EXPECT_EQ(0, unsetenv("test-variable")); } -static void TestFsyncFunction(int (*fn)(int)) { +static void TestSyncFunction(int (*fn)(int)) { int fd; // Can't sync an invalid fd. @@ -401,10 +401,15 @@ static void TestFsyncFunction(int (*fn)(int)) { ASSERT_NE(-1, fd = open("/data/local/tmp", O_RDONLY)); EXPECT_EQ(0, fn(fd)); close(fd); +} + +static void TestFsyncFunction(int (*fn)(int)) { + TestSyncFunction(fn); - // But some file systems may choose to be fussy... + // But some file systems are fussy about fsync/fdatasync... errno = 0; - ASSERT_NE(-1, fd = open("/proc/version", O_RDONLY)); + int fd = open("/proc/version", O_RDONLY); + ASSERT_NE(-1, fd); EXPECT_EQ(-1, fn(fd)); EXPECT_EQ(EINVAL, errno); close(fd); @@ -418,6 +423,10 @@ TEST(UNISTD_TEST, fsync) { TestFsyncFunction(fsync); } +TEST(UNISTD_TEST, syncfs) { + TestSyncFunction(syncfs); +} + static void AssertGetPidCorrect() { // The loop is just to make manual testing/debugging with strace easier. pid_t getpid_syscall_result = syscall(__NR_getpid); |