diff options
author | Ben Hutchings <ben@decadent.org.uk> | 2018-07-16 18:24:08 +0100 |
---|---|---|
committer | Ben Hutchings <ben@decadent.org.uk> | 2019-01-02 03:08:04 +0000 |
commit | d8d26edbf94316286900ecf363382b0fcc2d76b2 (patch) | |
tree | b3b4c88b4cb6b7f69b8dcd2b4d17736a40517166 | |
parent | edee9092e32482a06cc441cf47ae78b5e7c4a621 (diff) | |
download | klibc-d8d26edbf94316286900ecf363382b0fcc2d76b2.tar.gz |
[klibc] rename, renameat: Use renameat2() system call
New architectures only define the renameat2() system call, which was
added in Linux 3.15. Define rename() and renameat() as wrappers for
it if necessary.
Link: https://www.zytor.com/pipermail/klibc/2018-July/003996.html
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
-rw-r--r-- | usr/klibc/Kbuild | 3 | ||||
-rw-r--r-- | usr/klibc/SYSCALLS.def | 1 | ||||
-rw-r--r-- | usr/klibc/rename.c | 2 | ||||
-rw-r--r-- | usr/klibc/renameat.c | 12 |
4 files changed, 16 insertions, 2 deletions
diff --git a/usr/klibc/Kbuild b/usr/klibc/Kbuild index eba6addf90b3a1..b19f3ab11d19d0 100644 --- a/usr/klibc/Kbuild +++ b/usr/klibc/Kbuild @@ -59,7 +59,8 @@ klib-y += vsnprintf.o snprintf.o vsprintf.o sprintf.o \ inet/inet_ntoa.o inet/inet_aton.o inet/inet_addr.o \ inet/inet_ntop.o inet/inet_pton.o inet/bindresvport.o \ accept.o send.o recv.o \ - access.o chmod.o chown.o dup2.o mknod.o poll.o rename.o stat.o \ + access.o chmod.o chown.o dup2.o mknod.o poll.o rename.o renameat.o \ + stat.o \ lchown.o link.o rmdir.o unlink.o utimes.o lstat.o mkdir.o \ readlink.o realpath.o select.o symlink.o pipe.o \ ctype/isalnum.o ctype/isalpha.o ctype/isascii.o \ diff --git a/usr/klibc/SYSCALLS.def b/usr/klibc/SYSCALLS.def index c56e8f99783814..64d7b0c1376665 100644 --- a/usr/klibc/SYSCALLS.def +++ b/usr/klibc/SYSCALLS.def @@ -116,6 +116,7 @@ int chdir(const char *); int fchdir(int); <?> int rename(const char *, const char *); <?> int renameat(int, const char *, int, const char *); +<?> int renameat2(int, const char *, int, const char *, unsigned int); <?> int mknod(const char *, mode_t, dev_t); <?> int mknodat(int, const char *, mode_t, dev_t); <?> int chmod(const char *, mode_t); diff --git a/usr/klibc/rename.c b/usr/klibc/rename.c index 587c26f8b4983e..d76b7397502ab5 100644 --- a/usr/klibc/rename.c +++ b/usr/klibc/rename.c @@ -5,7 +5,7 @@ int rename(const char *oldpath, const char *newpath) { - return renameat(AT_FDCWD, oldpath, AT_FDCWD, newpath); + return renameat2(AT_FDCWD, oldpath, AT_FDCWD, newpath, 0); } #endif /* __NR_rename */ diff --git a/usr/klibc/renameat.c b/usr/klibc/renameat.c new file mode 100644 index 00000000000000..10c88827bd042c --- /dev/null +++ b/usr/klibc/renameat.c @@ -0,0 +1,12 @@ +#include <fcntl.h> +#include <stdio.h> + +#ifndef __NR_renameat + +int renameat(int olddirfd, const char *oldpath, + int newdirfd, const char *newpath) +{ + return renameat2(olddirfd, oldpath, newdirfd, newpath, 0); +} + +#endif /* __NR_renameat */ |