Implement some of the missing LFS64 support.
This gives us:
* <dirent.h>
struct dirent64
readdir64, readdir64_r, alphasort64, scandir64
* <fcntl.h>
creat64, openat64, open64.
* <sys/stat.h>
struct stat64
fstat64, fstatat64, lstat64, stat64.
* <sys/statvfs.h>
struct statvfs64
statvfs64, fstatvfs64.
* <sys/vfs.h>
struct statfs64
statfs64, fstatfs64.
This also removes some of the incorrect #define hacks we've had in the
past (for stat64, for example, which we promised to clean up way back
in bug 8472078).
Bug: 11865851
Bug: 8472078
Change-Id: Ia46443521918519f2dfa64d4621027dfd13ac566
diff --git a/libc/Android.mk b/libc/Android.mk
index c1716b1..ad5fb1c 100644
--- a/libc/Android.mk
+++ b/libc/Android.mk
@@ -378,7 +378,6 @@
libc_upstream_netbsd_src_files := \
upstream-netbsd/common/lib/libc/hash/sha1/sha1.c \
upstream-netbsd/common/lib/libc/inet/inet_addr.c \
- upstream-netbsd/libc/compat-43/creat.c \
upstream-netbsd/libc/gen/ftw.c \
upstream-netbsd/libc/gen/nftw.c \
upstream-netbsd/libc/gen/nice.c \
diff --git a/libc/SYSCALLS.TXT b/libc/SYSCALLS.TXT
index e60b166..ee3a05b 100644
--- a/libc/SYSCALLS.TXT
+++ b/libc/SYSCALLS.TXT
@@ -127,8 +127,6 @@
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 __fstatfs64:fstatfs64(int, size_t, struct statfs*) arm,mips,x86
-int fstatfs(int, struct statfs*) arm64,mips64,x86_64
int fsetxattr(int, const char*, const void*, size_t, int) all
ssize_t fgetxattr(int, const char*, void*, size_t) all
ssize_t flistxattr(int, char*, size_t) all
@@ -145,8 +143,8 @@
int faccessat(int, const char*, int, int) all
int fchmodat(int, const char*, mode_t, int) all
int fchownat(int, const char*, uid_t, gid_t, int) all
-int fstatat:fstatat64(int, const char*, struct stat*, int) arm,mips,x86
-int fstatat:newfstatat(int, const char*, struct stat*, int) arm64,mips64,x86_64
+int fstatat64|fstatat:fstatat64(int, const char*, struct stat*, int) arm,mips,x86
+int fstatat64|fstatat:newfstatat(int, const char*, struct stat*, int) arm64,mips64,x86_64
int linkat(int, const char*, int, const char*, int) all
int mkdirat(int, const char*, mode_t) all
int mknodat(int, const char*, mode_t, dev_t) all
@@ -179,12 +177,18 @@
int fallocate64:fallocate(int, int, off64_t, off64_t) arm,mips,x86
int fallocate|fallocate64(int, int, off_t, off_t) arm64,mips64,x86_64
+int __fstatfs64:fstatfs64(int, size_t, struct statfs*) arm,mips,x86
+int fstatfs64|fstatfs:fstatfs(int, struct statfs*) arm64,mips64,x86_64
+int __statfs64:statfs64(const char*, size_t, struct statfs*) arm,mips,x86
+int statfs64|statfs:statfs(const char*, struct statfs*) arm64,mips64,x86_64
+
+int fstat64|fstat:fstat64(int, struct stat*) arm,mips,x86
+int fstat64|fstat:fstat(int, struct stat*) arm64,mips64,x86_64
+
# file system
int chdir(const char*) all
int mount(const char*, const char*, const char*, unsigned long, const void*) all
int umount2(const char*, int) all
-int fstat:fstat64(int, struct stat*) arm,mips,x86
-int fstat(int, struct stat*) arm64,mips64,x86_64
int __getcwd:getcwd(char* buf, size_t size) all
int fchdir(int) all
int setxattr(const char*, const char*, const void*, size_t, int) all
@@ -195,8 +199,6 @@
ssize_t llistxattr(const char*, char*, size_t) all
int removexattr(const char*, const char*) all
int lremovexattr(const char*, const char*) all
-int __statfs64:statfs64(const char*, size_t, struct statfs*) arm,mips,x86
-int statfs(const char*, struct statfs*) arm64,mips64,x86_64
int swapon(const char*, int) all
int swapoff(const char*) all
diff --git a/libc/arch-arm/syscalls/fstat.S b/libc/arch-arm/syscalls/fstat64.S
similarity index 71%
rename from libc/arch-arm/syscalls/fstat.S
rename to libc/arch-arm/syscalls/fstat64.S
index cf08d08..4eceb8f 100644
--- a/libc/arch-arm/syscalls/fstat.S
+++ b/libc/arch-arm/syscalls/fstat64.S
@@ -2,7 +2,7 @@
#include <private/bionic_asm.h>
-ENTRY(fstat)
+ENTRY(fstat64)
mov ip, r7
ldr r7, =__NR_fstat64
swi #0
@@ -11,4 +11,7 @@
bxls lr
neg r0, r0
b __set_errno
-END(fstat)
+END(fstat64)
+
+ .globl _C_LABEL(fstat)
+ .equ _C_LABEL(fstat), _C_LABEL(fstat64)
diff --git a/libc/arch-arm/syscalls/fstatat.S b/libc/arch-arm/syscalls/fstatat64.S
similarity index 69%
rename from libc/arch-arm/syscalls/fstatat.S
rename to libc/arch-arm/syscalls/fstatat64.S
index 7cc9bb0..e919efe 100644
--- a/libc/arch-arm/syscalls/fstatat.S
+++ b/libc/arch-arm/syscalls/fstatat64.S
@@ -2,7 +2,7 @@
#include <private/bionic_asm.h>
-ENTRY(fstatat)
+ENTRY(fstatat64)
mov ip, r7
ldr r7, =__NR_fstatat64
swi #0
@@ -11,4 +11,7 @@
bxls lr
neg r0, r0
b __set_errno
-END(fstatat)
+END(fstatat64)
+
+ .globl _C_LABEL(fstatat)
+ .equ _C_LABEL(fstatat), _C_LABEL(fstatat64)
diff --git a/libc/arch-arm64/syscalls/fstat.S b/libc/arch-arm64/syscalls/fstat64.S
similarity index 78%
rename from libc/arch-arm64/syscalls/fstat.S
rename to libc/arch-arm64/syscalls/fstat64.S
index f8aaa40..56a1b35 100644
--- a/libc/arch-arm64/syscalls/fstat.S
+++ b/libc/arch-arm64/syscalls/fstat64.S
@@ -2,7 +2,7 @@
#include <private/bionic_asm.h>
-ENTRY(fstat)
+ENTRY(fstat64)
stp x29, x30, [sp, #-16]!
mov x29, sp
str x8, [sp, #-16]!
@@ -18,4 +18,7 @@
b.hi __set_errno
ret
-END(fstat)
+END(fstat64)
+
+ .globl _C_LABEL(fstat)
+ .equ _C_LABEL(fstat), _C_LABEL(fstat64)
diff --git a/libc/arch-arm64/syscalls/fstatat.S b/libc/arch-arm64/syscalls/fstatat64.S
similarity index 77%
rename from libc/arch-arm64/syscalls/fstatat.S
rename to libc/arch-arm64/syscalls/fstatat64.S
index 5de0fa0..97e0634 100644
--- a/libc/arch-arm64/syscalls/fstatat.S
+++ b/libc/arch-arm64/syscalls/fstatat64.S
@@ -2,7 +2,7 @@
#include <private/bionic_asm.h>
-ENTRY(fstatat)
+ENTRY(fstatat64)
stp x29, x30, [sp, #-16]!
mov x29, sp
str x8, [sp, #-16]!
@@ -18,4 +18,7 @@
b.hi __set_errno
ret
-END(fstatat)
+END(fstatat64)
+
+ .globl _C_LABEL(fstatat)
+ .equ _C_LABEL(fstatat), _C_LABEL(fstatat64)
diff --git a/libc/arch-arm64/syscalls/fstatfs.S b/libc/arch-arm64/syscalls/fstatfs64.S
similarity index 76%
rename from libc/arch-arm64/syscalls/fstatfs.S
rename to libc/arch-arm64/syscalls/fstatfs64.S
index afd8875..2c0506d 100644
--- a/libc/arch-arm64/syscalls/fstatfs.S
+++ b/libc/arch-arm64/syscalls/fstatfs64.S
@@ -2,7 +2,7 @@
#include <private/bionic_asm.h>
-ENTRY(fstatfs)
+ENTRY(fstatfs64)
stp x29, x30, [sp, #-16]!
mov x29, sp
str x8, [sp, #-16]!
@@ -18,4 +18,7 @@
b.hi __set_errno
ret
-END(fstatfs)
+END(fstatfs64)
+
+ .globl _C_LABEL(fstatfs)
+ .equ _C_LABEL(fstatfs), _C_LABEL(fstatfs64)
diff --git a/libc/arch-arm64/syscalls/statfs.S b/libc/arch-arm64/syscalls/statfs64.S
similarity index 77%
rename from libc/arch-arm64/syscalls/statfs.S
rename to libc/arch-arm64/syscalls/statfs64.S
index 9bfae63..a449b35 100644
--- a/libc/arch-arm64/syscalls/statfs.S
+++ b/libc/arch-arm64/syscalls/statfs64.S
@@ -2,7 +2,7 @@
#include <private/bionic_asm.h>
-ENTRY(statfs)
+ENTRY(statfs64)
stp x29, x30, [sp, #-16]!
mov x29, sp
str x8, [sp, #-16]!
@@ -18,4 +18,7 @@
b.hi __set_errno
ret
-END(statfs)
+END(statfs64)
+
+ .globl _C_LABEL(statfs)
+ .equ _C_LABEL(statfs), _C_LABEL(statfs64)
diff --git a/libc/arch-mips/syscalls/fstat.S b/libc/arch-mips/syscalls/fstat64.S
similarity index 67%
rename from libc/arch-mips/syscalls/fstat.S
rename to libc/arch-mips/syscalls/fstat64.S
index 77eabf8..de09df5 100644
--- a/libc/arch-mips/syscalls/fstat.S
+++ b/libc/arch-mips/syscalls/fstat64.S
@@ -2,11 +2,11 @@
#include <asm/unistd.h>
.text
- .globl fstat
+ .globl fstat64
.align 4
- .ent fstat
+ .ent fstat64
-fstat:
+fstat64:
.set noreorder
.cpload $t9
li $v0, __NR_fstat64
@@ -20,4 +20,7 @@
j $t9
nop
.set reorder
- .end fstat
+ .end fstat64
+
+ .globl _C_LABEL(fstat)
+ .equ _C_LABEL(fstat), _C_LABEL(fstat64)
diff --git a/libc/arch-mips/syscalls/fstatat.S b/libc/arch-mips/syscalls/fstatat64.S
similarity index 65%
rename from libc/arch-mips/syscalls/fstatat.S
rename to libc/arch-mips/syscalls/fstatat64.S
index 478f099..b177922 100644
--- a/libc/arch-mips/syscalls/fstatat.S
+++ b/libc/arch-mips/syscalls/fstatat64.S
@@ -2,11 +2,11 @@
#include <asm/unistd.h>
.text
- .globl fstatat
+ .globl fstatat64
.align 4
- .ent fstatat
+ .ent fstatat64
-fstatat:
+fstatat64:
.set noreorder
.cpload $t9
li $v0, __NR_fstatat64
@@ -20,4 +20,7 @@
j $t9
nop
.set reorder
- .end fstatat
+ .end fstatat64
+
+ .globl _C_LABEL(fstatat)
+ .equ _C_LABEL(fstatat), _C_LABEL(fstatat64)
diff --git a/libc/arch-mips64/syscalls/fstat.S b/libc/arch-mips64/syscalls/fstat64.S
similarity index 75%
rename from libc/arch-mips64/syscalls/fstat.S
rename to libc/arch-mips64/syscalls/fstat64.S
index 4c3e236..413d03b 100644
--- a/libc/arch-mips64/syscalls/fstat.S
+++ b/libc/arch-mips64/syscalls/fstat64.S
@@ -4,11 +4,11 @@
#include <machine/asm.h>
#include <machine/regdef.h>
.text
- .globl fstat
+ .globl fstat64
.align 4
- .ent fstat
+ .ent fstat64
-fstat:
+fstat64:
.set push
.set noreorder
li v0, __NR_fstat
@@ -28,4 +28,7 @@
j t9
move ra, t0
.set pop
- .end fstat
+ .end fstat64
+
+ .globl _C_LABEL(fstat)
+ .equ _C_LABEL(fstat), _C_LABEL(fstat64)
diff --git a/libc/arch-mips64/syscalls/fstatat.S b/libc/arch-mips64/syscalls/fstatat64.S
similarity index 73%
rename from libc/arch-mips64/syscalls/fstatat.S
rename to libc/arch-mips64/syscalls/fstatat64.S
index 630debe..df00901 100644
--- a/libc/arch-mips64/syscalls/fstatat.S
+++ b/libc/arch-mips64/syscalls/fstatat64.S
@@ -4,11 +4,11 @@
#include <machine/asm.h>
#include <machine/regdef.h>
.text
- .globl fstatat
+ .globl fstatat64
.align 4
- .ent fstatat
+ .ent fstatat64
-fstatat:
+fstatat64:
.set push
.set noreorder
li v0, __NR_newfstatat
@@ -28,4 +28,7 @@
j t9
move ra, t0
.set pop
- .end fstatat
+ .end fstatat64
+
+ .globl _C_LABEL(fstatat)
+ .equ _C_LABEL(fstatat), _C_LABEL(fstatat64)
diff --git a/libc/arch-mips64/syscalls/fstatfs.S b/libc/arch-mips64/syscalls/fstatfs64.S
similarity index 73%
rename from libc/arch-mips64/syscalls/fstatfs.S
rename to libc/arch-mips64/syscalls/fstatfs64.S
index 3e38227..2276299 100644
--- a/libc/arch-mips64/syscalls/fstatfs.S
+++ b/libc/arch-mips64/syscalls/fstatfs64.S
@@ -4,11 +4,11 @@
#include <machine/asm.h>
#include <machine/regdef.h>
.text
- .globl fstatfs
+ .globl fstatfs64
.align 4
- .ent fstatfs
+ .ent fstatfs64
-fstatfs:
+fstatfs64:
.set push
.set noreorder
li v0, __NR_fstatfs
@@ -28,4 +28,7 @@
j t9
move ra, t0
.set pop
- .end fstatfs
+ .end fstatfs64
+
+ .globl _C_LABEL(fstatfs)
+ .equ _C_LABEL(fstatfs), _C_LABEL(fstatfs64)
diff --git a/libc/arch-mips64/syscalls/statfs.S b/libc/arch-mips64/syscalls/statfs64.S
similarity index 74%
rename from libc/arch-mips64/syscalls/statfs.S
rename to libc/arch-mips64/syscalls/statfs64.S
index 4711b1a..2fd7603 100644
--- a/libc/arch-mips64/syscalls/statfs.S
+++ b/libc/arch-mips64/syscalls/statfs64.S
@@ -4,11 +4,11 @@
#include <machine/asm.h>
#include <machine/regdef.h>
.text
- .globl statfs
+ .globl statfs64
.align 4
- .ent statfs
+ .ent statfs64
-statfs:
+statfs64:
.set push
.set noreorder
li v0, __NR_statfs
@@ -28,4 +28,7 @@
j t9
move ra, t0
.set pop
- .end statfs
+ .end statfs64
+
+ .globl _C_LABEL(statfs)
+ .equ _C_LABEL(statfs), _C_LABEL(statfs64)
diff --git a/libc/arch-x86/syscalls/fstat.S b/libc/arch-x86/syscalls/fstat64.S
similarity index 82%
rename from libc/arch-x86/syscalls/fstat.S
rename to libc/arch-x86/syscalls/fstat64.S
index daa4d7f..3e1fdd0 100644
--- a/libc/arch-x86/syscalls/fstat.S
+++ b/libc/arch-x86/syscalls/fstat64.S
@@ -2,7 +2,7 @@
#include <private/bionic_asm.h>
-ENTRY(fstat)
+ENTRY(fstat64)
pushl %ebx
pushl %ecx
.cfi_def_cfa_offset 8
@@ -23,4 +23,7 @@
popl %ecx
popl %ebx
ret
-END(fstat)
+END(fstat64)
+
+ .globl _C_LABEL(fstat)
+ .equ _C_LABEL(fstat), _C_LABEL(fstat64)
diff --git a/libc/arch-x86/syscalls/fstatat.S b/libc/arch-x86/syscalls/fstatat64.S
similarity index 85%
rename from libc/arch-x86/syscalls/fstatat.S
rename to libc/arch-x86/syscalls/fstatat64.S
index 7be868c..4b98e88 100644
--- a/libc/arch-x86/syscalls/fstatat.S
+++ b/libc/arch-x86/syscalls/fstatat64.S
@@ -2,7 +2,7 @@
#include <private/bionic_asm.h>
-ENTRY(fstatat)
+ENTRY(fstatat64)
pushl %ebx
pushl %ecx
pushl %edx
@@ -31,4 +31,7 @@
popl %ecx
popl %ebx
ret
-END(fstatat)
+END(fstatat64)
+
+ .globl _C_LABEL(fstatat)
+ .equ _C_LABEL(fstatat), _C_LABEL(fstatat64)
diff --git a/libc/arch-x86_64/syscalls/fstat.S b/libc/arch-x86_64/syscalls/fstat64.S
similarity index 72%
rename from libc/arch-x86_64/syscalls/fstat.S
rename to libc/arch-x86_64/syscalls/fstat64.S
index 35f487d..1a2281b 100644
--- a/libc/arch-x86_64/syscalls/fstat.S
+++ b/libc/arch-x86_64/syscalls/fstat64.S
@@ -2,7 +2,7 @@
#include <private/bionic_asm.h>
-ENTRY(fstat)
+ENTRY(fstat64)
movl $__NR_fstat, %eax
syscall
cmpq $-MAX_ERRNO, %rax
@@ -13,4 +13,7 @@
orq $-1, %rax
1:
ret
-END(fstat)
+END(fstat64)
+
+ .globl _C_LABEL(fstat)
+ .equ _C_LABEL(fstat), _C_LABEL(fstat64)
diff --git a/libc/arch-x86_64/syscalls/fstatat.S b/libc/arch-x86_64/syscalls/fstatat64.S
similarity index 72%
rename from libc/arch-x86_64/syscalls/fstatat.S
rename to libc/arch-x86_64/syscalls/fstatat64.S
index c5d79bd..e429ecc 100644
--- a/libc/arch-x86_64/syscalls/fstatat.S
+++ b/libc/arch-x86_64/syscalls/fstatat64.S
@@ -2,7 +2,7 @@
#include <private/bionic_asm.h>
-ENTRY(fstatat)
+ENTRY(fstatat64)
movq %rcx, %r10
movl $__NR_newfstatat, %eax
syscall
@@ -14,4 +14,7 @@
orq $-1, %rax
1:
ret
-END(fstatat)
+END(fstatat64)
+
+ .globl _C_LABEL(fstatat)
+ .equ _C_LABEL(fstatat), _C_LABEL(fstatat64)
diff --git a/libc/arch-x86_64/syscalls/fstatfs.S b/libc/arch-x86_64/syscalls/fstatfs64.S
similarity index 70%
rename from libc/arch-x86_64/syscalls/fstatfs.S
rename to libc/arch-x86_64/syscalls/fstatfs64.S
index 59a90fb..fb3685a 100644
--- a/libc/arch-x86_64/syscalls/fstatfs.S
+++ b/libc/arch-x86_64/syscalls/fstatfs64.S
@@ -2,7 +2,7 @@
#include <private/bionic_asm.h>
-ENTRY(fstatfs)
+ENTRY(fstatfs64)
movl $__NR_fstatfs, %eax
syscall
cmpq $-MAX_ERRNO, %rax
@@ -13,4 +13,7 @@
orq $-1, %rax
1:
ret
-END(fstatfs)
+END(fstatfs64)
+
+ .globl _C_LABEL(fstatfs)
+ .equ _C_LABEL(fstatfs), _C_LABEL(fstatfs64)
diff --git a/libc/arch-x86_64/syscalls/statfs.S b/libc/arch-x86_64/syscalls/statfs64.S
similarity index 71%
rename from libc/arch-x86_64/syscalls/statfs.S
rename to libc/arch-x86_64/syscalls/statfs64.S
index 8b4b2e5..fd6d54f 100644
--- a/libc/arch-x86_64/syscalls/statfs.S
+++ b/libc/arch-x86_64/syscalls/statfs64.S
@@ -2,7 +2,7 @@
#include <private/bionic_asm.h>
-ENTRY(statfs)
+ENTRY(statfs64)
movl $__NR_statfs, %eax
syscall
cmpq $-MAX_ERRNO, %rax
@@ -13,4 +13,7 @@
orq $-1, %rax
1:
ret
-END(statfs)
+END(statfs64)
+
+ .globl _C_LABEL(statfs)
+ .equ _C_LABEL(statfs), _C_LABEL(statfs64)
diff --git a/libc/bionic/dirent.cpp b/libc/bionic/dirent.cpp
index 0565698..0f9b26a 100644
--- a/libc/bionic/dirent.cpp
+++ b/libc/bionic/dirent.cpp
@@ -105,6 +105,7 @@
ScopedPthreadMutexLocker locker(&d->mutex_);
return __readdir_locked(d);
}
+__strong_alias(readdir64, readdir);
int readdir_r(DIR* d, dirent* entry, dirent** result) {
ErrnoRestorer errno_restorer;
@@ -125,6 +126,7 @@
}
return 0;
}
+__strong_alias(readdir64_r, readdir_r);
int closedir(DIR* d) {
if (d == NULL) {
@@ -147,3 +149,4 @@
int alphasort(const dirent** a, const dirent** b) {
return strcoll((*a)->d_name, (*b)->d_name);
}
+__strong_alias(alphasort64, alphasort);
diff --git a/libc/bionic/legacy_32_bit_support.cpp b/libc/bionic/legacy_32_bit_support.cpp
index 411daa0..73f77be 100644
--- a/libc/bionic/legacy_32_bit_support.cpp
+++ b/libc/bionic/legacy_32_bit_support.cpp
@@ -59,11 +59,13 @@
int fstatfs(int fd, struct statfs* stat) {
return __fstatfs64(fd, sizeof(*stat), stat);
}
+__strong_alias(fstatfs64, fstatfs);
// For statfs we need to add the extra argument giving the kernel the size of the buffer.
int statfs(const char* path, struct statfs* stat) {
return __statfs64(path, sizeof(*stat), stat);
}
+__strong_alias(statfs64, statfs);
// For lseek64 we need to use the llseek system call which splits the off64_t in two and
// returns the off64_t result via a pointer because 32-bit kernels can't return 64-bit results.
diff --git a/libc/bionic/lstat.cpp b/libc/bionic/lstat.cpp
index 300d7fa..84d17e2 100644
--- a/libc/bionic/lstat.cpp
+++ b/libc/bionic/lstat.cpp
@@ -34,3 +34,4 @@
int lstat(const char* path, struct stat* sb) {
return fstatat(AT_FDCWD, path, sb, AT_SYMLINK_NOFOLLOW);
}
+__strong_alias(lstat64, lstat);
diff --git a/libc/bionic/open.cpp b/libc/bionic/open.cpp
index 986ed1c..bd832c0 100644
--- a/libc/bionic/open.cpp
+++ b/libc/bionic/open.cpp
@@ -43,6 +43,11 @@
#endif
}
+int creat(const char* pathname, mode_t mode) {
+ return open(pathname, O_CREAT | O_TRUNC | O_WRONLY, mode);
+}
+__strong_alias(creat64, creat);
+
int open(const char* pathname, int flags, ...) {
mode_t mode = 0;
@@ -55,6 +60,7 @@
return __openat(AT_FDCWD, pathname, force_O_LARGEFILE(flags), mode);
}
+__strong_alias(open64, open);
int __open_2(const char* pathname, int flags) {
if (__predict_false((flags & O_CREAT) != 0)) {
@@ -76,6 +82,7 @@
return __openat(fd, pathname, force_O_LARGEFILE(flags), mode);
}
+__strong_alias(openat64, openat);
int __openat_2(int fd, const char* pathname, int flags) {
if ((flags & O_CREAT) != 0) {
diff --git a/libc/bionic/scandir.cpp b/libc/bionic/scandir.cpp
index dd22b22..25d5200 100644
--- a/libc/bionic/scandir.cpp
+++ b/libc/bionic/scandir.cpp
@@ -113,3 +113,4 @@
*name_list = names.release();
return size;
}
+__strong_alias(scandir64, scandir);
diff --git a/libc/bionic/stat.cpp b/libc/bionic/stat.cpp
index 62387c5..e71d9d4 100644
--- a/libc/bionic/stat.cpp
+++ b/libc/bionic/stat.cpp
@@ -34,3 +34,4 @@
int stat(const char* path, struct stat* sb) {
return fstatat(AT_FDCWD, path, sb, 0);
}
+__strong_alias(stat64, stat);
diff --git a/libc/bionic/statvfs.cpp b/libc/bionic/statvfs.cpp
index 39c9332..f1e2833 100644
--- a/libc/bionic/statvfs.cpp
+++ b/libc/bionic/statvfs.cpp
@@ -53,6 +53,7 @@
__statfs_to_statvfs(tmp, result);
return 0;
}
+__strong_alias(statvfs64, statvfs);
int fstatvfs(int fd, struct statvfs* result) {
struct statfs tmp;
@@ -63,3 +64,4 @@
__statfs_to_statvfs(tmp, result);
return 0;
}
+__strong_alias(fstatvfs64, fstatvfs);
diff --git a/libc/include/dirent.h b/libc/include/dirent.h
index 129cdfa..bfe4ea4 100644
--- a/libc/include/dirent.h
+++ b/libc/include/dirent.h
@@ -46,27 +46,33 @@
#define DT_WHT 14
#endif
-struct dirent {
- uint64_t d_ino;
- int64_t d_off;
- unsigned short d_reclen;
- unsigned char d_type;
- char d_name[256];
-};
+#define __DIRENT64_BODY \
+ uint64_t d_ino; \
+ int64_t d_off; \
+ unsigned short d_reclen; \
+ unsigned char d_type; \
+ char d_name[256]; \
+
+struct dirent { __DIRENT64_BODY };
+struct dirent64 { __DIRENT64_BODY };
+
#define d_fileno d_ino
-#define dirent64 dirent
typedef struct DIR DIR;
extern DIR* opendir(const char*);
extern DIR* fdopendir(int);
extern struct dirent* readdir(DIR*);
+extern struct dirent64* readdir64(DIR*);
extern int readdir_r(DIR*, struct dirent*, struct dirent**);
+extern int readdir64_r(DIR*, struct dirent64*, struct dirent64**);
extern int closedir(DIR*);
extern void rewinddir(DIR*);
extern int dirfd(DIR*);
extern int alphasort(const struct dirent**, const struct dirent**);
+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 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
diff --git a/libc/include/fcntl.h b/libc/include/fcntl.h
index b7b91f2..e37e0a7 100644
--- a/libc/include/fcntl.h
+++ b/libc/include/fcntl.h
@@ -42,11 +42,14 @@
#endif
extern int creat(const char*, mode_t);
+extern int creat64(const char*, mode_t);
extern int fallocate64(int, int, off64_t, off64_t);
extern int fallocate(int, int, off_t, off_t);
extern int fcntl(int, int, ...);
extern int openat(int, const char*, int, ...);
+extern int openat64(int, const char*, int, ...);
extern int open(const char*, int, ...);
+extern int open64(const char*, int, ...);
extern int posix_fallocate64(int, off64_t, off64_t);
extern int posix_fallocate(int, off_t, off_t);
extern int unlinkat(int, const char*, int);
diff --git a/libc/include/sys/stat.h b/libc/include/sys/stat.h
index 37b8dc2..10bd01f 100644
--- a/libc/include/sys/stat.h
+++ b/libc/include/sys/stat.h
@@ -38,101 +38,101 @@
__BEGIN_DECLS
#if defined(__aarch64__)
-struct stat {
- unsigned long st_dev;
- unsigned long st_ino;
- unsigned int st_mode;
- unsigned int st_nlink;
- unsigned int st_uid;
- unsigned int st_gid;
- unsigned long st_rdev;
- unsigned long __pad1;
- long st_size;
- int st_blksize;
- int __pad2;
- long st_blocks;
- long st_atime;
- unsigned long st_atime_nsec;
- long st_mtime;
- unsigned long st_mtime_nsec;
- long st_ctime;
- unsigned long st_ctime_nsec;
- unsigned int __unused4;
- unsigned int __unused5;
-};
+#define __STAT64_BODY \
+ unsigned long st_dev; \
+ unsigned long st_ino; \
+ unsigned int st_mode; \
+ unsigned int st_nlink; \
+ unsigned int st_uid; \
+ unsigned int st_gid; \
+ unsigned long st_rdev; \
+ unsigned long __pad1; \
+ long st_size; \
+ int st_blksize; \
+ int __pad2; \
+ long st_blocks; \
+ long st_atime; \
+ unsigned long st_atime_nsec; \
+ long st_mtime; \
+ unsigned long st_mtime_nsec; \
+ long st_ctime; \
+ unsigned long st_ctime_nsec; \
+ unsigned int __unused4; \
+ unsigned int __unused5; \
+
#elif defined(__mips__)
-struct stat {
- unsigned int st_dev;
- unsigned int __pad0[3];
- unsigned long long st_ino;
- unsigned int st_mode;
- unsigned int st_nlink;
- unsigned int st_uid;
- unsigned int st_gid;
- unsigned int st_rdev;
- unsigned int __pad1[3];
- long long st_size;
- unsigned int st_atime;
- unsigned int st_atime_nsec;
- unsigned int st_mtime;
- unsigned int st_mtime_nsec;
- unsigned int st_ctime;
- unsigned int st_ctime_nsec;
- unsigned int st_blksize;
- unsigned int __pad2;
- unsigned long long st_blocks;
-};
+#define __STAT64_BODY \
+ unsigned int st_dev; \
+ unsigned int __pad0[3]; \
+ unsigned long long st_ino; \
+ unsigned int st_mode; \
+ unsigned int st_nlink; \
+ unsigned int st_uid; \
+ unsigned int st_gid; \
+ unsigned int st_rdev; \
+ unsigned int __pad1[3]; \
+ long long st_size; \
+ unsigned int st_atime; \
+ unsigned int st_atime_nsec; \
+ unsigned int st_mtime; \
+ unsigned int st_mtime_nsec; \
+ unsigned int st_ctime; \
+ unsigned int st_ctime_nsec; \
+ unsigned int st_blksize; \
+ unsigned int __pad2; \
+ unsigned long long st_blocks; \
+
#elif defined(__x86_64__)
-struct stat {
- unsigned long st_dev;
- unsigned long st_ino;
- unsigned long st_nlink;
- unsigned int st_mode;
- unsigned int st_uid;
- unsigned int st_gid;
- unsigned int __pad0;
- unsigned long st_rdev;
- long st_size;
- long st_blksize;
- long st_blocks;
- unsigned long st_atime;
- unsigned long st_atime_nsec;
- unsigned long st_mtime;
- unsigned long st_mtime_nsec;
- unsigned long st_ctime;
- unsigned long st_ctime_nsec;
- long __pad3[3];
-};
+#define __STAT64_BODY \
+ unsigned long st_dev; \
+ unsigned long st_ino; \
+ unsigned long st_nlink; \
+ unsigned int st_mode; \
+ unsigned int st_uid; \
+ unsigned int st_gid; \
+ unsigned int __pad0; \
+ unsigned long st_rdev; \
+ long st_size; \
+ long st_blksize; \
+ long st_blocks; \
+ unsigned long st_atime; \
+ unsigned long st_atime_nsec; \
+ unsigned long st_mtime; \
+ unsigned long st_mtime_nsec; \
+ unsigned long st_ctime; \
+ unsigned long st_ctime_nsec; \
+ long __pad3[3]; \
+
#else
-struct stat {
- unsigned long long st_dev;
- unsigned char __pad0[4];
- unsigned long __st_ino;
- unsigned int st_mode;
- unsigned int st_nlink;
- unsigned long st_uid;
- unsigned long st_gid;
- unsigned long long st_rdev;
- unsigned char __pad3[4];
- long long st_size;
- unsigned long st_blksize;
- unsigned long long st_blocks;
- unsigned long st_atime;
- unsigned long st_atime_nsec;
- unsigned long st_mtime;
- unsigned long st_mtime_nsec;
- unsigned long st_ctime;
- unsigned long st_ctime_nsec;
- unsigned long long st_ino;
-};
+#define __STAT64_BODY \
+ unsigned long long st_dev; \
+ unsigned char __pad0[4]; \
+ unsigned long __st_ino; \
+ unsigned int st_mode; \
+ unsigned int st_nlink; \
+ unsigned long st_uid; \
+ unsigned long st_gid; \
+ unsigned long long st_rdev; \
+ unsigned char __pad3[4]; \
+ long long st_size; \
+ unsigned long st_blksize; \
+ unsigned long long st_blocks; \
+ unsigned long st_atime; \
+ unsigned long st_atime_nsec; \
+ unsigned long st_mtime; \
+ unsigned long st_mtime_nsec; \
+ unsigned long st_ctime; \
+ unsigned long st_ctime_nsec; \
+ unsigned long long st_ino; \
+
#endif
-/* For compatibility with GLibc, we provide macro aliases
- * for the non-Posix nano-seconds accessors.
- */
-#define st_atimensec st_atime_nsec
-#define st_mtimensec st_mtime_nsec
-#define st_ctimensec st_ctime_nsec
+struct stat { __STAT64_BODY };
+struct stat64 { __STAT64_BODY };
+
+#define st_atimensec st_atime_nsec
+#define st_mtimensec st_mtime_nsec
+#define st_ctimensec st_ctime_nsec
#ifdef __USE_BSD
/* Permission macros provided by glibc for compatibility with BSDs. */
@@ -141,21 +141,26 @@
#define DEFFILEMODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH) /* 0666 */
#endif
-extern int chmod(const char *, mode_t);
-extern int fchmod(int, mode_t);
-extern int mkdir(const char *, mode_t);
+extern int chmod(const char*, mode_t);
+extern int fchmod(int, mode_t);
+extern int mkdir(const char*, mode_t);
-extern int stat(const char *, struct stat *);
-extern int fstat(int, struct stat *);
-extern int lstat(const char *, struct stat *);
-extern int mknod(const char *, mode_t, dev_t);
+extern int fstat(int, struct stat*);
+extern int fstat64(int, struct stat64*);
+extern int fstatat(int, const char*, struct stat*, int);
+extern int fstatat64(int, const char*, struct stat64*, int);
+extern int lstat(const char*, struct stat*);
+extern int lstat64(const char*, struct stat64*);
+extern int stat(const char*, struct stat*);
+extern int stat64(const char*, struct stat64*);
+
+extern int mknod(const char*, mode_t, dev_t);
extern mode_t umask(mode_t);
#if defined(__BIONIC_FORTIFY)
extern mode_t __umask_chk(mode_t);
-extern mode_t __umask_real(mode_t)
- __asm__(__USER_LABEL_PREFIX__ "umask");
+extern mode_t __umask_real(mode_t) __asm__(__USER_LABEL_PREFIX__ "umask");
__errordecl(__umask_invalid_mode, "umask called with invalid mode");
__BIONIC_FORTIFY_INLINE
@@ -172,20 +177,14 @@
}
#endif /* defined(__BIONIC_FORTIFY) */
-
-#define stat64 stat
-#define fstat64 fstat
-#define lstat64 lstat
-
extern int mkfifo(const char*, mode_t);
extern int fchmodat(int, const char*, mode_t, int);
-extern int fstatat(int, const char*, struct stat*, int);
extern int mkdirat(int, const char*, mode_t);
extern int mknodat(int, const char*, mode_t, dev_t);
-# define UTIME_NOW ((1l << 30) - 1l)
-# define UTIME_OMIT ((1l << 30) - 2l)
+#define UTIME_NOW ((1L << 30) - 1L)
+#define UTIME_OMIT ((1L << 30) - 2L)
extern int utimensat(int fd, const char *path, const struct timespec times[2], int flags);
extern int futimens(int fd, const struct timespec times[2]);
diff --git a/libc/include/sys/statvfs.h b/libc/include/sys/statvfs.h
index e910c03..3d8179e 100644
--- a/libc/include/sys/statvfs.h
+++ b/libc/include/sys/statvfs.h
@@ -23,19 +23,21 @@
__BEGIN_DECLS
-struct statvfs {
- unsigned long f_bsize;
- unsigned long f_frsize;
- fsblkcnt_t f_blocks;
- fsblkcnt_t f_bfree;
- fsblkcnt_t f_bavail;
- fsfilcnt_t f_files;
- fsfilcnt_t f_ffree;
- fsfilcnt_t f_favail;
- unsigned long f_fsid;
- unsigned long f_flag;
- unsigned long f_namemax;
-};
+#define __STATVFS64_BODY \
+ unsigned long f_bsize; \
+ unsigned long f_frsize; \
+ fsblkcnt_t f_blocks; \
+ fsblkcnt_t f_bfree; \
+ fsblkcnt_t f_bavail; \
+ fsfilcnt_t f_files; \
+ fsfilcnt_t f_ffree; \
+ fsfilcnt_t f_favail; \
+ unsigned long f_fsid; \
+ unsigned long f_flag; \
+ unsigned long f_namemax; \
+
+struct statvfs { __STATVFS64_BODY };
+struct statvfs64 { __STATVFS64_BODY };
#define ST_RDONLY 0x0001
#define ST_NOSUID 0x0002
@@ -48,7 +50,9 @@
#define ST_RELATIME 0x1000
extern int statvfs(const char* __restrict, struct statvfs* __restrict) __nonnull((1, 2));
+extern int statvfs64(const char* __restrict, struct statvfs64* __restrict) __nonnull((1, 2));
extern int fstatvfs(int, struct statvfs*) __nonnull((2));
+extern int fstatvfs64(int, struct statvfs64*) __nonnull((2));
__END_DECLS
diff --git a/libc/include/sys/vfs.h b/libc/include/sys/vfs.h
index 10afbc3..cd6044d 100644
--- a/libc/include/sys/vfs.h
+++ b/libc/include/sys/vfs.h
@@ -39,73 +39,73 @@
typedef __fsid_t fsid_t;
#if defined(__aarch64__) || defined(__x86_64__)
-struct statfs {
- uint64_t f_type;
- uint64_t f_bsize;
- uint64_t f_blocks;
- uint64_t f_bfree;
- uint64_t f_bavail;
- uint64_t f_files;
- uint64_t f_ffree;
- fsid_t f_fsid;
- uint64_t f_namelen;
- uint64_t f_frsize;
- uint64_t f_flags;
- uint64_t f_spare[4];
-};
+#define __STATFS64_BODY \
+ uint64_t f_type; \
+ uint64_t f_bsize; \
+ uint64_t f_blocks; \
+ uint64_t f_bfree; \
+ uint64_t f_bavail; \
+ uint64_t f_files; \
+ uint64_t f_ffree; \
+ fsid_t f_fsid; \
+ uint64_t f_namelen; \
+ uint64_t f_frsize; \
+ uint64_t f_flags; \
+ uint64_t f_spare[4]; \
+
#elif defined(__mips__) && defined(__LP64__)
/* 64-bit MIPS. */
-struct statfs {
- uint64_t f_type;
- uint64_t f_bsize;
- uint64_t f_frsize; /* Fragment size - unsupported. */
- uint64_t f_blocks;
- uint64_t f_bfree;
- uint64_t f_files;
- uint64_t f_ffree;
- uint64_t f_bavail;
- fsid_t f_fsid;
- uint64_t f_namelen;
- uint64_t f_flags;
- uint64_t f_spare[5];
-};
+#define __STATFS64_BODY \
+ uint64_t f_type; \
+ uint64_t f_bsize; \
+ uint64_t f_frsize; /* Fragment size - unsupported. */ \
+ uint64_t f_blocks; \
+ uint64_t f_bfree; \
+ uint64_t f_files; \
+ uint64_t f_ffree; \
+ uint64_t f_bavail; \
+ fsid_t f_fsid; \
+ uint64_t f_namelen; \
+ uint64_t f_flags; \
+ uint64_t f_spare[5]; \
+
#elif defined(__mips__)
/* 32-bit MIPS (corresponds to the kernel's statfs64 type). */
-struct statfs {
- uint32_t f_type;
- uint32_t f_bsize;
- uint32_t f_frsize;
- uint32_t __pad;
- uint64_t f_blocks;
- uint64_t f_bfree;
- uint64_t f_files;
- uint64_t f_ffree;
- uint64_t f_bavail;
- fsid_t f_fsid;
- uint32_t f_namelen;
- uint32_t f_flags;
- uint32_t f_spare[5];
-};
+#define __STATFS64_BODY \
+ uint32_t f_type; \
+ uint32_t f_bsize; \
+ uint32_t f_frsize; \
+ uint32_t __pad; \
+ uint64_t f_blocks; \
+ uint64_t f_bfree; \
+ uint64_t f_files; \
+ uint64_t f_ffree; \
+ uint64_t f_bavail; \
+ fsid_t f_fsid; \
+ uint32_t f_namelen; \
+ uint32_t f_flags; \
+ uint32_t f_spare[5]; \
+
#else
/* 32-bit ARM or x86 (corresponds to the kernel's statfs64 type). */
-struct statfs {
- uint32_t f_type;
- uint32_t f_bsize;
- uint64_t f_blocks;
- uint64_t f_bfree;
- uint64_t f_bavail;
- uint64_t f_files;
- uint64_t f_ffree;
- fsid_t f_fsid;
- uint32_t f_namelen;
- uint32_t f_frsize;
- uint32_t f_flags;
- uint32_t f_spare[4];
-};
+#define __STATFS64_BODY \
+ uint32_t f_type; \
+ uint32_t f_bsize; \
+ uint64_t f_blocks; \
+ uint64_t f_bfree; \
+ uint64_t f_bavail; \
+ uint64_t f_files; \
+ uint64_t f_ffree; \
+ fsid_t f_fsid; \
+ uint32_t f_namelen; \
+ uint32_t f_frsize; \
+ uint32_t f_flags; \
+ uint32_t f_spare[4]; \
+
#endif
-/* Source compatibility with glibc. */
-#define statfs64 statfs
+struct statfs { __STATFS64_BODY };
+struct statfs64 { __STATFS64_BODY };
/* Declare that we have the f_namelen, f_frsize, and f_flags fields. */
#define _STATFS_F_NAMELEN
@@ -158,7 +158,9 @@
#define _XIAFS_SUPER_MAGIC 0x012FD16D
extern int statfs(const char*, struct statfs*) __nonnull((1, 2));
+extern int statfs64(const char*, struct statfs64*) __nonnull((1, 2));
extern int fstatfs(int, struct statfs*) __nonnull((2));
+extern int fstatfs64(int, struct statfs64*) __nonnull((2));
__END_DECLS
diff --git a/libc/tools/bionic_utils.py b/libc/tools/bionic_utils.py
index def04a6..c38efb5 100644
--- a/libc/tools/bionic_utils.py
+++ b/libc/tools/bionic_utils.py
@@ -130,7 +130,7 @@
if arch in all_arches:
t[arch] = True
else:
- E("invalid syscall architecture list in '%s'" % line)
+ E("invalid syscall architecture '%s' in '%s'" % (arch, line))
return
self.syscalls.append(t)
diff --git a/libc/upstream-netbsd/libc/compat-43/creat.c b/libc/upstream-netbsd/libc/compat-43/creat.c
deleted file mode 100644
index 9560bea..0000000
--- a/libc/upstream-netbsd/libc/compat-43/creat.c
+++ /dev/null
@@ -1,52 +0,0 @@
-/* $NetBSD: creat.c,v 1.10 2003/08/07 16:42:39 agc Exp $ */
-
-/*
- * Copyright (c) 1989, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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 <sys/cdefs.h>
-#if defined(LIBC_SCCS) && !defined(lint)
-#if 0
-static char sccsid[] = "@(#)creat.c 8.1 (Berkeley) 6/2/93";
-#else
-__RCSID("$NetBSD: creat.c,v 1.10 2003/08/07 16:42:39 agc Exp $");
-#endif
-#endif /* LIBC_SCCS and not lint */
-
-#include <assert.h>
-#include <errno.h>
-#include <fcntl.h>
-
-int
-creat(const char *path, mode_t mode)
-{
-
- _DIAGASSERT(path != NULL);
-
- return(open(path, O_WRONLY|O_CREAT|O_TRUNC, mode));
-}