am 132a66be: am 3e0e7eea: Merge "Remove getdents from bionic."
* commit '132a66be4692840b13b3a6d6fb93d6e7965003c5': Remove getdents from bionic.
This commit is contained in:
commit
3f508b3fc0
@ -129,12 +129,7 @@ ssize_t fgetxattr(int, const char*, void*, size_t) all
|
|||||||
ssize_t flistxattr(int, char*, size_t) all
|
ssize_t flistxattr(int, char*, size_t) all
|
||||||
int fremovexattr(int, const char*) all
|
int fremovexattr(int, const char*) all
|
||||||
|
|
||||||
# mips64 doesn't have getdents64 until 3.10 kernels.
|
int __getdents64:getdents64(unsigned int, struct dirent*, unsigned int) arm,arm64,mips,mips64,x86,x86_64
|
||||||
# We need this special-case hack as long as we need to support mips64 on older kernels.
|
|
||||||
# The currently-available Debian qemu image is on a 3.2 kernel.
|
|
||||||
int getdents:getdents64(unsigned int, struct dirent*, unsigned int) arm,arm64,mips,x86,x86_64
|
|
||||||
int __getdents64:getdents64(unsigned int, struct dirent*, unsigned int) mips64
|
|
||||||
int __getdents:getdents(unsigned int, void*, unsigned int) mips64
|
|
||||||
|
|
||||||
int __openat:openat(int, const char*, int, mode_t) all
|
int __openat:openat(int, const char*, int, mode_t) all
|
||||||
int faccessat(int, const char*, int, int) all
|
int faccessat(int, const char*, int, int) all
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include <private/bionic_asm.h>
|
#include <private/bionic_asm.h>
|
||||||
|
|
||||||
ENTRY(getdents)
|
ENTRY(__getdents64)
|
||||||
mov ip, r7
|
mov ip, r7
|
||||||
ldr r7, =__NR_getdents64
|
ldr r7, =__NR_getdents64
|
||||||
swi #0
|
swi #0
|
||||||
@ -11,4 +11,4 @@ ENTRY(getdents)
|
|||||||
bxls lr
|
bxls lr
|
||||||
neg r0, r0
|
neg r0, r0
|
||||||
b __set_errno
|
b __set_errno
|
||||||
END(getdents)
|
END(__getdents64)
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include <private/bionic_asm.h>
|
#include <private/bionic_asm.h>
|
||||||
|
|
||||||
ENTRY(getdents)
|
ENTRY(__getdents64)
|
||||||
stp x29, x30, [sp, #-16]!
|
stp x29, x30, [sp, #-16]!
|
||||||
.cfi_def_cfa_offset 16
|
.cfi_def_cfa_offset 16
|
||||||
.cfi_rel_offset x29, 0
|
.cfi_rel_offset x29, 0
|
||||||
@ -22,4 +22,5 @@ ENTRY(getdents)
|
|||||||
b.hi __set_errno
|
b.hi __set_errno
|
||||||
|
|
||||||
ret
|
ret
|
||||||
END(getdents)
|
END(__getdents64)
|
||||||
|
.hidden __getdents64
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include <private/bionic_asm.h>
|
#include <private/bionic_asm.h>
|
||||||
|
|
||||||
ENTRY(getdents)
|
ENTRY(__getdents64)
|
||||||
.set noreorder
|
.set noreorder
|
||||||
.cpload t9
|
.cpload t9
|
||||||
li v0, __NR_getdents64
|
li v0, __NR_getdents64
|
||||||
@ -16,4 +16,4 @@ ENTRY(getdents)
|
|||||||
j t9
|
j t9
|
||||||
nop
|
nop
|
||||||
.set reorder
|
.set reorder
|
||||||
END(getdents)
|
END(__getdents64)
|
@ -1,97 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2014 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The MIPS64 getdents64() system call is only present in 3.10+ kernels.
|
|
||||||
* If the getdents64() system call is not available fall back to using
|
|
||||||
* getdents() and modify the result to be compatible with getdents64().
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <dirent.h>
|
|
||||||
|
|
||||||
#include <errno.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
|
|
||||||
/* The mips_getdents type is 64bit clean */
|
|
||||||
struct mips_dirent {
|
|
||||||
uint64_t d_ino; /* Inode number */
|
|
||||||
uint64_t d_off; /* Offset to next mips_dirent */
|
|
||||||
uint16_t d_reclen; /* Length of this mips_dirent */
|
|
||||||
char d_name[]; /* Filename (null-terminated) */
|
|
||||||
/* length is actually (d_reclen - 2 -
|
|
||||||
offsetof(struct mips_dirent, d_name) */
|
|
||||||
// char pad; /* Zero padding byte */
|
|
||||||
// char d_type; /* File type (only since Linux 2.6.4; offset is (d_reclen - 1)) */
|
|
||||||
};
|
|
||||||
|
|
||||||
extern "C" int __getdents64(unsigned int fd, struct dirent *dirp, unsigned int count);
|
|
||||||
extern "C" int __getdents(unsigned int fd, struct mips_dirent *dirp, unsigned int count);
|
|
||||||
int getdents(unsigned int fd, struct dirent *dirp, unsigned int count)
|
|
||||||
{
|
|
||||||
int r;
|
|
||||||
int oerrno = errno;
|
|
||||||
|
|
||||||
/* Use getdents64() if it is available */
|
|
||||||
r = __getdents64(fd, dirp, count);
|
|
||||||
if (r >= 0 || errno != ENOSYS)
|
|
||||||
return r;
|
|
||||||
|
|
||||||
/* Fallback to getdents() */
|
|
||||||
errno = oerrno;
|
|
||||||
r = __getdents(fd, (struct mips_dirent *)dirp, count);
|
|
||||||
if (r > 0) {
|
|
||||||
char *p;
|
|
||||||
char type;
|
|
||||||
union dirents {
|
|
||||||
struct mips_dirent m;
|
|
||||||
struct dirent d;
|
|
||||||
} *u;
|
|
||||||
|
|
||||||
p = (char *)dirp;
|
|
||||||
do {
|
|
||||||
u = (union dirents *)p;
|
|
||||||
|
|
||||||
/* This should not happen, but just in case... */
|
|
||||||
if (p + u->m.d_reclen > (char *)dirp + r)
|
|
||||||
break;
|
|
||||||
|
|
||||||
/* shuffle the dirent */
|
|
||||||
type = *(p + u->m.d_reclen - 1);
|
|
||||||
memmove(u->d.d_name, u->m.d_name,
|
|
||||||
u->m.d_reclen - 2 - offsetof(struct mips_dirent, d_name) + 1);
|
|
||||||
u->d.d_type = type;
|
|
||||||
|
|
||||||
p += u->m.d_reclen;
|
|
||||||
} while (p < (char *)dirp + r);
|
|
||||||
}
|
|
||||||
return r;
|
|
||||||
}
|
|
@ -42,7 +42,6 @@ libc_bionic_src_files_mips64 := \
|
|||||||
arch-mips64/bionic/__bionic_clone.S \
|
arch-mips64/bionic/__bionic_clone.S \
|
||||||
arch-mips64/bionic/_exit_with_stack_teardown.S \
|
arch-mips64/bionic/_exit_with_stack_teardown.S \
|
||||||
arch-mips64/bionic/__get_sp.S \
|
arch-mips64/bionic/__get_sp.S \
|
||||||
arch-mips64/bionic/getdents.cpp \
|
|
||||||
arch-mips64/bionic/memcmp16.S \
|
arch-mips64/bionic/memcmp16.S \
|
||||||
arch-mips64/bionic/_setjmp.S \
|
arch-mips64/bionic/_setjmp.S \
|
||||||
arch-mips64/bionic/setjmp.S \
|
arch-mips64/bionic/setjmp.S \
|
||||||
|
@ -1,26 +0,0 @@
|
|||||||
/* Generated by gensyscalls.py. Do not edit. */
|
|
||||||
|
|
||||||
#include <private/bionic_asm.h>
|
|
||||||
|
|
||||||
ENTRY(__getdents)
|
|
||||||
.set push
|
|
||||||
.set noreorder
|
|
||||||
li v0, __NR_getdents
|
|
||||||
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
|
|
||||||
.cpreturn
|
|
||||||
j t9
|
|
||||||
move ra, t0
|
|
||||||
.set pop
|
|
||||||
END(__getdents)
|
|
||||||
.hidden __getdents
|
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include <private/bionic_asm.h>
|
#include <private/bionic_asm.h>
|
||||||
|
|
||||||
ENTRY(getdents)
|
ENTRY(__getdents64)
|
||||||
pushl %ebx
|
pushl %ebx
|
||||||
.cfi_def_cfa_offset 8
|
.cfi_def_cfa_offset 8
|
||||||
.cfi_rel_offset ebx, 0
|
.cfi_rel_offset ebx, 0
|
||||||
@ -28,4 +28,4 @@ ENTRY(getdents)
|
|||||||
popl %ecx
|
popl %ecx
|
||||||
popl %ebx
|
popl %ebx
|
||||||
ret
|
ret
|
||||||
END(getdents)
|
END(__getdents64)
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include <private/bionic_asm.h>
|
#include <private/bionic_asm.h>
|
||||||
|
|
||||||
ENTRY(getdents)
|
ENTRY(__getdents64)
|
||||||
movl $__NR_getdents64, %eax
|
movl $__NR_getdents64, %eax
|
||||||
syscall
|
syscall
|
||||||
cmpq $-MAX_ERRNO, %rax
|
cmpq $-MAX_ERRNO, %rax
|
||||||
@ -12,4 +12,5 @@ ENTRY(getdents)
|
|||||||
call __set_errno
|
call __set_errno
|
||||||
1:
|
1:
|
||||||
ret
|
ret
|
||||||
END(getdents)
|
END(__getdents64)
|
||||||
|
.hidden __getdents64
|
@ -37,6 +37,8 @@
|
|||||||
#include "private/ErrnoRestorer.h"
|
#include "private/ErrnoRestorer.h"
|
||||||
#include "private/ScopedPthreadMutexLocker.h"
|
#include "private/ScopedPthreadMutexLocker.h"
|
||||||
|
|
||||||
|
extern "C" int __getdents64(unsigned int, struct dirent*, unsigned int);
|
||||||
|
|
||||||
struct DIR {
|
struct DIR {
|
||||||
int fd_;
|
int fd_;
|
||||||
size_t available_bytes_;
|
size_t available_bytes_;
|
||||||
@ -81,7 +83,7 @@ DIR* opendir(const char* path) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool __fill_DIR(DIR* d) {
|
static bool __fill_DIR(DIR* d) {
|
||||||
int rc = TEMP_FAILURE_RETRY(getdents(d->fd_, d->buff_, sizeof(d->buff_)));
|
int rc = TEMP_FAILURE_RETRY(__getdents64(d->fd_, d->buff_, sizeof(d->buff_)));
|
||||||
if (rc <= 0) {
|
if (rc <= 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -238,4 +238,9 @@ extern "C" sighandler_t sysv_signal(int signum, sighandler_t handler) {
|
|||||||
return _signal(signum, handler, SA_RESETHAND);
|
return _signal(signum, handler, SA_RESETHAND);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This is a system call that was never in POSIX. Use readdir(3) instead.
|
||||||
|
extern "C" int getdents(unsigned int fd, struct dirent* dirp, unsigned int count) {
|
||||||
|
return __getdents64(fd, dirp, count);
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -75,7 +75,6 @@ extern int alphasort(const struct dirent**, const struct dirent**);
|
|||||||
extern int alphasort64(const struct dirent64**, const struct dirent64**);
|
extern int alphasort64(const struct dirent64**, const struct dirent64**);
|
||||||
extern int scandir(const char*, struct dirent***, int (*)(const struct dirent*), int (*)(const struct dirent**, const struct dirent**));
|
extern int scandir(const char*, struct dirent***, int (*)(const struct dirent*), int (*)(const struct dirent**, const struct dirent**));
|
||||||
extern int scandir64(const char*, struct dirent64***, int (*)(const struct dirent64*), int (*)(const struct dirent64**, const struct dirent64**));
|
extern int scandir64(const char*, struct dirent64***, int (*)(const struct dirent64*), int (*)(const struct dirent64**, const struct dirent64**));
|
||||||
extern int getdents(unsigned int, struct dirent*, unsigned int);
|
|
||||||
|
|
||||||
__END_DECLS
|
__END_DECLS
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user