[klibc] [PATCH klibc 1/2] rename, renameat: Use renameat2() system call
Ben Hutchings
ben at decadent.org.uk
Mon Jul 16 19:08:36 PDT 2018
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.
Signed-off-by: Ben Hutchings <ben at decadent.org.uk>
---
--- a/usr/klibc/Kbuild
+++ b/usr/klibc/Kbuild
@@ -59,7 +59,8 @@ klib-y += vsnprintf.o snprintf.o vsprint
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 select.o symlink.o pipe.o \
ctype/isalnum.o ctype/isalpha.o ctype/isascii.o \
--- 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 */
--- /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 */
--- 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);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 811 bytes
Desc: Digital signature
URL: <http://www.zytor.com/pipermail/klibc/attachments/20180717/cef82a9b/attachment.sig>
More information about the klibc
mailing list