From ab8b54101eed0a4b92ebf8fa6994cd1b4f22d8f4 Mon Sep 17 00:00:00 2001 From: David 'Digit' Turner Date: Thu, 8 Jul 2010 16:52:27 -0700 Subject: libc: fix fstatfs() implementation. The syscall expects the size of the buffer as the second argument. Change-Id: I99ede2fec7fcd385ca03ff022c2cffa4297bea8d --- libc/Android.mk | 1 + libc/SYSCALLS.TXT | 2 +- libc/arch-arm/syscalls.mk | 2 +- libc/arch-arm/syscalls/__fstatfs64.S | 19 +++++++++++++++++++ libc/arch-arm/syscalls/fstatfs.S | 19 ------------------- libc/arch-sh/syscalls.mk | 2 +- libc/arch-sh/syscalls/__fstatfs64.S | 32 ++++++++++++++++++++++++++++++++ libc/arch-sh/syscalls/fstatfs.S | 32 -------------------------------- libc/arch-x86/syscalls.mk | 2 +- libc/arch-x86/syscalls/__fstatfs64.S | 29 +++++++++++++++++++++++++++++ libc/arch-x86/syscalls/fstatfs.S | 29 ----------------------------- libc/docs/CHANGES.TXT | 2 ++ libc/include/sys/linux-unistd.h | 2 +- libc/unistd/fstatfs.c | 35 +++++++++++++++++++++++++++++++++++ 14 files changed, 123 insertions(+), 85 deletions(-) create mode 100644 libc/arch-arm/syscalls/__fstatfs64.S delete mode 100644 libc/arch-arm/syscalls/fstatfs.S create mode 100644 libc/arch-sh/syscalls/__fstatfs64.S delete mode 100644 libc/arch-sh/syscalls/fstatfs.S create mode 100644 libc/arch-x86/syscalls/__fstatfs64.S delete mode 100644 libc/arch-x86/syscalls/fstatfs.S create mode 100644 libc/unistd/fstatfs.c diff --git a/libc/Android.mk b/libc/Android.mk index 80c8cc7..6b9a904 100644 --- a/libc/Android.mk +++ b/libc/Android.mk @@ -14,6 +14,7 @@ libc_common_src_files := \ unistd/exec.c \ unistd/fcntl.c \ unistd/fnmatch.c \ + unistd/fstatfs.c \ unistd/ftime.c \ unistd/ftok.c \ unistd/getcwd.c \ diff --git a/libc/SYSCALLS.TXT b/libc/SYSCALLS.TXT index bf65a6f..7626c45 100644 --- a/libc/SYSCALLS.TXT +++ b/libc/SYSCALLS.TXT @@ -120,7 +120,7 @@ int fsync(int) 118 int fchown:fchown32(int, uid_t, gid_t) 207 void sync(void) 36 int __fcntl64:fcntl64(int, int, void *) 221 -int fstatfs:fstatfs64(int, size_t, struct statfs *) 267,269 +int __fstatfs64:fstatfs64(int, size_t, struct statfs *) 267,269 ssize_t sendfile(int out_fd, int in_fd, off_t *offset, size_t count) 187 int fstatat:fstatat64(int dirfd, const char *path, struct stat *buf, int flags) 327,300 int mkdirat(int dirfd, const char *pathname, mode_t mode) 323,296 diff --git a/libc/arch-arm/syscalls.mk b/libc/arch-arm/syscalls.mk index f6312e5..8afe099 100644 --- a/libc/arch-arm/syscalls.mk +++ b/libc/arch-arm/syscalls.mk @@ -74,7 +74,7 @@ syscall_src += arch-arm/syscalls/fsync.S syscall_src += arch-arm/syscalls/fchown.S syscall_src += arch-arm/syscalls/sync.S syscall_src += arch-arm/syscalls/__fcntl64.S -syscall_src += arch-arm/syscalls/fstatfs.S +syscall_src += arch-arm/syscalls/__fstatfs64.S syscall_src += arch-arm/syscalls/sendfile.S syscall_src += arch-arm/syscalls/fstatat.S syscall_src += arch-arm/syscalls/mkdirat.S diff --git a/libc/arch-arm/syscalls/__fstatfs64.S b/libc/arch-arm/syscalls/__fstatfs64.S new file mode 100644 index 0000000..00b4e41 --- /dev/null +++ b/libc/arch-arm/syscalls/__fstatfs64.S @@ -0,0 +1,19 @@ +/* autogenerated by gensyscalls.py */ +#include + + .text + .type __fstatfs64, #function + .globl __fstatfs64 + .align 4 + .fnstart + +__fstatfs64: + .save {r4, r7} + stmfd sp!, {r4, r7} + ldr r7, =__NR_fstatfs64 + swi #0 + ldmfd sp!, {r4, r7} + movs r0, r0 + bxpl lr + b __set_syscall_errno + .fnend diff --git a/libc/arch-arm/syscalls/fstatfs.S b/libc/arch-arm/syscalls/fstatfs.S deleted file mode 100644 index 88150d6..0000000 --- a/libc/arch-arm/syscalls/fstatfs.S +++ /dev/null @@ -1,19 +0,0 @@ -/* autogenerated by gensyscalls.py */ -#include - - .text - .type fstatfs, #function - .globl fstatfs - .align 4 - .fnstart - -fstatfs: - .save {r4, r7} - stmfd sp!, {r4, r7} - ldr r7, =__NR_fstatfs64 - swi #0 - ldmfd sp!, {r4, r7} - movs r0, r0 - bxpl lr - b __set_syscall_errno - .fnend diff --git a/libc/arch-sh/syscalls.mk b/libc/arch-sh/syscalls.mk index a8a151a..ddae8d3 100644 --- a/libc/arch-sh/syscalls.mk +++ b/libc/arch-sh/syscalls.mk @@ -77,7 +77,7 @@ syscall_src += arch-sh/syscalls/fsync.S syscall_src += arch-sh/syscalls/fchown.S syscall_src += arch-sh/syscalls/sync.S syscall_src += arch-sh/syscalls/__fcntl64.S -syscall_src += arch-sh/syscalls/fstatfs.S +syscall_src += arch-sh/syscalls/__fstatfs64.S syscall_src += arch-sh/syscalls/sendfile.S syscall_src += arch-sh/syscalls/fstatat.S syscall_src += arch-sh/syscalls/mkdirat.S diff --git a/libc/arch-sh/syscalls/__fstatfs64.S b/libc/arch-sh/syscalls/__fstatfs64.S new file mode 100644 index 0000000..dcf1d80 --- /dev/null +++ b/libc/arch-sh/syscalls/__fstatfs64.S @@ -0,0 +1,32 @@ +/* autogenerated by gensyscalls.py */ +#include + + .text + .type __fstatfs64, @function + .globl __fstatfs64 + .align 4 + +__fstatfs64: + + /* invoke trap */ + mov.l 0f, r3 /* trap num */ + trapa #(3 + 0x10) + + /* check return value */ + cmp/pz r0 + bt __NR_fstatfs64_end + + /* keep error number */ + sts.l pr, @-r15 + mov.l 1f, r1 + jsr @r1 + mov r0, r4 + lds.l @r15+, pr + +__NR_fstatfs64_end: + rts + nop + + .align 2 +0: .long __NR_fstatfs64 +1: .long __set_syscall_errno diff --git a/libc/arch-sh/syscalls/fstatfs.S b/libc/arch-sh/syscalls/fstatfs.S deleted file mode 100644 index 6adb2cb..0000000 --- a/libc/arch-sh/syscalls/fstatfs.S +++ /dev/null @@ -1,32 +0,0 @@ -/* autogenerated by gensyscalls.py */ -#include - - .text - .type fstatfs, @function - .globl fstatfs - .align 4 - -fstatfs: - - /* invoke trap */ - mov.l 0f, r3 /* trap num */ - trapa #(3 + 0x10) - - /* check return value */ - cmp/pz r0 - bt __NR_fstatfs64_end - - /* keep error number */ - sts.l pr, @-r15 - mov.l 1f, r1 - jsr @r1 - mov r0, r4 - lds.l @r15+, pr - -__NR_fstatfs64_end: - rts - nop - - .align 2 -0: .long __NR_fstatfs64 -1: .long __set_syscall_errno diff --git a/libc/arch-x86/syscalls.mk b/libc/arch-x86/syscalls.mk index bd9a9ab..6ac3716 100644 --- a/libc/arch-x86/syscalls.mk +++ b/libc/arch-x86/syscalls.mk @@ -77,7 +77,7 @@ syscall_src += arch-x86/syscalls/fsync.S syscall_src += arch-x86/syscalls/fchown.S syscall_src += arch-x86/syscalls/sync.S syscall_src += arch-x86/syscalls/__fcntl64.S -syscall_src += arch-x86/syscalls/fstatfs.S +syscall_src += arch-x86/syscalls/__fstatfs64.S syscall_src += arch-x86/syscalls/sendfile.S syscall_src += arch-x86/syscalls/fstatat.S syscall_src += arch-x86/syscalls/mkdirat.S diff --git a/libc/arch-x86/syscalls/__fstatfs64.S b/libc/arch-x86/syscalls/__fstatfs64.S new file mode 100644 index 0000000..f755244 --- /dev/null +++ b/libc/arch-x86/syscalls/__fstatfs64.S @@ -0,0 +1,29 @@ +/* autogenerated by gensyscalls.py */ +#include + + .text + .type __fstatfs64, @function + .globl __fstatfs64 + .align 4 + +__fstatfs64: + pushl %ebx + pushl %ecx + pushl %edx + mov 16(%esp), %ebx + mov 20(%esp), %ecx + mov 24(%esp), %edx + movl $__NR_fstatfs64, %eax + int $0x80 + cmpl $-129, %eax + jb 1f + negl %eax + pushl %eax + call __set_errno + addl $4, %esp + orl $-1, %eax +1: + popl %edx + popl %ecx + popl %ebx + ret diff --git a/libc/arch-x86/syscalls/fstatfs.S b/libc/arch-x86/syscalls/fstatfs.S deleted file mode 100644 index f72b3d4..0000000 --- a/libc/arch-x86/syscalls/fstatfs.S +++ /dev/null @@ -1,29 +0,0 @@ -/* autogenerated by gensyscalls.py */ -#include - - .text - .type fstatfs, @function - .globl fstatfs - .align 4 - -fstatfs: - pushl %ebx - pushl %ecx - pushl %edx - mov 16(%esp), %ebx - mov 20(%esp), %ecx - mov 24(%esp), %edx - movl $__NR_fstatfs64, %eax - int $0x80 - cmpl $-129, %eax - jb 1f - negl %eax - pushl %eax - call __set_errno - addl $4, %esp - orl $-1, %eax -1: - popl %edx - popl %ecx - popl %ebx - ret diff --git a/libc/docs/CHANGES.TXT b/libc/docs/CHANGES.TXT index 9389f7a..cbca6cb 100644 --- a/libc/docs/CHANGES.TXT +++ b/libc/docs/CHANGES.TXT @@ -63,6 +63,8 @@ Differences between current and Android 2.2: - : add missing declaration for pselect() +- : fixed implementation of fstatfs() (also fixes fpathconf() + which uses it). ------------------------------------------------------------------------------- Differences between Android 2.2. and Android 2.1: diff --git a/libc/include/sys/linux-unistd.h b/libc/include/sys/linux-unistd.h index 27db2a9..3f151f9 100644 --- a/libc/include/sys/linux-unistd.h +++ b/libc/include/sys/linux-unistd.h @@ -87,7 +87,7 @@ int fsync (int); int fchown (int, uid_t, gid_t); void sync (void); int __fcntl64 (int, int, void *); -int fstatfs (int, size_t, struct statfs *); +int __fstatfs64 (int, size_t, struct statfs *); ssize_t sendfile (int out_fd, int in_fd, off_t *offset, size_t count); int fstatat (int dirfd, const char *path, struct stat *buf, int flags); int mkdirat (int dirfd, const char *pathname, mode_t mode); diff --git a/libc/unistd/fstatfs.c b/libc/unistd/fstatfs.c new file mode 100644 index 0000000..3d7c696 --- /dev/null +++ b/libc/unistd/fstatfs.c @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2010 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 + +extern int __fstatfs64(int, size_t, struct statfs *); + +int fstatfs(int fd, struct statfs* stat) +{ + return __fstatfs64(fd, sizeof(struct statfs), stat); +} -- cgit v1.1