Add syncfs(2).

GMM calls this system call directly at the moment. That's silly.

Bug: http://b/36405699
Test: ran tests
Change-Id: I1e14c0e5ce0bc2aa888d884845ac30dc20f13cd5
diff --git a/libc/SECCOMP_WHITELIST.TXT b/libc/SECCOMP_WHITELIST.TXT
index 9e417c4..4df53f9 100644
--- a/libc/SECCOMP_WHITELIST.TXT
+++ b/libc/SECCOMP_WHITELIST.TXT
@@ -46,9 +46,6 @@
 # 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 d674630..a1d1af0 100644
--- a/libc/SYSCALLS.TXT
+++ b/libc/SYSCALLS.TXT
@@ -131,6 +131,7 @@
 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 0000000..26f2f14
--- /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 0000000..773c0cb
--- /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 0000000..cd87a61
--- /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 0000000..504ca4a
--- /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 0000000..c08688a
--- /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 0000000..12dee08
--- /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 ff77421..a05fa54 100644
--- a/libc/include/unistd.h
+++ b/libc/include/unistd.h
@@ -152,6 +152,9 @@
 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 06856c8..0749fc8 100644
--- a/libc/libc.arm.map
+++ b/libc/libc.arm.map
@@ -1320,9 +1320,10 @@
 
 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 50e4390..ce6f12d 100644
--- a/libc/libc.arm64.map
+++ b/libc/libc.arm64.map
@@ -1240,9 +1240,10 @@
 
 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 3e4d36e..b35c72e 100644
--- a/libc/libc.map.txt
+++ b/libc/libc.map.txt
@@ -1345,9 +1345,10 @@
 
 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 3fa7c9d..051afaf 100644
--- a/libc/libc.mips.map
+++ b/libc/libc.mips.map
@@ -1304,9 +1304,10 @@
 
 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 50e4390..ce6f12d 100644
--- a/libc/libc.mips64.map
+++ b/libc/libc.mips64.map
@@ -1240,9 +1240,10 @@
 
 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 bd74fbe..5f27643 100644
--- a/libc/libc.x86.map
+++ b/libc/libc.x86.map
@@ -1302,9 +1302,10 @@
 
 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 50e4390..ce6f12d 100644
--- a/libc/libc.x86_64.map
+++ b/libc/libc.x86_64.map
@@ -1240,9 +1240,10 @@
 
 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 {