From f8fcfbc85a3ce3e195626b90736d3a484331494b Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Tue, 22 Oct 2013 13:28:46 -0700 Subject: [PATCH] Move away from the __ARCH_WANT_SYSCALL_NO_AT system calls. Modern architectures only get the *at(2) system calls. For example, aarch64 doesn't have open(2), and expects userspace to use openat(2) instead. Change-Id: I87b4ed79790cb8a80844f5544ac1a13fda26c7b5 --- libc/Android.mk | 18 ++++++- libc/SYSCALLS.TXT | 45 ++++++----------- libc/arch-arm/syscalls.mk | 19 ++----- libc/arch-arm/syscalls/link.S | 16 ------ libc/arch-arm/syscalls/{lchown.S => linkat.S} | 13 +++-- libc/arch-arm/syscalls/lstat.S | 16 ------ libc/arch-arm/syscalls/mkdir.S | 16 ------ libc/arch-arm/syscalls/mknod.S | 16 ------ .../arch-arm/syscalls/{access.S => mknodat.S} | 6 +-- libc/arch-arm/syscalls/readlink.S | 16 ------ .../syscalls/{chown.S => readlinkat.S} | 6 +-- libc/arch-arm/syscalls/rename.S | 16 ------ libc/arch-arm/syscalls/rmdir.S | 16 ------ libc/arch-arm/syscalls/stat.S | 16 ------ libc/arch-arm/syscalls/symlink.S | 16 ------ .../syscalls/{chmod.S => symlinkat.S} | 6 +-- libc/arch-arm/syscalls/unlink.S | 16 ------ libc/arch-arm/syscalls/utimes.S | 16 ------ libc/arch-mips/syscalls.mk | 19 ++----- libc/arch-mips/syscalls/link.S | 23 --------- .../arch-mips/syscalls/{access.S => linkat.S} | 10 ++-- libc/arch-mips/syscalls/lstat.S | 23 --------- libc/arch-mips/syscalls/mkdir.S | 23 --------- libc/arch-mips/syscalls/mknod.S | 23 --------- .../arch-mips/syscalls/{chmod.S => mknodat.S} | 10 ++-- libc/arch-mips/syscalls/readlink.S | 23 --------- .../syscalls/{lchown.S => readlinkat.S} | 10 ++-- libc/arch-mips/syscalls/rename.S | 23 --------- libc/arch-mips/syscalls/rmdir.S | 23 --------- libc/arch-mips/syscalls/stat.S | 23 --------- libc/arch-mips/syscalls/symlink.S | 23 --------- .../syscalls/{chown.S => symlinkat.S} | 10 ++-- libc/arch-mips/syscalls/unlink.S | 23 --------- libc/arch-mips/syscalls/utimes.S | 23 --------- libc/arch-x86/syscalls.mk | 19 ++----- libc/arch-x86/syscalls/access.S | 25 ---------- libc/arch-x86/syscalls/chmod.S | 25 ---------- libc/arch-x86/syscalls/link.S | 25 ---------- libc/arch-x86/syscalls/{lchown.S => linkat.S} | 18 ++++--- libc/arch-x86/syscalls/lstat.S | 25 ---------- libc/arch-x86/syscalls/mkdir.S | 25 ---------- .../syscalls/{readlink.S => mknodat.S} | 15 +++--- .../syscalls/{chown.S => readlinkat.S} | 15 +++--- libc/arch-x86/syscalls/rename.S | 25 ---------- libc/arch-x86/syscalls/rmdir.S | 22 -------- libc/arch-x86/syscalls/stat.S | 25 ---------- libc/arch-x86/syscalls/symlink.S | 25 ---------- .../syscalls/{mknod.S => symlinkat.S} | 6 +-- libc/arch-x86/syscalls/unlink.S | 22 -------- libc/arch-x86/syscalls/utimes.S | 25 ---------- libc/arch-x86_64/syscalls.mk | 21 ++------ .../syscalls/{access.S => fstatat.S} | 7 +-- libc/arch-x86_64/syscalls/lchown.S | 18 ------- libc/arch-x86_64/syscalls/link.S | 18 ------- .../syscalls/{chmod.S => linkat.S} | 7 +-- libc/arch-x86_64/syscalls/lstat.S | 18 ------- libc/arch-x86_64/syscalls/mkdir.S | 18 ------- libc/arch-x86_64/syscalls/mknod.S | 18 ------- .../syscalls/{chown.S => mknodat.S} | 7 +-- libc/arch-x86_64/syscalls/readlink.S | 18 ------- libc/arch-x86_64/syscalls/readlinkat.S | 19 +++++++ libc/arch-x86_64/syscalls/rename.S | 18 ------- libc/arch-x86_64/syscalls/rmdir.S | 18 ------- libc/arch-x86_64/syscalls/stat.S | 18 ------- libc/arch-x86_64/syscalls/symlink.S | 18 ------- .../syscalls/{__open.S => symlinkat.S} | 6 +-- libc/arch-x86_64/syscalls/unlink.S | 18 ------- libc/arch-x86_64/syscalls/utimes.S | 18 ------- libc/bionic/{open.c => access.cpp} | 35 ++----------- libc/bionic/chmod.cpp | 35 +++++++++++++ libc/bionic/chown.cpp | 35 +++++++++++++ libc/bionic/lchown.cpp | 35 +++++++++++++ libc/bionic/link.cpp | 34 +++++++++++++ libc/bionic/lstat.cpp | 36 +++++++++++++ libc/bionic/mkdir.cpp | 35 +++++++++++++ libc/bionic/mknod.cpp | 36 +++++++++++++ libc/bionic/{openat.c => open.cpp} | 31 +++++++++++- libc/bionic/readlink.cpp | 35 +++++++++++++ libc/bionic/rename.cpp | 34 +++++++++++++ libc/bionic/rmdir.cpp | 34 +++++++++++++ libc/bionic/stat.cpp | 36 +++++++++++++ libc/bionic/symlink.cpp | 34 +++++++++++++ libc/bionic/unlink.cpp | 34 +++++++++++++ libc/bionic/utimes.cpp | 50 +++++++++++++++++++ libc/include/stdio.h | 3 +- libc/include/sys/stat.h | 9 ++-- libc/include/unistd.h | 17 ++++--- tests/Android.mk | 1 + tests/sys_time_test.cpp | 40 +++++++++++++++ 89 files changed, 748 insertions(+), 1117 deletions(-) delete mode 100644 libc/arch-arm/syscalls/link.S rename libc/arch-arm/syscalls/{lchown.S => linkat.S} (53%) delete mode 100644 libc/arch-arm/syscalls/lstat.S delete mode 100644 libc/arch-arm/syscalls/mkdir.S delete mode 100644 libc/arch-arm/syscalls/mknod.S rename libc/arch-arm/syscalls/{access.S => mknodat.S} (82%) delete mode 100644 libc/arch-arm/syscalls/readlink.S rename libc/arch-arm/syscalls/{chown.S => readlinkat.S} (79%) delete mode 100644 libc/arch-arm/syscalls/rename.S delete mode 100644 libc/arch-arm/syscalls/rmdir.S delete mode 100644 libc/arch-arm/syscalls/stat.S delete mode 100644 libc/arch-arm/syscalls/symlink.S rename libc/arch-arm/syscalls/{chmod.S => symlinkat.S} (80%) delete mode 100644 libc/arch-arm/syscalls/unlink.S delete mode 100644 libc/arch-arm/syscalls/utimes.S delete mode 100644 libc/arch-mips/syscalls/link.S rename libc/arch-mips/syscalls/{access.S => linkat.S} (75%) delete mode 100644 libc/arch-mips/syscalls/lstat.S delete mode 100644 libc/arch-mips/syscalls/mkdir.S delete mode 100644 libc/arch-mips/syscalls/mknod.S rename libc/arch-mips/syscalls/{chmod.S => mknodat.S} (74%) delete mode 100644 libc/arch-mips/syscalls/readlink.S rename libc/arch-mips/syscalls/{lchown.S => readlinkat.S} (71%) delete mode 100644 libc/arch-mips/syscalls/rename.S delete mode 100644 libc/arch-mips/syscalls/rmdir.S delete mode 100644 libc/arch-mips/syscalls/stat.S delete mode 100644 libc/arch-mips/syscalls/symlink.S rename libc/arch-mips/syscalls/{chown.S => symlinkat.S} (72%) delete mode 100644 libc/arch-mips/syscalls/unlink.S delete mode 100644 libc/arch-mips/syscalls/utimes.S delete mode 100644 libc/arch-x86/syscalls/access.S delete mode 100644 libc/arch-x86/syscalls/chmod.S delete mode 100644 libc/arch-x86/syscalls/link.S rename libc/arch-x86/syscalls/{lchown.S => linkat.S} (60%) delete mode 100644 libc/arch-x86/syscalls/lstat.S delete mode 100644 libc/arch-x86/syscalls/mkdir.S rename libc/arch-x86/syscalls/{readlink.S => mknodat.S} (66%) rename libc/arch-x86/syscalls/{chown.S => readlinkat.S} (65%) delete mode 100644 libc/arch-x86/syscalls/rename.S delete mode 100644 libc/arch-x86/syscalls/rmdir.S delete mode 100644 libc/arch-x86/syscalls/stat.S delete mode 100644 libc/arch-x86/syscalls/symlink.S rename libc/arch-x86/syscalls/{mknod.S => symlinkat.S} (87%) delete mode 100644 libc/arch-x86/syscalls/unlink.S delete mode 100644 libc/arch-x86/syscalls/utimes.S rename libc/arch-x86_64/syscalls/{access.S => fstatat.S} (76%) delete mode 100644 libc/arch-x86_64/syscalls/lchown.S delete mode 100644 libc/arch-x86_64/syscalls/link.S rename libc/arch-x86_64/syscalls/{chmod.S => linkat.S} (77%) delete mode 100644 libc/arch-x86_64/syscalls/lstat.S delete mode 100644 libc/arch-x86_64/syscalls/mkdir.S delete mode 100644 libc/arch-x86_64/syscalls/mknod.S rename libc/arch-x86_64/syscalls/{chown.S => mknodat.S} (76%) delete mode 100644 libc/arch-x86_64/syscalls/readlink.S create mode 100644 libc/arch-x86_64/syscalls/readlinkat.S delete mode 100644 libc/arch-x86_64/syscalls/rename.S delete mode 100644 libc/arch-x86_64/syscalls/rmdir.S delete mode 100644 libc/arch-x86_64/syscalls/stat.S delete mode 100644 libc/arch-x86_64/syscalls/symlink.S rename libc/arch-x86_64/syscalls/{__open.S => symlinkat.S} (80%) delete mode 100644 libc/arch-x86_64/syscalls/unlink.S delete mode 100644 libc/arch-x86_64/syscalls/utimes.S rename libc/bionic/{open.c => access.cpp} (67%) create mode 100644 libc/bionic/chmod.cpp create mode 100644 libc/bionic/chown.cpp create mode 100644 libc/bionic/lchown.cpp create mode 100644 libc/bionic/link.cpp create mode 100644 libc/bionic/lstat.cpp create mode 100644 libc/bionic/mkdir.cpp create mode 100644 libc/bionic/mknod.cpp rename libc/bionic/{openat.c => open.cpp} (77%) create mode 100644 libc/bionic/readlink.cpp create mode 100644 libc/bionic/rename.cpp create mode 100644 libc/bionic/rmdir.cpp create mode 100644 libc/bionic/stat.cpp create mode 100644 libc/bionic/symlink.cpp create mode 100644 libc/bionic/unlink.cpp create mode 100644 libc/bionic/utimes.cpp create mode 100644 tests/sys_time_test.cpp diff --git a/libc/Android.mk b/libc/Android.mk index 33f236206..a37c9bcf1 100644 --- a/libc/Android.mk +++ b/libc/Android.mk @@ -104,8 +104,6 @@ libc_common_src_files := \ bionic/md5.c \ bionic/memmem.c \ bionic/memswap.c \ - bionic/openat.c \ - bionic/open.c \ bionic/pathconf.c \ bionic/perror.c \ bionic/pread.c \ @@ -211,8 +209,11 @@ libc_common_src_files += \ libc_bionic_src_files := \ bionic/abort.cpp \ + bionic/access.cpp \ bionic/assert.cpp \ bionic/brk.cpp \ + bionic/chmod.cpp \ + bionic/chown.cpp \ bionic/dirent.cpp \ bionic/__errno.cpp \ bionic/eventfd_read.cpp \ @@ -221,10 +222,16 @@ libc_bionic_src_files := \ bionic/futimens.cpp \ bionic/getauxval.cpp \ bionic/getcwd.cpp \ + bionic/lchown.cpp \ bionic/libc_init_common.cpp \ bionic/libc_logging.cpp \ bionic/libgen.cpp \ + bionic/link.cpp \ + bionic/lstat.cpp \ + bionic/mkdir.cpp \ bionic/mkfifo.cpp \ + bionic/mknod.cpp \ + bionic/open.cpp \ bionic/pthread_attr.cpp \ bionic/pthread_detach.cpp \ bionic/pthread_equal.cpp \ @@ -238,6 +245,9 @@ libc_bionic_src_files := \ bionic/pthread_setschedparam.cpp \ bionic/pthread_sigmask.cpp \ bionic/raise.cpp \ + bionic/readlink.cpp \ + bionic/rename.cpp \ + bionic/rmdir.cpp \ bionic/sbrk.cpp \ bionic/scandir.cpp \ bionic/sched_getaffinity.cpp \ @@ -257,15 +267,19 @@ libc_bionic_src_files := \ bionic/sigprocmask.cpp \ bionic/sigsuspend.cpp \ bionic/sigwait.cpp \ + bionic/stat.cpp \ bionic/statvfs.cpp \ bionic/strerror.cpp \ bionic/strerror_r.cpp \ bionic/strsignal.cpp \ bionic/stubs.cpp \ + bionic/symlink.cpp \ bionic/sysconf.cpp \ bionic/tdestroy.cpp \ bionic/__thread_entry.cpp \ bionic/tmpfile.cpp \ + bionic/unlink.cpp \ + bionic/utimes.cpp \ bionic/wait.cpp \ bionic/wchar.cpp \ diff --git a/libc/SYSCALLS.TXT b/libc/SYSCALLS.TXT index d9a250672..504f190f8 100644 --- a/libc/SYSCALLS.TXT +++ b/libc/SYSCALLS.TXT @@ -34,6 +34,7 @@ pid_t wait4(pid_t pid, int* status, int options, struct rusage* rusage) all pid_t __sys_clone:clone(int, void*, int*, void*, int*) all pid_t _waitpid:waitpid(pid_t, int*, int, struct rusage*) mips,x86 int __waitid:waitid(int, pid_t, struct siginfo_t*, int, void*) all +int __open:open(const char*, int, mode_t) arm,mips,x86 int execve(const char*, char* const*, char* const*) all @@ -101,8 +102,6 @@ ssize_t read(int, void*, size_t) all ssize_t write(int, const void*, size_t) all ssize_t pread64(int, void*, size_t, off64_t) all ssize_t pwrite64(int, void*, size_t, off64_t) all -int __open:open(const char*, int, mode_t) all -int __openat:openat(int, const char*, int, mode_t) all int close(int) all pid_t getpid() all void* mmap(void*, size_t, int, int, int, long) x86_64 @@ -139,16 +138,26 @@ void sync(void) all int __fcntl64:fcntl64(int, int, void*) arm,x86,mips int __fstatfs64:fstatfs64(int, size_t, struct statfs*) arm,x86,mips int fstatfs(int, struct statfs*) x86_64 -int fstatat:fstatat64(int dirfd, const char* path, struct stat* buf, int flags) arm,x86,mips -int mkdirat(int dirfd, const char* pathname, mode_t mode) all -int fchownat(int dirfd, const char* path, uid_t owner, gid_t group, int flags) all -int fchmodat(int dirfd, const char* path, mode_t mode, int flags) all -int renameat(int olddirfd, const char* oldpath, int newdirfd, const char* newpath) all 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 int fremovexattr(int, const char*) all +int __openat:openat(int, const char*, int, mode_t) all +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,x86,mips +int fstatat:newfstatat(int, const char*, struct stat*, int) 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 +int readlinkat(int, const char*, char*, size_t) all +int renameat(int, const char*, int, const char*) all +int symlinkat(const char*, int, const char*) all +int unlinkat(int, const char*, int) all +int utimensat(int, const char*, const struct timespec times[2], int) all + # Paired off_t/off64_t system calls. On 64-bit systems, # sizeof(off_t) == sizeof(off64_t), so there we emit two symbols that are # aliases. On 32-bit systems, we have two different system calls. @@ -167,32 +176,12 @@ int truncate64(const char*, off64_t) arm,mips,x86 int truncate|truncate64(const char*, off_t) x86_64 # file system -int link(const char*, const char*) all -int unlink(const char*) all -int unlinkat(int, const char*, int) all int chdir(const char*) all -int mknod(const char*, mode_t, dev_t) all -int chmod(const char*, mode_t) all -int chown:chown32(const char*, uid_t, gid_t) arm,x86 -int chown:chown(const char*, uid_t, gid_t) mips,x86_64 -int lchown:lchown32(const char*, uid_t, gid_t) arm,x86 -int lchown:lchown(const char*, uid_t, gid_t) mips,x86_64 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,x86,mips int fstat(int, struct stat*) x86_64 -int stat:stat64(const char*, struct stat*) arm,x86,mips -int stat(const char*, struct stat*) x86_64 -int lstat:lstat64(const char*, struct stat*) arm,x86,mips -int lstat(const char*, struct stat*) x86_64 -int mkdir(const char*, mode_t) all -int readlink(const char*, char*, size_t) all -int rmdir(const char*) all -int rename(const char*, const char*) all int __getcwd:getcwd(char* buf, size_t size) all -int access(const char*, int) all -int faccessat(int, const char*, int, int) all -int symlink(const char*, const char*) all int fchdir(int) all int setxattr(const char*, const char*, const void*, size_t, int) all int lsetxattr(const char*, const char*, const void*, size_t, int) all @@ -225,8 +214,6 @@ int __timer_settime:timer_settime(timer_t, int, const struct itimerspe int __timer_gettime:timer_gettime(timer_t, struct itimerspec*) all int __timer_getoverrun:timer_getoverrun(timer_t) all int __timer_delete:timer_delete(timer_t) all -int utimes(const char*, const struct timeval tvp[2]) all -int utimensat(int, const char*, const struct timespec times[2], int) all int timerfd_create(clockid_t, int) all int timerfd_settime(int, int, const struct itimerspec*, struct itimerspec*) all int timerfd_gettime(int, struct itimerspec*) all diff --git a/libc/arch-arm/syscalls.mk b/libc/arch-arm/syscalls.mk index f9d348b4f..a59d064a7 100644 --- a/libc/arch-arm/syscalls.mk +++ b/libc/arch-arm/syscalls.mk @@ -35,15 +35,12 @@ syscall_src += arch-arm/syscalls/__waitid.S syscall_src += arch-arm/syscalls/_exit.S syscall_src += arch-arm/syscalls/_exit_thread.S syscall_src += arch-arm/syscalls/accept.S -syscall_src += arch-arm/syscalls/access.S syscall_src += arch-arm/syscalls/acct.S syscall_src += arch-arm/syscalls/bind.S syscall_src += arch-arm/syscalls/cacheflush.S syscall_src += arch-arm/syscalls/capget.S syscall_src += arch-arm/syscalls/capset.S syscall_src += arch-arm/syscalls/chdir.S -syscall_src += arch-arm/syscalls/chmod.S -syscall_src += arch-arm/syscalls/chown.S syscall_src += arch-arm/syscalls/chroot.S syscall_src += arch-arm/syscalls/clock_getres.S syscall_src += arch-arm/syscalls/clock_gettime.S @@ -105,21 +102,18 @@ syscall_src += arch-arm/syscalls/inotify_rm_watch.S syscall_src += arch-arm/syscalls/ioprio_get.S syscall_src += arch-arm/syscalls/ioprio_set.S syscall_src += arch-arm/syscalls/klogctl.S -syscall_src += arch-arm/syscalls/lchown.S syscall_src += arch-arm/syscalls/lgetxattr.S -syscall_src += arch-arm/syscalls/link.S +syscall_src += arch-arm/syscalls/linkat.S syscall_src += arch-arm/syscalls/listen.S syscall_src += arch-arm/syscalls/listxattr.S syscall_src += arch-arm/syscalls/llistxattr.S syscall_src += arch-arm/syscalls/lremovexattr.S syscall_src += arch-arm/syscalls/lseek.S syscall_src += arch-arm/syscalls/lsetxattr.S -syscall_src += arch-arm/syscalls/lstat.S syscall_src += arch-arm/syscalls/madvise.S syscall_src += arch-arm/syscalls/mincore.S -syscall_src += arch-arm/syscalls/mkdir.S syscall_src += arch-arm/syscalls/mkdirat.S -syscall_src += arch-arm/syscalls/mknod.S +syscall_src += arch-arm/syscalls/mknodat.S syscall_src += arch-arm/syscalls/mlock.S syscall_src += arch-arm/syscalls/mlockall.S syscall_src += arch-arm/syscalls/mount.S @@ -141,14 +135,12 @@ syscall_src += arch-arm/syscalls/pread64.S syscall_src += arch-arm/syscalls/pwrite64.S syscall_src += arch-arm/syscalls/read.S syscall_src += arch-arm/syscalls/readahead.S -syscall_src += arch-arm/syscalls/readlink.S +syscall_src += arch-arm/syscalls/readlinkat.S syscall_src += arch-arm/syscalls/readv.S syscall_src += arch-arm/syscalls/recvfrom.S syscall_src += arch-arm/syscalls/recvmsg.S syscall_src += arch-arm/syscalls/removexattr.S -syscall_src += arch-arm/syscalls/rename.S syscall_src += arch-arm/syscalls/renameat.S -syscall_src += arch-arm/syscalls/rmdir.S syscall_src += arch-arm/syscalls/sched_get_priority_max.S syscall_src += arch-arm/syscalls/sched_get_priority_min.S syscall_src += arch-arm/syscalls/sched_getparam.S @@ -183,10 +175,9 @@ syscall_src += arch-arm/syscalls/sigaltstack.S syscall_src += arch-arm/syscalls/signalfd4.S syscall_src += arch-arm/syscalls/socket.S syscall_src += arch-arm/syscalls/socketpair.S -syscall_src += arch-arm/syscalls/stat.S syscall_src += arch-arm/syscalls/swapoff.S syscall_src += arch-arm/syscalls/swapon.S -syscall_src += arch-arm/syscalls/symlink.S +syscall_src += arch-arm/syscalls/symlinkat.S syscall_src += arch-arm/syscalls/sync.S syscall_src += arch-arm/syscalls/sysinfo.S syscall_src += arch-arm/syscalls/timerfd_create.S @@ -198,11 +189,9 @@ syscall_src += arch-arm/syscalls/truncate64.S syscall_src += arch-arm/syscalls/umask.S syscall_src += arch-arm/syscalls/umount2.S syscall_src += arch-arm/syscalls/uname.S -syscall_src += arch-arm/syscalls/unlink.S syscall_src += arch-arm/syscalls/unlinkat.S syscall_src += arch-arm/syscalls/unshare.S syscall_src += arch-arm/syscalls/utimensat.S -syscall_src += arch-arm/syscalls/utimes.S syscall_src += arch-arm/syscalls/vfork.S syscall_src += arch-arm/syscalls/wait4.S syscall_src += arch-arm/syscalls/write.S diff --git a/libc/arch-arm/syscalls/link.S b/libc/arch-arm/syscalls/link.S deleted file mode 100644 index cc6314ef2..000000000 --- a/libc/arch-arm/syscalls/link.S +++ /dev/null @@ -1,16 +0,0 @@ -/* Generated by gensyscalls.py. Do not edit. */ - -#include -#include -#include - -ENTRY(link) - mov ip, r7 - ldr r7, =__NR_link - swi #0 - mov r7, ip - cmn r0, #(MAX_ERRNO + 1) - bxls lr - neg r0, r0 - b __set_errno -END(link) diff --git a/libc/arch-arm/syscalls/lchown.S b/libc/arch-arm/syscalls/linkat.S similarity index 53% rename from libc/arch-arm/syscalls/lchown.S rename to libc/arch-arm/syscalls/linkat.S index 91b7cf5bf..e990ce15b 100644 --- a/libc/arch-arm/syscalls/lchown.S +++ b/libc/arch-arm/syscalls/linkat.S @@ -4,13 +4,16 @@ #include #include -ENTRY(lchown) - mov ip, r7 - ldr r7, =__NR_lchown32 +ENTRY(linkat) + mov ip, sp + .save {r4, r5, r6, r7} + stmfd sp!, {r4, r5, r6, r7} + ldmfd ip, {r4, r5, r6} + ldr r7, =__NR_linkat swi #0 - mov r7, ip + ldmfd sp!, {r4, r5, r6, r7} cmn r0, #(MAX_ERRNO + 1) bxls lr neg r0, r0 b __set_errno -END(lchown) +END(linkat) diff --git a/libc/arch-arm/syscalls/lstat.S b/libc/arch-arm/syscalls/lstat.S deleted file mode 100644 index 4e3d3f99e..000000000 --- a/libc/arch-arm/syscalls/lstat.S +++ /dev/null @@ -1,16 +0,0 @@ -/* Generated by gensyscalls.py. Do not edit. */ - -#include -#include -#include - -ENTRY(lstat) - mov ip, r7 - ldr r7, =__NR_lstat64 - swi #0 - mov r7, ip - cmn r0, #(MAX_ERRNO + 1) - bxls lr - neg r0, r0 - b __set_errno -END(lstat) diff --git a/libc/arch-arm/syscalls/mkdir.S b/libc/arch-arm/syscalls/mkdir.S deleted file mode 100644 index efceeaa1e..000000000 --- a/libc/arch-arm/syscalls/mkdir.S +++ /dev/null @@ -1,16 +0,0 @@ -/* Generated by gensyscalls.py. Do not edit. */ - -#include -#include -#include - -ENTRY(mkdir) - mov ip, r7 - ldr r7, =__NR_mkdir - swi #0 - mov r7, ip - cmn r0, #(MAX_ERRNO + 1) - bxls lr - neg r0, r0 - b __set_errno -END(mkdir) diff --git a/libc/arch-arm/syscalls/mknod.S b/libc/arch-arm/syscalls/mknod.S deleted file mode 100644 index a8aeb390d..000000000 --- a/libc/arch-arm/syscalls/mknod.S +++ /dev/null @@ -1,16 +0,0 @@ -/* Generated by gensyscalls.py. Do not edit. */ - -#include -#include -#include - -ENTRY(mknod) - mov ip, r7 - ldr r7, =__NR_mknod - swi #0 - mov r7, ip - cmn r0, #(MAX_ERRNO + 1) - bxls lr - neg r0, r0 - b __set_errno -END(mknod) diff --git a/libc/arch-arm/syscalls/access.S b/libc/arch-arm/syscalls/mknodat.S similarity index 82% rename from libc/arch-arm/syscalls/access.S rename to libc/arch-arm/syscalls/mknodat.S index 730be2ad6..4a64eeade 100644 --- a/libc/arch-arm/syscalls/access.S +++ b/libc/arch-arm/syscalls/mknodat.S @@ -4,13 +4,13 @@ #include #include -ENTRY(access) +ENTRY(mknodat) mov ip, r7 - ldr r7, =__NR_access + ldr r7, =__NR_mknodat swi #0 mov r7, ip cmn r0, #(MAX_ERRNO + 1) bxls lr neg r0, r0 b __set_errno -END(access) +END(mknodat) diff --git a/libc/arch-arm/syscalls/readlink.S b/libc/arch-arm/syscalls/readlink.S deleted file mode 100644 index 41fd4575a..000000000 --- a/libc/arch-arm/syscalls/readlink.S +++ /dev/null @@ -1,16 +0,0 @@ -/* Generated by gensyscalls.py. Do not edit. */ - -#include -#include -#include - -ENTRY(readlink) - mov ip, r7 - ldr r7, =__NR_readlink - swi #0 - mov r7, ip - cmn r0, #(MAX_ERRNO + 1) - bxls lr - neg r0, r0 - b __set_errno -END(readlink) diff --git a/libc/arch-arm/syscalls/chown.S b/libc/arch-arm/syscalls/readlinkat.S similarity index 79% rename from libc/arch-arm/syscalls/chown.S rename to libc/arch-arm/syscalls/readlinkat.S index 1ef51b452..3d85e565b 100644 --- a/libc/arch-arm/syscalls/chown.S +++ b/libc/arch-arm/syscalls/readlinkat.S @@ -4,13 +4,13 @@ #include #include -ENTRY(chown) +ENTRY(readlinkat) mov ip, r7 - ldr r7, =__NR_chown32 + ldr r7, =__NR_readlinkat swi #0 mov r7, ip cmn r0, #(MAX_ERRNO + 1) bxls lr neg r0, r0 b __set_errno -END(chown) +END(readlinkat) diff --git a/libc/arch-arm/syscalls/rename.S b/libc/arch-arm/syscalls/rename.S deleted file mode 100644 index 0954c51a6..000000000 --- a/libc/arch-arm/syscalls/rename.S +++ /dev/null @@ -1,16 +0,0 @@ -/* Generated by gensyscalls.py. Do not edit. */ - -#include -#include -#include - -ENTRY(rename) - mov ip, r7 - ldr r7, =__NR_rename - swi #0 - mov r7, ip - cmn r0, #(MAX_ERRNO + 1) - bxls lr - neg r0, r0 - b __set_errno -END(rename) diff --git a/libc/arch-arm/syscalls/rmdir.S b/libc/arch-arm/syscalls/rmdir.S deleted file mode 100644 index 3ebe9d194..000000000 --- a/libc/arch-arm/syscalls/rmdir.S +++ /dev/null @@ -1,16 +0,0 @@ -/* Generated by gensyscalls.py. Do not edit. */ - -#include -#include -#include - -ENTRY(rmdir) - mov ip, r7 - ldr r7, =__NR_rmdir - swi #0 - mov r7, ip - cmn r0, #(MAX_ERRNO + 1) - bxls lr - neg r0, r0 - b __set_errno -END(rmdir) diff --git a/libc/arch-arm/syscalls/stat.S b/libc/arch-arm/syscalls/stat.S deleted file mode 100644 index 728c1706a..000000000 --- a/libc/arch-arm/syscalls/stat.S +++ /dev/null @@ -1,16 +0,0 @@ -/* Generated by gensyscalls.py. Do not edit. */ - -#include -#include -#include - -ENTRY(stat) - mov ip, r7 - ldr r7, =__NR_stat64 - swi #0 - mov r7, ip - cmn r0, #(MAX_ERRNO + 1) - bxls lr - neg r0, r0 - b __set_errno -END(stat) diff --git a/libc/arch-arm/syscalls/symlink.S b/libc/arch-arm/syscalls/symlink.S deleted file mode 100644 index 92bd66990..000000000 --- a/libc/arch-arm/syscalls/symlink.S +++ /dev/null @@ -1,16 +0,0 @@ -/* Generated by gensyscalls.py. Do not edit. */ - -#include -#include -#include - -ENTRY(symlink) - mov ip, r7 - ldr r7, =__NR_symlink - swi #0 - mov r7, ip - cmn r0, #(MAX_ERRNO + 1) - bxls lr - neg r0, r0 - b __set_errno -END(symlink) diff --git a/libc/arch-arm/syscalls/chmod.S b/libc/arch-arm/syscalls/symlinkat.S similarity index 80% rename from libc/arch-arm/syscalls/chmod.S rename to libc/arch-arm/syscalls/symlinkat.S index 3491ff249..fb51f1982 100644 --- a/libc/arch-arm/syscalls/chmod.S +++ b/libc/arch-arm/syscalls/symlinkat.S @@ -4,13 +4,13 @@ #include #include -ENTRY(chmod) +ENTRY(symlinkat) mov ip, r7 - ldr r7, =__NR_chmod + ldr r7, =__NR_symlinkat swi #0 mov r7, ip cmn r0, #(MAX_ERRNO + 1) bxls lr neg r0, r0 b __set_errno -END(chmod) +END(symlinkat) diff --git a/libc/arch-arm/syscalls/unlink.S b/libc/arch-arm/syscalls/unlink.S deleted file mode 100644 index 80c4c7787..000000000 --- a/libc/arch-arm/syscalls/unlink.S +++ /dev/null @@ -1,16 +0,0 @@ -/* Generated by gensyscalls.py. Do not edit. */ - -#include -#include -#include - -ENTRY(unlink) - mov ip, r7 - ldr r7, =__NR_unlink - swi #0 - mov r7, ip - cmn r0, #(MAX_ERRNO + 1) - bxls lr - neg r0, r0 - b __set_errno -END(unlink) diff --git a/libc/arch-arm/syscalls/utimes.S b/libc/arch-arm/syscalls/utimes.S deleted file mode 100644 index 8b704793d..000000000 --- a/libc/arch-arm/syscalls/utimes.S +++ /dev/null @@ -1,16 +0,0 @@ -/* Generated by gensyscalls.py. Do not edit. */ - -#include -#include -#include - -ENTRY(utimes) - mov ip, r7 - ldr r7, =__NR_utimes - swi #0 - mov r7, ip - cmn r0, #(MAX_ERRNO + 1) - bxls lr - neg r0, r0 - b __set_errno -END(utimes) diff --git a/libc/arch-mips/syscalls.mk b/libc/arch-mips/syscalls.mk index fc96222e8..621dbacfb 100644 --- a/libc/arch-mips/syscalls.mk +++ b/libc/arch-mips/syscalls.mk @@ -37,14 +37,11 @@ syscall_src += arch-mips/syscalls/_exit_thread.S syscall_src += arch-mips/syscalls/_flush_cache.S syscall_src += arch-mips/syscalls/_waitpid.S syscall_src += arch-mips/syscalls/accept.S -syscall_src += arch-mips/syscalls/access.S syscall_src += arch-mips/syscalls/acct.S syscall_src += arch-mips/syscalls/bind.S syscall_src += arch-mips/syscalls/capget.S syscall_src += arch-mips/syscalls/capset.S syscall_src += arch-mips/syscalls/chdir.S -syscall_src += arch-mips/syscalls/chmod.S -syscall_src += arch-mips/syscalls/chown.S syscall_src += arch-mips/syscalls/chroot.S syscall_src += arch-mips/syscalls/clock_getres.S syscall_src += arch-mips/syscalls/clock_gettime.S @@ -107,21 +104,18 @@ syscall_src += arch-mips/syscalls/ioprio_get.S syscall_src += arch-mips/syscalls/ioprio_set.S syscall_src += arch-mips/syscalls/kill.S syscall_src += arch-mips/syscalls/klogctl.S -syscall_src += arch-mips/syscalls/lchown.S syscall_src += arch-mips/syscalls/lgetxattr.S -syscall_src += arch-mips/syscalls/link.S +syscall_src += arch-mips/syscalls/linkat.S syscall_src += arch-mips/syscalls/listen.S syscall_src += arch-mips/syscalls/listxattr.S syscall_src += arch-mips/syscalls/llistxattr.S syscall_src += arch-mips/syscalls/lremovexattr.S syscall_src += arch-mips/syscalls/lseek.S syscall_src += arch-mips/syscalls/lsetxattr.S -syscall_src += arch-mips/syscalls/lstat.S syscall_src += arch-mips/syscalls/madvise.S syscall_src += arch-mips/syscalls/mincore.S -syscall_src += arch-mips/syscalls/mkdir.S syscall_src += arch-mips/syscalls/mkdirat.S -syscall_src += arch-mips/syscalls/mknod.S +syscall_src += arch-mips/syscalls/mknodat.S syscall_src += arch-mips/syscalls/mlock.S syscall_src += arch-mips/syscalls/mlockall.S syscall_src += arch-mips/syscalls/mount.S @@ -142,14 +136,12 @@ syscall_src += arch-mips/syscalls/pread64.S syscall_src += arch-mips/syscalls/pwrite64.S syscall_src += arch-mips/syscalls/read.S syscall_src += arch-mips/syscalls/readahead.S -syscall_src += arch-mips/syscalls/readlink.S +syscall_src += arch-mips/syscalls/readlinkat.S syscall_src += arch-mips/syscalls/readv.S syscall_src += arch-mips/syscalls/recvfrom.S syscall_src += arch-mips/syscalls/recvmsg.S syscall_src += arch-mips/syscalls/removexattr.S -syscall_src += arch-mips/syscalls/rename.S syscall_src += arch-mips/syscalls/renameat.S -syscall_src += arch-mips/syscalls/rmdir.S syscall_src += arch-mips/syscalls/sched_get_priority_max.S syscall_src += arch-mips/syscalls/sched_get_priority_min.S syscall_src += arch-mips/syscalls/sched_getparam.S @@ -184,10 +176,9 @@ syscall_src += arch-mips/syscalls/sigaltstack.S syscall_src += arch-mips/syscalls/signalfd4.S syscall_src += arch-mips/syscalls/socket.S syscall_src += arch-mips/syscalls/socketpair.S -syscall_src += arch-mips/syscalls/stat.S syscall_src += arch-mips/syscalls/swapoff.S syscall_src += arch-mips/syscalls/swapon.S -syscall_src += arch-mips/syscalls/symlink.S +syscall_src += arch-mips/syscalls/symlinkat.S syscall_src += arch-mips/syscalls/sync.S syscall_src += arch-mips/syscalls/syscall.S syscall_src += arch-mips/syscalls/sysinfo.S @@ -202,11 +193,9 @@ syscall_src += arch-mips/syscalls/truncate64.S syscall_src += arch-mips/syscalls/umask.S syscall_src += arch-mips/syscalls/umount2.S syscall_src += arch-mips/syscalls/uname.S -syscall_src += arch-mips/syscalls/unlink.S syscall_src += arch-mips/syscalls/unlinkat.S syscall_src += arch-mips/syscalls/unshare.S syscall_src += arch-mips/syscalls/utimensat.S -syscall_src += arch-mips/syscalls/utimes.S syscall_src += arch-mips/syscalls/wait4.S syscall_src += arch-mips/syscalls/write.S syscall_src += arch-mips/syscalls/writev.S diff --git a/libc/arch-mips/syscalls/link.S b/libc/arch-mips/syscalls/link.S deleted file mode 100644 index e197927e1..000000000 --- a/libc/arch-mips/syscalls/link.S +++ /dev/null @@ -1,23 +0,0 @@ -/* Generated by gensyscalls.py. Do not edit. */ - -#include - .text - .globl link - .align 4 - .ent link - -link: - .set noreorder - .cpload $t9 - li $v0, __NR_link - syscall - bnez $a3, 1f - move $a0, $v0 - j $ra - nop -1: - la $t9,__set_errno - j $t9 - nop - .set reorder - .end link diff --git a/libc/arch-mips/syscalls/access.S b/libc/arch-mips/syscalls/linkat.S similarity index 75% rename from libc/arch-mips/syscalls/access.S rename to libc/arch-mips/syscalls/linkat.S index 941b79117..dae07dd6d 100644 --- a/libc/arch-mips/syscalls/access.S +++ b/libc/arch-mips/syscalls/linkat.S @@ -2,14 +2,14 @@ #include .text - .globl access + .globl linkat .align 4 - .ent access + .ent linkat -access: +linkat: .set noreorder .cpload $t9 - li $v0, __NR_access + li $v0, __NR_linkat syscall bnez $a3, 1f move $a0, $v0 @@ -20,4 +20,4 @@ access: j $t9 nop .set reorder - .end access + .end linkat diff --git a/libc/arch-mips/syscalls/lstat.S b/libc/arch-mips/syscalls/lstat.S deleted file mode 100644 index 78e7a98a8..000000000 --- a/libc/arch-mips/syscalls/lstat.S +++ /dev/null @@ -1,23 +0,0 @@ -/* Generated by gensyscalls.py. Do not edit. */ - -#include - .text - .globl lstat - .align 4 - .ent lstat - -lstat: - .set noreorder - .cpload $t9 - li $v0, __NR_lstat64 - syscall - bnez $a3, 1f - move $a0, $v0 - j $ra - nop -1: - la $t9,__set_errno - j $t9 - nop - .set reorder - .end lstat diff --git a/libc/arch-mips/syscalls/mkdir.S b/libc/arch-mips/syscalls/mkdir.S deleted file mode 100644 index ec7412a2e..000000000 --- a/libc/arch-mips/syscalls/mkdir.S +++ /dev/null @@ -1,23 +0,0 @@ -/* Generated by gensyscalls.py. Do not edit. */ - -#include - .text - .globl mkdir - .align 4 - .ent mkdir - -mkdir: - .set noreorder - .cpload $t9 - li $v0, __NR_mkdir - syscall - bnez $a3, 1f - move $a0, $v0 - j $ra - nop -1: - la $t9,__set_errno - j $t9 - nop - .set reorder - .end mkdir diff --git a/libc/arch-mips/syscalls/mknod.S b/libc/arch-mips/syscalls/mknod.S deleted file mode 100644 index 579acaff1..000000000 --- a/libc/arch-mips/syscalls/mknod.S +++ /dev/null @@ -1,23 +0,0 @@ -/* Generated by gensyscalls.py. Do not edit. */ - -#include - .text - .globl mknod - .align 4 - .ent mknod - -mknod: - .set noreorder - .cpload $t9 - li $v0, __NR_mknod - syscall - bnez $a3, 1f - move $a0, $v0 - j $ra - nop -1: - la $t9,__set_errno - j $t9 - nop - .set reorder - .end mknod diff --git a/libc/arch-mips/syscalls/chmod.S b/libc/arch-mips/syscalls/mknodat.S similarity index 74% rename from libc/arch-mips/syscalls/chmod.S rename to libc/arch-mips/syscalls/mknodat.S index dd5a1f265..fc05bb3f0 100644 --- a/libc/arch-mips/syscalls/chmod.S +++ b/libc/arch-mips/syscalls/mknodat.S @@ -2,14 +2,14 @@ #include .text - .globl chmod + .globl mknodat .align 4 - .ent chmod + .ent mknodat -chmod: +mknodat: .set noreorder .cpload $t9 - li $v0, __NR_chmod + li $v0, __NR_mknodat syscall bnez $a3, 1f move $a0, $v0 @@ -20,4 +20,4 @@ chmod: j $t9 nop .set reorder - .end chmod + .end mknodat diff --git a/libc/arch-mips/syscalls/readlink.S b/libc/arch-mips/syscalls/readlink.S deleted file mode 100644 index adaf7fa80..000000000 --- a/libc/arch-mips/syscalls/readlink.S +++ /dev/null @@ -1,23 +0,0 @@ -/* Generated by gensyscalls.py. Do not edit. */ - -#include - .text - .globl readlink - .align 4 - .ent readlink - -readlink: - .set noreorder - .cpload $t9 - li $v0, __NR_readlink - syscall - bnez $a3, 1f - move $a0, $v0 - j $ra - nop -1: - la $t9,__set_errno - j $t9 - nop - .set reorder - .end readlink diff --git a/libc/arch-mips/syscalls/lchown.S b/libc/arch-mips/syscalls/readlinkat.S similarity index 71% rename from libc/arch-mips/syscalls/lchown.S rename to libc/arch-mips/syscalls/readlinkat.S index f23aa6a25..3e5d72fd3 100644 --- a/libc/arch-mips/syscalls/lchown.S +++ b/libc/arch-mips/syscalls/readlinkat.S @@ -2,14 +2,14 @@ #include .text - .globl lchown + .globl readlinkat .align 4 - .ent lchown + .ent readlinkat -lchown: +readlinkat: .set noreorder .cpload $t9 - li $v0, __NR_lchown + li $v0, __NR_readlinkat syscall bnez $a3, 1f move $a0, $v0 @@ -20,4 +20,4 @@ lchown: j $t9 nop .set reorder - .end lchown + .end readlinkat diff --git a/libc/arch-mips/syscalls/rename.S b/libc/arch-mips/syscalls/rename.S deleted file mode 100644 index 113b91056..000000000 --- a/libc/arch-mips/syscalls/rename.S +++ /dev/null @@ -1,23 +0,0 @@ -/* Generated by gensyscalls.py. Do not edit. */ - -#include - .text - .globl rename - .align 4 - .ent rename - -rename: - .set noreorder - .cpload $t9 - li $v0, __NR_rename - syscall - bnez $a3, 1f - move $a0, $v0 - j $ra - nop -1: - la $t9,__set_errno - j $t9 - nop - .set reorder - .end rename diff --git a/libc/arch-mips/syscalls/rmdir.S b/libc/arch-mips/syscalls/rmdir.S deleted file mode 100644 index 97b6744d2..000000000 --- a/libc/arch-mips/syscalls/rmdir.S +++ /dev/null @@ -1,23 +0,0 @@ -/* Generated by gensyscalls.py. Do not edit. */ - -#include - .text - .globl rmdir - .align 4 - .ent rmdir - -rmdir: - .set noreorder - .cpload $t9 - li $v0, __NR_rmdir - syscall - bnez $a3, 1f - move $a0, $v0 - j $ra - nop -1: - la $t9,__set_errno - j $t9 - nop - .set reorder - .end rmdir diff --git a/libc/arch-mips/syscalls/stat.S b/libc/arch-mips/syscalls/stat.S deleted file mode 100644 index ca1b26f32..000000000 --- a/libc/arch-mips/syscalls/stat.S +++ /dev/null @@ -1,23 +0,0 @@ -/* Generated by gensyscalls.py. Do not edit. */ - -#include - .text - .globl stat - .align 4 - .ent stat - -stat: - .set noreorder - .cpload $t9 - li $v0, __NR_stat64 - syscall - bnez $a3, 1f - move $a0, $v0 - j $ra - nop -1: - la $t9,__set_errno - j $t9 - nop - .set reorder - .end stat diff --git a/libc/arch-mips/syscalls/symlink.S b/libc/arch-mips/syscalls/symlink.S deleted file mode 100644 index 7a4985867..000000000 --- a/libc/arch-mips/syscalls/symlink.S +++ /dev/null @@ -1,23 +0,0 @@ -/* Generated by gensyscalls.py. Do not edit. */ - -#include - .text - .globl symlink - .align 4 - .ent symlink - -symlink: - .set noreorder - .cpload $t9 - li $v0, __NR_symlink - syscall - bnez $a3, 1f - move $a0, $v0 - j $ra - nop -1: - la $t9,__set_errno - j $t9 - nop - .set reorder - .end symlink diff --git a/libc/arch-mips/syscalls/chown.S b/libc/arch-mips/syscalls/symlinkat.S similarity index 72% rename from libc/arch-mips/syscalls/chown.S rename to libc/arch-mips/syscalls/symlinkat.S index afe807de5..9c4324181 100644 --- a/libc/arch-mips/syscalls/chown.S +++ b/libc/arch-mips/syscalls/symlinkat.S @@ -2,14 +2,14 @@ #include .text - .globl chown + .globl symlinkat .align 4 - .ent chown + .ent symlinkat -chown: +symlinkat: .set noreorder .cpload $t9 - li $v0, __NR_chown + li $v0, __NR_symlinkat syscall bnez $a3, 1f move $a0, $v0 @@ -20,4 +20,4 @@ chown: j $t9 nop .set reorder - .end chown + .end symlinkat diff --git a/libc/arch-mips/syscalls/unlink.S b/libc/arch-mips/syscalls/unlink.S deleted file mode 100644 index 290070743..000000000 --- a/libc/arch-mips/syscalls/unlink.S +++ /dev/null @@ -1,23 +0,0 @@ -/* Generated by gensyscalls.py. Do not edit. */ - -#include - .text - .globl unlink - .align 4 - .ent unlink - -unlink: - .set noreorder - .cpload $t9 - li $v0, __NR_unlink - syscall - bnez $a3, 1f - move $a0, $v0 - j $ra - nop -1: - la $t9,__set_errno - j $t9 - nop - .set reorder - .end unlink diff --git a/libc/arch-mips/syscalls/utimes.S b/libc/arch-mips/syscalls/utimes.S deleted file mode 100644 index dc683e549..000000000 --- a/libc/arch-mips/syscalls/utimes.S +++ /dev/null @@ -1,23 +0,0 @@ -/* Generated by gensyscalls.py. Do not edit. */ - -#include - .text - .globl utimes - .align 4 - .ent utimes - -utimes: - .set noreorder - .cpload $t9 - li $v0, __NR_utimes - syscall - bnez $a3, 1f - move $a0, $v0 - j $ra - nop -1: - la $t9,__set_errno - j $t9 - nop - .set reorder - .end utimes diff --git a/libc/arch-x86/syscalls.mk b/libc/arch-x86/syscalls.mk index 54949927e..5d1edaad7 100644 --- a/libc/arch-x86/syscalls.mk +++ b/libc/arch-x86/syscalls.mk @@ -36,14 +36,11 @@ syscall_src += arch-x86/syscalls/_exit.S syscall_src += arch-x86/syscalls/_exit_thread.S syscall_src += arch-x86/syscalls/_waitpid.S syscall_src += arch-x86/syscalls/accept.S -syscall_src += arch-x86/syscalls/access.S syscall_src += arch-x86/syscalls/acct.S syscall_src += arch-x86/syscalls/bind.S syscall_src += arch-x86/syscalls/capget.S syscall_src += arch-x86/syscalls/capset.S syscall_src += arch-x86/syscalls/chdir.S -syscall_src += arch-x86/syscalls/chmod.S -syscall_src += arch-x86/syscalls/chown.S syscall_src += arch-x86/syscalls/chroot.S syscall_src += arch-x86/syscalls/clock_getres.S syscall_src += arch-x86/syscalls/clock_gettime.S @@ -106,21 +103,18 @@ syscall_src += arch-x86/syscalls/ioprio_get.S syscall_src += arch-x86/syscalls/ioprio_set.S syscall_src += arch-x86/syscalls/kill.S syscall_src += arch-x86/syscalls/klogctl.S -syscall_src += arch-x86/syscalls/lchown.S syscall_src += arch-x86/syscalls/lgetxattr.S -syscall_src += arch-x86/syscalls/link.S +syscall_src += arch-x86/syscalls/linkat.S syscall_src += arch-x86/syscalls/listen.S syscall_src += arch-x86/syscalls/listxattr.S syscall_src += arch-x86/syscalls/llistxattr.S syscall_src += arch-x86/syscalls/lremovexattr.S syscall_src += arch-x86/syscalls/lseek.S syscall_src += arch-x86/syscalls/lsetxattr.S -syscall_src += arch-x86/syscalls/lstat.S syscall_src += arch-x86/syscalls/madvise.S syscall_src += arch-x86/syscalls/mincore.S -syscall_src += arch-x86/syscalls/mkdir.S syscall_src += arch-x86/syscalls/mkdirat.S -syscall_src += arch-x86/syscalls/mknod.S +syscall_src += arch-x86/syscalls/mknodat.S syscall_src += arch-x86/syscalls/mlock.S syscall_src += arch-x86/syscalls/mlockall.S syscall_src += arch-x86/syscalls/mount.S @@ -142,14 +136,12 @@ syscall_src += arch-x86/syscalls/pread64.S syscall_src += arch-x86/syscalls/pwrite64.S syscall_src += arch-x86/syscalls/read.S syscall_src += arch-x86/syscalls/readahead.S -syscall_src += arch-x86/syscalls/readlink.S +syscall_src += arch-x86/syscalls/readlinkat.S syscall_src += arch-x86/syscalls/readv.S syscall_src += arch-x86/syscalls/recvfrom.S syscall_src += arch-x86/syscalls/recvmsg.S syscall_src += arch-x86/syscalls/removexattr.S -syscall_src += arch-x86/syscalls/rename.S syscall_src += arch-x86/syscalls/renameat.S -syscall_src += arch-x86/syscalls/rmdir.S syscall_src += arch-x86/syscalls/sched_get_priority_max.S syscall_src += arch-x86/syscalls/sched_get_priority_min.S syscall_src += arch-x86/syscalls/sched_getparam.S @@ -184,10 +176,9 @@ syscall_src += arch-x86/syscalls/sigaltstack.S syscall_src += arch-x86/syscalls/signalfd4.S syscall_src += arch-x86/syscalls/socket.S syscall_src += arch-x86/syscalls/socketpair.S -syscall_src += arch-x86/syscalls/stat.S syscall_src += arch-x86/syscalls/swapoff.S syscall_src += arch-x86/syscalls/swapon.S -syscall_src += arch-x86/syscalls/symlink.S +syscall_src += arch-x86/syscalls/symlinkat.S syscall_src += arch-x86/syscalls/sync.S syscall_src += arch-x86/syscalls/sysinfo.S syscall_src += arch-x86/syscalls/tgkill.S @@ -201,11 +192,9 @@ syscall_src += arch-x86/syscalls/truncate64.S syscall_src += arch-x86/syscalls/umask.S syscall_src += arch-x86/syscalls/umount2.S syscall_src += arch-x86/syscalls/uname.S -syscall_src += arch-x86/syscalls/unlink.S syscall_src += arch-x86/syscalls/unlinkat.S syscall_src += arch-x86/syscalls/unshare.S syscall_src += arch-x86/syscalls/utimensat.S -syscall_src += arch-x86/syscalls/utimes.S syscall_src += arch-x86/syscalls/wait4.S syscall_src += arch-x86/syscalls/write.S syscall_src += arch-x86/syscalls/writev.S diff --git a/libc/arch-x86/syscalls/access.S b/libc/arch-x86/syscalls/access.S deleted file mode 100644 index 0a553edf3..000000000 --- a/libc/arch-x86/syscalls/access.S +++ /dev/null @@ -1,25 +0,0 @@ -/* Generated by gensyscalls.py. Do not edit. */ - -#include -#include -#include - -ENTRY(access) - pushl %ebx - pushl %ecx - mov 12(%esp), %ebx - mov 16(%esp), %ecx - movl $__NR_access, %eax - int $0x80 - cmpl $-MAX_ERRNO, %eax - jb 1f - negl %eax - pushl %eax - call __set_errno - addl $4, %esp - orl $-1, %eax -1: - popl %ecx - popl %ebx - ret -END(access) diff --git a/libc/arch-x86/syscalls/chmod.S b/libc/arch-x86/syscalls/chmod.S deleted file mode 100644 index 5718f8f5e..000000000 --- a/libc/arch-x86/syscalls/chmod.S +++ /dev/null @@ -1,25 +0,0 @@ -/* Generated by gensyscalls.py. Do not edit. */ - -#include -#include -#include - -ENTRY(chmod) - pushl %ebx - pushl %ecx - mov 12(%esp), %ebx - mov 16(%esp), %ecx - movl $__NR_chmod, %eax - int $0x80 - cmpl $-MAX_ERRNO, %eax - jb 1f - negl %eax - pushl %eax - call __set_errno - addl $4, %esp - orl $-1, %eax -1: - popl %ecx - popl %ebx - ret -END(chmod) diff --git a/libc/arch-x86/syscalls/link.S b/libc/arch-x86/syscalls/link.S deleted file mode 100644 index 15d67c478..000000000 --- a/libc/arch-x86/syscalls/link.S +++ /dev/null @@ -1,25 +0,0 @@ -/* Generated by gensyscalls.py. Do not edit. */ - -#include -#include -#include - -ENTRY(link) - pushl %ebx - pushl %ecx - mov 12(%esp), %ebx - mov 16(%esp), %ecx - movl $__NR_link, %eax - int $0x80 - cmpl $-MAX_ERRNO, %eax - jb 1f - negl %eax - pushl %eax - call __set_errno - addl $4, %esp - orl $-1, %eax -1: - popl %ecx - popl %ebx - ret -END(link) diff --git a/libc/arch-x86/syscalls/lchown.S b/libc/arch-x86/syscalls/linkat.S similarity index 60% rename from libc/arch-x86/syscalls/lchown.S rename to libc/arch-x86/syscalls/linkat.S index 7f4589a9b..652f3469c 100644 --- a/libc/arch-x86/syscalls/lchown.S +++ b/libc/arch-x86/syscalls/linkat.S @@ -4,14 +4,18 @@ #include #include -ENTRY(lchown) +ENTRY(linkat) pushl %ebx pushl %ecx pushl %edx - mov 16(%esp), %ebx - mov 20(%esp), %ecx - mov 24(%esp), %edx - movl $__NR_lchown32, %eax + pushl %esi + pushl %edi + mov 24(%esp), %ebx + mov 28(%esp), %ecx + mov 32(%esp), %edx + mov 36(%esp), %esi + mov 40(%esp), %edi + movl $__NR_linkat, %eax int $0x80 cmpl $-MAX_ERRNO, %eax jb 1f @@ -21,8 +25,10 @@ ENTRY(lchown) addl $4, %esp orl $-1, %eax 1: + popl %edi + popl %esi popl %edx popl %ecx popl %ebx ret -END(lchown) +END(linkat) diff --git a/libc/arch-x86/syscalls/lstat.S b/libc/arch-x86/syscalls/lstat.S deleted file mode 100644 index 23a0dcf31..000000000 --- a/libc/arch-x86/syscalls/lstat.S +++ /dev/null @@ -1,25 +0,0 @@ -/* Generated by gensyscalls.py. Do not edit. */ - -#include -#include -#include - -ENTRY(lstat) - pushl %ebx - pushl %ecx - mov 12(%esp), %ebx - mov 16(%esp), %ecx - movl $__NR_lstat64, %eax - int $0x80 - cmpl $-MAX_ERRNO, %eax - jb 1f - negl %eax - pushl %eax - call __set_errno - addl $4, %esp - orl $-1, %eax -1: - popl %ecx - popl %ebx - ret -END(lstat) diff --git a/libc/arch-x86/syscalls/mkdir.S b/libc/arch-x86/syscalls/mkdir.S deleted file mode 100644 index d242ce2b1..000000000 --- a/libc/arch-x86/syscalls/mkdir.S +++ /dev/null @@ -1,25 +0,0 @@ -/* Generated by gensyscalls.py. Do not edit. */ - -#include -#include -#include - -ENTRY(mkdir) - pushl %ebx - pushl %ecx - mov 12(%esp), %ebx - mov 16(%esp), %ecx - movl $__NR_mkdir, %eax - int $0x80 - cmpl $-MAX_ERRNO, %eax - jb 1f - negl %eax - pushl %eax - call __set_errno - addl $4, %esp - orl $-1, %eax -1: - popl %ecx - popl %ebx - ret -END(mkdir) diff --git a/libc/arch-x86/syscalls/readlink.S b/libc/arch-x86/syscalls/mknodat.S similarity index 66% rename from libc/arch-x86/syscalls/readlink.S rename to libc/arch-x86/syscalls/mknodat.S index 4a279dce4..8e5394055 100644 --- a/libc/arch-x86/syscalls/readlink.S +++ b/libc/arch-x86/syscalls/mknodat.S @@ -4,14 +4,16 @@ #include #include -ENTRY(readlink) +ENTRY(mknodat) pushl %ebx pushl %ecx pushl %edx - mov 16(%esp), %ebx - mov 20(%esp), %ecx - mov 24(%esp), %edx - movl $__NR_readlink, %eax + pushl %esi + mov 20(%esp), %ebx + mov 24(%esp), %ecx + mov 28(%esp), %edx + mov 32(%esp), %esi + movl $__NR_mknodat, %eax int $0x80 cmpl $-MAX_ERRNO, %eax jb 1f @@ -21,8 +23,9 @@ ENTRY(readlink) addl $4, %esp orl $-1, %eax 1: + popl %esi popl %edx popl %ecx popl %ebx ret -END(readlink) +END(mknodat) diff --git a/libc/arch-x86/syscalls/chown.S b/libc/arch-x86/syscalls/readlinkat.S similarity index 65% rename from libc/arch-x86/syscalls/chown.S rename to libc/arch-x86/syscalls/readlinkat.S index 5706da16f..73b05af29 100644 --- a/libc/arch-x86/syscalls/chown.S +++ b/libc/arch-x86/syscalls/readlinkat.S @@ -4,14 +4,16 @@ #include #include -ENTRY(chown) +ENTRY(readlinkat) pushl %ebx pushl %ecx pushl %edx - mov 16(%esp), %ebx - mov 20(%esp), %ecx - mov 24(%esp), %edx - movl $__NR_chown32, %eax + pushl %esi + mov 20(%esp), %ebx + mov 24(%esp), %ecx + mov 28(%esp), %edx + mov 32(%esp), %esi + movl $__NR_readlinkat, %eax int $0x80 cmpl $-MAX_ERRNO, %eax jb 1f @@ -21,8 +23,9 @@ ENTRY(chown) addl $4, %esp orl $-1, %eax 1: + popl %esi popl %edx popl %ecx popl %ebx ret -END(chown) +END(readlinkat) diff --git a/libc/arch-x86/syscalls/rename.S b/libc/arch-x86/syscalls/rename.S deleted file mode 100644 index 855661974..000000000 --- a/libc/arch-x86/syscalls/rename.S +++ /dev/null @@ -1,25 +0,0 @@ -/* Generated by gensyscalls.py. Do not edit. */ - -#include -#include -#include - -ENTRY(rename) - pushl %ebx - pushl %ecx - mov 12(%esp), %ebx - mov 16(%esp), %ecx - movl $__NR_rename, %eax - int $0x80 - cmpl $-MAX_ERRNO, %eax - jb 1f - negl %eax - pushl %eax - call __set_errno - addl $4, %esp - orl $-1, %eax -1: - popl %ecx - popl %ebx - ret -END(rename) diff --git a/libc/arch-x86/syscalls/rmdir.S b/libc/arch-x86/syscalls/rmdir.S deleted file mode 100644 index 8ec2d3cac..000000000 --- a/libc/arch-x86/syscalls/rmdir.S +++ /dev/null @@ -1,22 +0,0 @@ -/* Generated by gensyscalls.py. Do not edit. */ - -#include -#include -#include - -ENTRY(rmdir) - pushl %ebx - mov 8(%esp), %ebx - movl $__NR_rmdir, %eax - int $0x80 - cmpl $-MAX_ERRNO, %eax - jb 1f - negl %eax - pushl %eax - call __set_errno - addl $4, %esp - orl $-1, %eax -1: - popl %ebx - ret -END(rmdir) diff --git a/libc/arch-x86/syscalls/stat.S b/libc/arch-x86/syscalls/stat.S deleted file mode 100644 index 6f7604dea..000000000 --- a/libc/arch-x86/syscalls/stat.S +++ /dev/null @@ -1,25 +0,0 @@ -/* Generated by gensyscalls.py. Do not edit. */ - -#include -#include -#include - -ENTRY(stat) - pushl %ebx - pushl %ecx - mov 12(%esp), %ebx - mov 16(%esp), %ecx - movl $__NR_stat64, %eax - int $0x80 - cmpl $-MAX_ERRNO, %eax - jb 1f - negl %eax - pushl %eax - call __set_errno - addl $4, %esp - orl $-1, %eax -1: - popl %ecx - popl %ebx - ret -END(stat) diff --git a/libc/arch-x86/syscalls/symlink.S b/libc/arch-x86/syscalls/symlink.S deleted file mode 100644 index 815d833e7..000000000 --- a/libc/arch-x86/syscalls/symlink.S +++ /dev/null @@ -1,25 +0,0 @@ -/* Generated by gensyscalls.py. Do not edit. */ - -#include -#include -#include - -ENTRY(symlink) - pushl %ebx - pushl %ecx - mov 12(%esp), %ebx - mov 16(%esp), %ecx - movl $__NR_symlink, %eax - int $0x80 - cmpl $-MAX_ERRNO, %eax - jb 1f - negl %eax - pushl %eax - call __set_errno - addl $4, %esp - orl $-1, %eax -1: - popl %ecx - popl %ebx - ret -END(symlink) diff --git a/libc/arch-x86/syscalls/mknod.S b/libc/arch-x86/syscalls/symlinkat.S similarity index 87% rename from libc/arch-x86/syscalls/mknod.S rename to libc/arch-x86/syscalls/symlinkat.S index e27038454..7d2422695 100644 --- a/libc/arch-x86/syscalls/mknod.S +++ b/libc/arch-x86/syscalls/symlinkat.S @@ -4,14 +4,14 @@ #include #include -ENTRY(mknod) +ENTRY(symlinkat) pushl %ebx pushl %ecx pushl %edx mov 16(%esp), %ebx mov 20(%esp), %ecx mov 24(%esp), %edx - movl $__NR_mknod, %eax + movl $__NR_symlinkat, %eax int $0x80 cmpl $-MAX_ERRNO, %eax jb 1f @@ -25,4 +25,4 @@ ENTRY(mknod) popl %ecx popl %ebx ret -END(mknod) +END(symlinkat) diff --git a/libc/arch-x86/syscalls/unlink.S b/libc/arch-x86/syscalls/unlink.S deleted file mode 100644 index 297d34b58..000000000 --- a/libc/arch-x86/syscalls/unlink.S +++ /dev/null @@ -1,22 +0,0 @@ -/* Generated by gensyscalls.py. Do not edit. */ - -#include -#include -#include - -ENTRY(unlink) - pushl %ebx - mov 8(%esp), %ebx - movl $__NR_unlink, %eax - int $0x80 - cmpl $-MAX_ERRNO, %eax - jb 1f - negl %eax - pushl %eax - call __set_errno - addl $4, %esp - orl $-1, %eax -1: - popl %ebx - ret -END(unlink) diff --git a/libc/arch-x86/syscalls/utimes.S b/libc/arch-x86/syscalls/utimes.S deleted file mode 100644 index bfe02b5da..000000000 --- a/libc/arch-x86/syscalls/utimes.S +++ /dev/null @@ -1,25 +0,0 @@ -/* Generated by gensyscalls.py. Do not edit. */ - -#include -#include -#include - -ENTRY(utimes) - pushl %ebx - pushl %ecx - mov 12(%esp), %ebx - mov 16(%esp), %ecx - movl $__NR_utimes, %eax - int $0x80 - cmpl $-MAX_ERRNO, %eax - jb 1f - negl %eax - pushl %eax - call __set_errno - addl $4, %esp - orl $-1, %eax -1: - popl %ecx - popl %ebx - ret -END(utimes) diff --git a/libc/arch-x86_64/syscalls.mk b/libc/arch-x86_64/syscalls.mk index 70cc3191c..803b700a5 100644 --- a/libc/arch-x86_64/syscalls.mk +++ b/libc/arch-x86_64/syscalls.mk @@ -7,7 +7,6 @@ syscall_src += arch-x86_64/syscalls/__getcpu.S syscall_src += arch-x86_64/syscalls/__getcwd.S syscall_src += arch-x86_64/syscalls/__getpriority.S syscall_src += arch-x86_64/syscalls/__ioctl.S -syscall_src += arch-x86_64/syscalls/__open.S syscall_src += arch-x86_64/syscalls/__openat.S syscall_src += arch-x86_64/syscalls/__ptrace.S syscall_src += arch-x86_64/syscalls/__reboot.S @@ -28,14 +27,11 @@ syscall_src += arch-x86_64/syscalls/__waitid.S syscall_src += arch-x86_64/syscalls/_exit.S syscall_src += arch-x86_64/syscalls/_exit_thread.S syscall_src += arch-x86_64/syscalls/accept.S -syscall_src += arch-x86_64/syscalls/access.S syscall_src += arch-x86_64/syscalls/acct.S syscall_src += arch-x86_64/syscalls/bind.S syscall_src += arch-x86_64/syscalls/capget.S syscall_src += arch-x86_64/syscalls/capset.S syscall_src += arch-x86_64/syscalls/chdir.S -syscall_src += arch-x86_64/syscalls/chmod.S -syscall_src += arch-x86_64/syscalls/chown.S syscall_src += arch-x86_64/syscalls/chroot.S syscall_src += arch-x86_64/syscalls/clock_getres.S syscall_src += arch-x86_64/syscalls/clock_gettime.S @@ -65,6 +61,7 @@ syscall_src += arch-x86_64/syscalls/flock.S syscall_src += arch-x86_64/syscalls/fremovexattr.S syscall_src += arch-x86_64/syscalls/fsetxattr.S syscall_src += arch-x86_64/syscalls/fstat.S +syscall_src += arch-x86_64/syscalls/fstatat.S syscall_src += arch-x86_64/syscalls/fstatfs.S syscall_src += arch-x86_64/syscalls/fsync.S syscall_src += arch-x86_64/syscalls/ftruncate.S @@ -98,21 +95,18 @@ syscall_src += arch-x86_64/syscalls/ioprio_get.S syscall_src += arch-x86_64/syscalls/ioprio_set.S syscall_src += arch-x86_64/syscalls/kill.S syscall_src += arch-x86_64/syscalls/klogctl.S -syscall_src += arch-x86_64/syscalls/lchown.S syscall_src += arch-x86_64/syscalls/lgetxattr.S -syscall_src += arch-x86_64/syscalls/link.S +syscall_src += arch-x86_64/syscalls/linkat.S syscall_src += arch-x86_64/syscalls/listen.S syscall_src += arch-x86_64/syscalls/listxattr.S syscall_src += arch-x86_64/syscalls/llistxattr.S syscall_src += arch-x86_64/syscalls/lremovexattr.S syscall_src += arch-x86_64/syscalls/lseek.S syscall_src += arch-x86_64/syscalls/lsetxattr.S -syscall_src += arch-x86_64/syscalls/lstat.S syscall_src += arch-x86_64/syscalls/madvise.S syscall_src += arch-x86_64/syscalls/mincore.S -syscall_src += arch-x86_64/syscalls/mkdir.S syscall_src += arch-x86_64/syscalls/mkdirat.S -syscall_src += arch-x86_64/syscalls/mknod.S +syscall_src += arch-x86_64/syscalls/mknodat.S syscall_src += arch-x86_64/syscalls/mlock.S syscall_src += arch-x86_64/syscalls/mlockall.S syscall_src += arch-x86_64/syscalls/mmap.S @@ -135,14 +129,12 @@ syscall_src += arch-x86_64/syscalls/pread64.S syscall_src += arch-x86_64/syscalls/pwrite64.S syscall_src += arch-x86_64/syscalls/read.S syscall_src += arch-x86_64/syscalls/readahead.S -syscall_src += arch-x86_64/syscalls/readlink.S +syscall_src += arch-x86_64/syscalls/readlinkat.S syscall_src += arch-x86_64/syscalls/readv.S syscall_src += arch-x86_64/syscalls/recvfrom.S syscall_src += arch-x86_64/syscalls/recvmsg.S syscall_src += arch-x86_64/syscalls/removexattr.S -syscall_src += arch-x86_64/syscalls/rename.S syscall_src += arch-x86_64/syscalls/renameat.S -syscall_src += arch-x86_64/syscalls/rmdir.S syscall_src += arch-x86_64/syscalls/sched_get_priority_max.S syscall_src += arch-x86_64/syscalls/sched_get_priority_min.S syscall_src += arch-x86_64/syscalls/sched_getparam.S @@ -176,11 +168,10 @@ syscall_src += arch-x86_64/syscalls/sigaltstack.S syscall_src += arch-x86_64/syscalls/signalfd4.S syscall_src += arch-x86_64/syscalls/socket.S syscall_src += arch-x86_64/syscalls/socketpair.S -syscall_src += arch-x86_64/syscalls/stat.S syscall_src += arch-x86_64/syscalls/statfs.S syscall_src += arch-x86_64/syscalls/swapoff.S syscall_src += arch-x86_64/syscalls/swapon.S -syscall_src += arch-x86_64/syscalls/symlink.S +syscall_src += arch-x86_64/syscalls/symlinkat.S syscall_src += arch-x86_64/syscalls/sync.S syscall_src += arch-x86_64/syscalls/sysinfo.S syscall_src += arch-x86_64/syscalls/tgkill.S @@ -193,11 +184,9 @@ syscall_src += arch-x86_64/syscalls/truncate.S syscall_src += arch-x86_64/syscalls/umask.S syscall_src += arch-x86_64/syscalls/umount2.S syscall_src += arch-x86_64/syscalls/uname.S -syscall_src += arch-x86_64/syscalls/unlink.S syscall_src += arch-x86_64/syscalls/unlinkat.S syscall_src += arch-x86_64/syscalls/unshare.S syscall_src += arch-x86_64/syscalls/utimensat.S -syscall_src += arch-x86_64/syscalls/utimes.S syscall_src += arch-x86_64/syscalls/wait4.S syscall_src += arch-x86_64/syscalls/write.S syscall_src += arch-x86_64/syscalls/writev.S diff --git a/libc/arch-x86_64/syscalls/access.S b/libc/arch-x86_64/syscalls/fstatat.S similarity index 76% rename from libc/arch-x86_64/syscalls/access.S rename to libc/arch-x86_64/syscalls/fstatat.S index 81fd734c1..577660f06 100644 --- a/libc/arch-x86_64/syscalls/access.S +++ b/libc/arch-x86_64/syscalls/fstatat.S @@ -4,8 +4,9 @@ #include #include -ENTRY(access) - movl $__NR_access, %eax +ENTRY(fstatat) + movq %rcx, %r10 + movl $__NR_newfstatat, %eax syscall cmpq $-MAX_ERRNO, %rax jb 1f @@ -15,4 +16,4 @@ ENTRY(access) orq $-1, %rax 1: ret -END(access) +END(fstatat) diff --git a/libc/arch-x86_64/syscalls/lchown.S b/libc/arch-x86_64/syscalls/lchown.S deleted file mode 100644 index 2a90044ef..000000000 --- a/libc/arch-x86_64/syscalls/lchown.S +++ /dev/null @@ -1,18 +0,0 @@ -/* Generated by gensyscalls.py. Do not edit. */ - -#include -#include -#include - -ENTRY(lchown) - movl $__NR_lchown, %eax - syscall - cmpq $-MAX_ERRNO, %rax - jb 1f - negl %eax - movl %eax, %edi - call __set_errno - orq $-1, %rax -1: - ret -END(lchown) diff --git a/libc/arch-x86_64/syscalls/link.S b/libc/arch-x86_64/syscalls/link.S deleted file mode 100644 index 8719572c8..000000000 --- a/libc/arch-x86_64/syscalls/link.S +++ /dev/null @@ -1,18 +0,0 @@ -/* Generated by gensyscalls.py. Do not edit. */ - -#include -#include -#include - -ENTRY(link) - movl $__NR_link, %eax - syscall - cmpq $-MAX_ERRNO, %rax - jb 1f - negl %eax - movl %eax, %edi - call __set_errno - orq $-1, %rax -1: - ret -END(link) diff --git a/libc/arch-x86_64/syscalls/chmod.S b/libc/arch-x86_64/syscalls/linkat.S similarity index 77% rename from libc/arch-x86_64/syscalls/chmod.S rename to libc/arch-x86_64/syscalls/linkat.S index 4591f1100..8dced7d16 100644 --- a/libc/arch-x86_64/syscalls/chmod.S +++ b/libc/arch-x86_64/syscalls/linkat.S @@ -4,8 +4,9 @@ #include #include -ENTRY(chmod) - movl $__NR_chmod, %eax +ENTRY(linkat) + movq %rcx, %r10 + movl $__NR_linkat, %eax syscall cmpq $-MAX_ERRNO, %rax jb 1f @@ -15,4 +16,4 @@ ENTRY(chmod) orq $-1, %rax 1: ret -END(chmod) +END(linkat) diff --git a/libc/arch-x86_64/syscalls/lstat.S b/libc/arch-x86_64/syscalls/lstat.S deleted file mode 100644 index e68592ded..000000000 --- a/libc/arch-x86_64/syscalls/lstat.S +++ /dev/null @@ -1,18 +0,0 @@ -/* Generated by gensyscalls.py. Do not edit. */ - -#include -#include -#include - -ENTRY(lstat) - movl $__NR_lstat, %eax - syscall - cmpq $-MAX_ERRNO, %rax - jb 1f - negl %eax - movl %eax, %edi - call __set_errno - orq $-1, %rax -1: - ret -END(lstat) diff --git a/libc/arch-x86_64/syscalls/mkdir.S b/libc/arch-x86_64/syscalls/mkdir.S deleted file mode 100644 index d21b2e2fd..000000000 --- a/libc/arch-x86_64/syscalls/mkdir.S +++ /dev/null @@ -1,18 +0,0 @@ -/* Generated by gensyscalls.py. Do not edit. */ - -#include -#include -#include - -ENTRY(mkdir) - movl $__NR_mkdir, %eax - syscall - cmpq $-MAX_ERRNO, %rax - jb 1f - negl %eax - movl %eax, %edi - call __set_errno - orq $-1, %rax -1: - ret -END(mkdir) diff --git a/libc/arch-x86_64/syscalls/mknod.S b/libc/arch-x86_64/syscalls/mknod.S deleted file mode 100644 index a49bc8a81..000000000 --- a/libc/arch-x86_64/syscalls/mknod.S +++ /dev/null @@ -1,18 +0,0 @@ -/* Generated by gensyscalls.py. Do not edit. */ - -#include -#include -#include - -ENTRY(mknod) - movl $__NR_mknod, %eax - syscall - cmpq $-MAX_ERRNO, %rax - jb 1f - negl %eax - movl %eax, %edi - call __set_errno - orq $-1, %rax -1: - ret -END(mknod) diff --git a/libc/arch-x86_64/syscalls/chown.S b/libc/arch-x86_64/syscalls/mknodat.S similarity index 76% rename from libc/arch-x86_64/syscalls/chown.S rename to libc/arch-x86_64/syscalls/mknodat.S index a587c0573..92dbb5b5d 100644 --- a/libc/arch-x86_64/syscalls/chown.S +++ b/libc/arch-x86_64/syscalls/mknodat.S @@ -4,8 +4,9 @@ #include #include -ENTRY(chown) - movl $__NR_chown, %eax +ENTRY(mknodat) + movq %rcx, %r10 + movl $__NR_mknodat, %eax syscall cmpq $-MAX_ERRNO, %rax jb 1f @@ -15,4 +16,4 @@ ENTRY(chown) orq $-1, %rax 1: ret -END(chown) +END(mknodat) diff --git a/libc/arch-x86_64/syscalls/readlink.S b/libc/arch-x86_64/syscalls/readlink.S deleted file mode 100644 index 7cee43791..000000000 --- a/libc/arch-x86_64/syscalls/readlink.S +++ /dev/null @@ -1,18 +0,0 @@ -/* Generated by gensyscalls.py. Do not edit. */ - -#include -#include -#include - -ENTRY(readlink) - movl $__NR_readlink, %eax - syscall - cmpq $-MAX_ERRNO, %rax - jb 1f - negl %eax - movl %eax, %edi - call __set_errno - orq $-1, %rax -1: - ret -END(readlink) diff --git a/libc/arch-x86_64/syscalls/readlinkat.S b/libc/arch-x86_64/syscalls/readlinkat.S new file mode 100644 index 000000000..209e4e977 --- /dev/null +++ b/libc/arch-x86_64/syscalls/readlinkat.S @@ -0,0 +1,19 @@ +/* Generated by gensyscalls.py. Do not edit. */ + +#include +#include +#include + +ENTRY(readlinkat) + movq %rcx, %r10 + movl $__NR_readlinkat, %eax + syscall + cmpq $-MAX_ERRNO, %rax + jb 1f + negl %eax + movl %eax, %edi + call __set_errno + orq $-1, %rax +1: + ret +END(readlinkat) diff --git a/libc/arch-x86_64/syscalls/rename.S b/libc/arch-x86_64/syscalls/rename.S deleted file mode 100644 index 2134732e8..000000000 --- a/libc/arch-x86_64/syscalls/rename.S +++ /dev/null @@ -1,18 +0,0 @@ -/* Generated by gensyscalls.py. Do not edit. */ - -#include -#include -#include - -ENTRY(rename) - movl $__NR_rename, %eax - syscall - cmpq $-MAX_ERRNO, %rax - jb 1f - negl %eax - movl %eax, %edi - call __set_errno - orq $-1, %rax -1: - ret -END(rename) diff --git a/libc/arch-x86_64/syscalls/rmdir.S b/libc/arch-x86_64/syscalls/rmdir.S deleted file mode 100644 index ecfe55882..000000000 --- a/libc/arch-x86_64/syscalls/rmdir.S +++ /dev/null @@ -1,18 +0,0 @@ -/* Generated by gensyscalls.py. Do not edit. */ - -#include -#include -#include - -ENTRY(rmdir) - movl $__NR_rmdir, %eax - syscall - cmpq $-MAX_ERRNO, %rax - jb 1f - negl %eax - movl %eax, %edi - call __set_errno - orq $-1, %rax -1: - ret -END(rmdir) diff --git a/libc/arch-x86_64/syscalls/stat.S b/libc/arch-x86_64/syscalls/stat.S deleted file mode 100644 index c6e2c8965..000000000 --- a/libc/arch-x86_64/syscalls/stat.S +++ /dev/null @@ -1,18 +0,0 @@ -/* Generated by gensyscalls.py. Do not edit. */ - -#include -#include -#include - -ENTRY(stat) - movl $__NR_stat, %eax - syscall - cmpq $-MAX_ERRNO, %rax - jb 1f - negl %eax - movl %eax, %edi - call __set_errno - orq $-1, %rax -1: - ret -END(stat) diff --git a/libc/arch-x86_64/syscalls/symlink.S b/libc/arch-x86_64/syscalls/symlink.S deleted file mode 100644 index 0edb484c3..000000000 --- a/libc/arch-x86_64/syscalls/symlink.S +++ /dev/null @@ -1,18 +0,0 @@ -/* Generated by gensyscalls.py. Do not edit. */ - -#include -#include -#include - -ENTRY(symlink) - movl $__NR_symlink, %eax - syscall - cmpq $-MAX_ERRNO, %rax - jb 1f - negl %eax - movl %eax, %edi - call __set_errno - orq $-1, %rax -1: - ret -END(symlink) diff --git a/libc/arch-x86_64/syscalls/__open.S b/libc/arch-x86_64/syscalls/symlinkat.S similarity index 80% rename from libc/arch-x86_64/syscalls/__open.S rename to libc/arch-x86_64/syscalls/symlinkat.S index a52235abf..3da76f270 100644 --- a/libc/arch-x86_64/syscalls/__open.S +++ b/libc/arch-x86_64/syscalls/symlinkat.S @@ -4,8 +4,8 @@ #include #include -ENTRY(__open) - movl $__NR_open, %eax +ENTRY(symlinkat) + movl $__NR_symlinkat, %eax syscall cmpq $-MAX_ERRNO, %rax jb 1f @@ -15,4 +15,4 @@ ENTRY(__open) orq $-1, %rax 1: ret -END(__open) +END(symlinkat) diff --git a/libc/arch-x86_64/syscalls/unlink.S b/libc/arch-x86_64/syscalls/unlink.S deleted file mode 100644 index 41fdc701f..000000000 --- a/libc/arch-x86_64/syscalls/unlink.S +++ /dev/null @@ -1,18 +0,0 @@ -/* Generated by gensyscalls.py. Do not edit. */ - -#include -#include -#include - -ENTRY(unlink) - movl $__NR_unlink, %eax - syscall - cmpq $-MAX_ERRNO, %rax - jb 1f - negl %eax - movl %eax, %edi - call __set_errno - orq $-1, %rax -1: - ret -END(unlink) diff --git a/libc/arch-x86_64/syscalls/utimes.S b/libc/arch-x86_64/syscalls/utimes.S deleted file mode 100644 index ff1fc6e0d..000000000 --- a/libc/arch-x86_64/syscalls/utimes.S +++ /dev/null @@ -1,18 +0,0 @@ -/* Generated by gensyscalls.py. Do not edit. */ - -#include -#include -#include - -ENTRY(utimes) - movl $__NR_utimes, %eax - syscall - cmpq $-MAX_ERRNO, %rax - jb 1f - negl %eax - movl %eax, %edi - call __set_errno - orq $-1, %rax -1: - ret -END(utimes) diff --git a/libc/bionic/open.c b/libc/bionic/access.cpp similarity index 67% rename from libc/bionic/open.c rename to libc/bionic/access.cpp index 6441dc28c..360b67252 100644 --- a/libc/bionic/open.c +++ b/libc/bionic/access.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008 The Android Open Source Project + * Copyright (C) 2013 The Android Open Source Project * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -25,35 +25,10 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ -#include + #include -#include -#include -#include "private/libc_logging.h" +#include -extern int __open(const char*, int, int); - -int open(const char* pathname, int flags, ...) { - mode_t mode = 0; - - flags |= O_LARGEFILE; - - if (flags & O_CREAT) { - va_list args; - va_start(args, flags); - mode = (mode_t) va_arg(args, int); - va_end(args); - } - - return __open(pathname, flags, mode); -} - -int __open_2(const char* pathname, int flags) { - if (__predict_false(flags & O_CREAT)) { - __fortify_chk_fail("open(O_CREAT): called without specifying a mode", 0); - } - - flags |= O_LARGEFILE; - - return __open(pathname, flags, 0); +int access(const char* path, int mode) { + return faccessat(AT_FDCWD, path, mode, 0); } diff --git a/libc/bionic/chmod.cpp b/libc/bionic/chmod.cpp new file mode 100644 index 000000000..d988f48ed --- /dev/null +++ b/libc/bionic/chmod.cpp @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2013 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 +#include +#include + +int chmod(const char* path, mode_t mode) { + return fchmodat(AT_FDCWD, path, mode, 0); +} diff --git a/libc/bionic/chown.cpp b/libc/bionic/chown.cpp new file mode 100644 index 000000000..bc2e6054e --- /dev/null +++ b/libc/bionic/chown.cpp @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2013 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 +#include +#include + +int chown(const char* path, uid_t uid, gid_t gid) { + return fchownat(AT_FDCWD, path, uid, gid, 0); +} diff --git a/libc/bionic/lchown.cpp b/libc/bionic/lchown.cpp new file mode 100644 index 000000000..95251db01 --- /dev/null +++ b/libc/bionic/lchown.cpp @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2013 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 +#include +#include + +int lchown(const char* path, uid_t uid, gid_t gid) { + return fchownat(AT_FDCWD, path, uid, gid, AT_SYMLINK_NOFOLLOW); +} diff --git a/libc/bionic/link.cpp b/libc/bionic/link.cpp new file mode 100644 index 000000000..65ad374e5 --- /dev/null +++ b/libc/bionic/link.cpp @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2013 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 +#include + +int link(const char* old_path, const char* new_path) { + return linkat(AT_FDCWD, old_path, AT_FDCWD, new_path, 0); +} diff --git a/libc/bionic/lstat.cpp b/libc/bionic/lstat.cpp new file mode 100644 index 000000000..300d7fa1a --- /dev/null +++ b/libc/bionic/lstat.cpp @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2013 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 +#include +#include +#include + +int lstat(const char* path, struct stat* sb) { + return fstatat(AT_FDCWD, path, sb, AT_SYMLINK_NOFOLLOW); +} diff --git a/libc/bionic/mkdir.cpp b/libc/bionic/mkdir.cpp new file mode 100644 index 000000000..90dc76159 --- /dev/null +++ b/libc/bionic/mkdir.cpp @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2013 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 +#include +#include + +int mkdir(const char* path, mode_t mode) { + return mkdirat(AT_FDCWD, path, mode); +} diff --git a/libc/bionic/mknod.cpp b/libc/bionic/mknod.cpp new file mode 100644 index 000000000..68d4309db --- /dev/null +++ b/libc/bionic/mknod.cpp @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2013 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 +#include +#include +#include + +int mknod(const char* path, mode_t mode, dev_t dev) { + return mknodat(AT_FDCWD, path, mode, dev); +} diff --git a/libc/bionic/openat.c b/libc/bionic/open.cpp similarity index 77% rename from libc/bionic/openat.c rename to libc/bionic/open.cpp index 56bb62749..e0dd181db 100644 --- a/libc/bionic/openat.c +++ b/libc/bionic/open.cpp @@ -25,13 +25,40 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ -#include + #include #include #include +#include + #include "private/libc_logging.h" -extern int __openat(int, const char*, int, int); +extern "C" int __openat(int, const char*, int, int); + +int open(const char* pathname, int flags, ...) { + mode_t mode = 0; + + flags |= O_LARGEFILE; + + if (flags & O_CREAT) { + va_list args; + va_start(args, flags); + mode = (mode_t) va_arg(args, int); + va_end(args); + } + + return __openat(AT_FDCWD, pathname, flags, mode); +} + +int __open_2(const char* pathname, int flags) { + if (__predict_false(flags & O_CREAT)) { + __fortify_chk_fail("open(O_CREAT): called without specifying a mode", 0); + } + + flags |= O_LARGEFILE; + + return __openat(AT_FDCWD, pathname, flags, 0); +} int openat(int fd, const char *pathname, int flags, ...) { mode_t mode = 0; diff --git a/libc/bionic/readlink.cpp b/libc/bionic/readlink.cpp new file mode 100644 index 000000000..a2c5e91a5 --- /dev/null +++ b/libc/bionic/readlink.cpp @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2013 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 +#include +#include + +ssize_t readlink(const char* path, char* buf, size_t size) { + return readlinkat(AT_FDCWD, path, buf, size); +} diff --git a/libc/bionic/rename.cpp b/libc/bionic/rename.cpp new file mode 100644 index 000000000..82955596b --- /dev/null +++ b/libc/bionic/rename.cpp @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2013 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 +#include + +int rename(const char* old_path, const char* new_path) { + return renameat(AT_FDCWD, old_path, AT_FDCWD, new_path); +} diff --git a/libc/bionic/rmdir.cpp b/libc/bionic/rmdir.cpp new file mode 100644 index 000000000..e7a9808da --- /dev/null +++ b/libc/bionic/rmdir.cpp @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2013 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 +#include + +int rmdir(const char* path) { + return unlinkat(AT_FDCWD, path, AT_REMOVEDIR); +} diff --git a/libc/bionic/stat.cpp b/libc/bionic/stat.cpp new file mode 100644 index 000000000..62387c5a6 --- /dev/null +++ b/libc/bionic/stat.cpp @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2013 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 +#include +#include +#include + +int stat(const char* path, struct stat* sb) { + return fstatat(AT_FDCWD, path, sb, 0); +} diff --git a/libc/bionic/symlink.cpp b/libc/bionic/symlink.cpp new file mode 100644 index 000000000..83cda47f4 --- /dev/null +++ b/libc/bionic/symlink.cpp @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2013 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 +#include + +int symlink(const char* old_path, const char* new_path) { + return symlinkat(old_path, AT_FDCWD, new_path); +} diff --git a/libc/bionic/unlink.cpp b/libc/bionic/unlink.cpp new file mode 100644 index 000000000..b1ab15c96 --- /dev/null +++ b/libc/bionic/unlink.cpp @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2013 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 +#include + +int unlink(const char* path) { + return unlinkat(AT_FDCWD, path, 0); +} diff --git a/libc/bionic/utimes.cpp b/libc/bionic/utimes.cpp new file mode 100644 index 000000000..315765ac6 --- /dev/null +++ b/libc/bionic/utimes.cpp @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2013 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 +#include +#include + +int utimes(const char* path, const timeval tv[2]) { + timespec ts[2]; + + // Whole seconds can just be copied. + ts[0].tv_sec = tv[0].tv_sec; + ts[1].tv_sec = tv[1].tv_sec; + + // But we might overflow when converting microseconds to nanoseconds. + if (tv[0].tv_usec >= 1000000 || tv[0].tv_usec < 0 || + tv[1].tv_usec >= 1000000 || tv[1].tv_usec < 0) { + errno = EINVAL; + return -1; + } + ts[0].tv_nsec = tv[0].tv_usec * 1000; + ts[1].tv_nsec = tv[1].tv_usec * 1000; + + return utimensat(AT_FDCWD, path, ts, 0); +} diff --git a/libc/include/stdio.h b/libc/include/stdio.h index a13cfeac6..409afeaf8 100644 --- a/libc/include/stdio.h +++ b/libc/include/stdio.h @@ -260,7 +260,8 @@ int vsprintf(char * __restrict, const char * __restrict, __printflike(2, 0); #endif -int rename (const char *, const char *); +extern int rename(const char*, const char*); +extern int renameat(int, const char*, int, const char*); int fgetpos(FILE * __restrict, fpos_t * __restrict); int fsetpos(FILE *, const fpos_t *); diff --git a/libc/include/sys/stat.h b/libc/include/sys/stat.h index 84e367fa9..ece44c64b 100644 --- a/libc/include/sys/stat.h +++ b/libc/include/sys/stat.h @@ -180,11 +180,10 @@ mode_t umask(mode_t mode) { extern int mkfifo(const char*, mode_t); -extern int fstatat(int dirfd, const char *path, struct stat *buf, int flags); -extern int mkdirat(int dirfd, const char *pathname, mode_t mode); -extern int fchownat(int dirfd, const char *path, uid_t owner, gid_t group, int flags); -extern int fchmodat(int dirfd, const char *path, mode_t mode, int flags); -extern int renameat(int olddirfd, const char *oldpath, int newdirfd, const char *newpath); +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) diff --git a/libc/include/unistd.h b/libc/include/unistd.h index fb1f663da..509ee5ceb 100644 --- a/libc/include/unistd.h +++ b/libc/include/unistd.h @@ -104,10 +104,12 @@ extern void endusershell(void); #define X_OK 1 /* Execute */ #define F_OK 0 /* Existence */ -extern int access(const char *, int); -extern int faccessat(int, const char *, int, int); -extern int link(const char *, const char *); -extern int unlink(const char *); +extern int access(const char*, int); +extern int faccessat(int, const char*, int, int); +extern int link(const char*, const char*); +extern int linkat(int, const char*, int, const char*, int); +extern int unlink(const char*); +extern int unlinkat(int, const char*, int); extern int chdir(const char *); extern int fchdir(int); extern int rmdir(const char *); @@ -116,10 +118,13 @@ extern int pipe(int *); extern int pipe2(int *, int); #endif extern int chroot(const char *); -extern int symlink(const char *, const char *); -extern int readlink(const char *, char *, size_t); +extern int symlink(const char*, const char*); +extern int symlinkat(const char*, int, const char*); +extern ssize_t readlink(const char*, char*, size_t); +extern ssize_t readlinkat(int, const char*, char*, size_t); extern int chown(const char *, uid_t, gid_t); extern int fchown(int, uid_t, gid_t); +extern int fchownat(int, const char*, uid_t, gid_t, int); extern int lchown(const char *, uid_t, gid_t); extern int truncate(const char *, off_t); extern int truncate64(const char *, off64_t); diff --git a/tests/Android.mk b/tests/Android.mk index 59e51299c..5bcf996c4 100644 --- a/tests/Android.mk +++ b/tests/Android.mk @@ -84,6 +84,7 @@ test_src_files = \ sys_select_test.cpp \ sys_sendfile_test.cpp \ sys_stat_test.cpp \ + sys_time_test.cpp \ system_properties_test.cpp \ time_test.cpp \ unistd_test.cpp \ diff --git a/tests/sys_time_test.cpp b/tests/sys_time_test.cpp new file mode 100644 index 000000000..186aa16c9 --- /dev/null +++ b/tests/sys_time_test.cpp @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include +#include + +TEST(sys_time, utimes) { + timeval tv[2]; + memset(&tv, 0, sizeof(tv)); + + tv[0].tv_usec = -123; + ASSERT_EQ(-1, utimes("/", tv)); + ASSERT_EQ(EINVAL, errno); + tv[0].tv_usec = 1234567; + ASSERT_EQ(-1, utimes("/", tv)); + ASSERT_EQ(EINVAL, errno); + tv[0].tv_usec = 0; + + tv[1].tv_usec = -123; + ASSERT_EQ(-1, utimes("/", tv)); + ASSERT_EQ(EINVAL, errno); + tv[1].tv_usec = 1234567; + ASSERT_EQ(-1, utimes("/", tv)); + ASSERT_EQ(EINVAL, errno); +}