bionic/strtold.cpp \
bionic/stubs.cpp \
bionic/symlink.cpp \
+ bionic/sync_file_range.cpp \
bionic/sysinfo.cpp \
bionic/syslog.cpp \
bionic/sys_siglist.c \
int setdomainname(const char*, size_t) all
int sethostname(const char*, size_t) all
+int __sync_file_range:sync_file_range(int, off64_t, off64_t, unsigned int) arm64,mips,mips64,x86,x86_64
+int __sync_file_range2:sync_file_range2(int, unsigned int, off64_t, off64_t) arm
+
pid_t wait4(pid_t, int*, int, struct rusage*) all
int __waitid:waitid(int, pid_t, struct siginfo_t*, int, void*) all
--- /dev/null
+/* Generated by gensyscalls.py. Do not edit. */
+
+#include <private/bionic_asm.h>
+
+ENTRY(__sync_file_range2)
+ mov ip, sp
+ stmfd sp!, {r4, r5, r6, r7}
+ .cfi_def_cfa_offset 16
+ .cfi_rel_offset r4, 0
+ .cfi_rel_offset r5, 4
+ .cfi_rel_offset r6, 8
+ .cfi_rel_offset r7, 12
+ ldmfd ip, {r4, r5, r6}
+ ldr r7, =__NR_sync_file_range2
+ swi #0
+ ldmfd sp!, {r4, r5, r6, r7}
+ .cfi_def_cfa_offset 0
+ cmn r0, #(MAX_ERRNO + 1)
+ bxls lr
+ neg r0, r0
+ b __set_errno_internal
+END(__sync_file_range2)
--- /dev/null
+/* Generated by gensyscalls.py. Do not edit. */
+
+#include <private/bionic_asm.h>
+
+ENTRY(__sync_file_range)
+ mov x8, __NR_sync_file_range
+ svc #0
+
+ cmn x0, #(MAX_ERRNO + 1)
+ cneg x0, x0, hi
+ b.hi __set_errno_internal
+
+ ret
+END(__sync_file_range)
+.hidden __sync_file_range
--- /dev/null
+/* Generated by gensyscalls.py. Do not edit. */
+
+#include <private/bionic_asm.h>
+
+ENTRY(__sync_file_range)
+ .set noreorder
+ .cpload t9
+ li v0, __NR_sync_file_range
+ syscall
+ bnez a3, 1f
+ move a0, v0
+ j ra
+ nop
+1:
+ la t9,__set_errno_internal
+ j t9
+ nop
+ .set reorder
+END(__sync_file_range)
--- /dev/null
+/* Generated by gensyscalls.py. Do not edit. */
+
+#include <private/bionic_asm.h>
+
+ENTRY(__sync_file_range)
+ .set push
+ .set noreorder
+ li v0, __NR_sync_file_range
+ 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(__sync_file_range)
+.hidden __sync_file_range
--- /dev/null
+/* Generated by gensyscalls.py. Do not edit. */
+
+#include <private/bionic_asm.h>
+
+ENTRY(__sync_file_range)
+ pushl %ebx
+ .cfi_def_cfa_offset 8
+ .cfi_rel_offset ebx, 0
+ pushl %ecx
+ .cfi_adjust_cfa_offset 4
+ .cfi_rel_offset ecx, 0
+ pushl %edx
+ .cfi_adjust_cfa_offset 4
+ .cfi_rel_offset edx, 0
+ pushl %esi
+ .cfi_adjust_cfa_offset 4
+ .cfi_rel_offset esi, 0
+ pushl %edi
+ .cfi_adjust_cfa_offset 4
+ .cfi_rel_offset edi, 0
+ pushl %ebp
+ .cfi_adjust_cfa_offset 4
+ .cfi_rel_offset ebp, 0
+
+ call __kernel_syscall
+ pushl %eax
+ .cfi_adjust_cfa_offset 4
+ .cfi_rel_offset eax, 0
+
+ mov 32(%esp), %ebx
+ mov 36(%esp), %ecx
+ mov 40(%esp), %edx
+ mov 44(%esp), %esi
+ mov 48(%esp), %edi
+ mov 52(%esp), %ebp
+ movl $__NR_sync_file_range, %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 %ebp
+ popl %edi
+ popl %esi
+ popl %edx
+ popl %ecx
+ popl %ebx
+ ret
+END(__sync_file_range)
--- /dev/null
+/* Generated by gensyscalls.py. Do not edit. */
+
+#include <private/bionic_asm.h>
+
+ENTRY(__sync_file_range)
+ movq %rcx, %r10
+ movl $__NR_sync_file_range, %eax
+ syscall
+ cmpq $-MAX_ERRNO, %rax
+ jb 1f
+ negl %eax
+ movl %eax, %edi
+ call __set_errno_internal
+1:
+ ret
+END(__sync_file_range)
+.hidden __sync_file_range
--- /dev/null
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <fcntl.h>
+
+extern "C" int __sync_file_range(int, off64_t, off64_t, unsigned int);
+extern "C" int __sync_file_range2(int, unsigned int, off64_t, off64_t);
+
+int sync_file_range(int fd, off64_t offset, off64_t length, unsigned int flags) {
+#if __arm__
+ return __sync_file_range2(fd, flags, offset, length);
+#else
+ return __sync_file_range(fd, offset, length, flags);
+#endif
+}
#if defined(__USE_GNU)
ssize_t readahead(int, off64_t, size_t);
+int sync_file_range(int, off64_t, off64_t, unsigned int);
#endif
extern int __open_2(const char*, int);
sigpause;
sigrelse;
sigset;
+ sync_file_range;
} LIBC_N;
LIBC_PRIVATE {
sigpause;
sigrelse;
sigset;
+ sync_file_range;
} LIBC_N;
LIBC_PRIVATE {
sigpause;
sigrelse;
sigset;
+ sync_file_range;
} LIBC_N;
LIBC_PRIVATE {
sigpause;
sigrelse;
sigset;
+ sync_file_range;
} LIBC_N;
LIBC_PRIVATE {
sigpause;
sigrelse;
sigset;
+ sync_file_range;
} LIBC_N;
LIBC_PRIVATE {
sigpause;
sigrelse;
sigset;
+ sync_file_range;
} LIBC_N;
LIBC_PRIVATE {
sigpause;
sigrelse;
sigset;
+ sync_file_range;
} LIBC_N;
LIBC_PRIVATE {
sigpause;
sigrelse;
sigset;
+ sync_file_range;
} LIBC_N;
LIBC_PRIVATE {
sigpause;
sigrelse;
sigset;
+ sync_file_range;
} LIBC_N;
LIBC_PRIVATE {
sigpause;
sigrelse;
sigset;
+ sync_file_range;
} LIBC_N;
LIBC_PRIVATE {
ASSERT_EQ(-1, readahead(-1, 0, 123));
ASSERT_EQ(EBADF, errno);
}
+
+TEST(fcntl, sync_file_range) {
+ // Just check that the function is available.
+ errno = 0;
+ ASSERT_EQ(-1, sync_file_range(-1, 0, 0, 0));
+ ASSERT_EQ(EBADF, errno);
+
+ TemporaryFile tf;
+ ASSERT_EQ(0, sync_file_range(tf.fd, 0, 0, 0));
+
+ // The arguments to the underlying system call are in a different order on 32-bit ARM.
+ // Check that the `flags` argument gets passed to the kernel correctly.
+ errno = 0;
+ ASSERT_EQ(-1, sync_file_range(tf.fd, 0, 0, ~0));
+ ASSERT_EQ(EINVAL, errno);
+}