summaryrefslogtreecommitdiff
path: root/libc/sysdeps/linux/common
diff options
context:
space:
mode:
authorMarkos Chandras <markos.chandras@imgtec.com>2012-10-10 15:17:10 +0100
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2013-02-20 13:45:11 +0100
commit3a5be53a84ac68255fbcecb73b8fe58a35550c26 (patch)
treeb7bc2eb2508b2f03691d1570127c6a7f9fdfa615 /libc/sysdeps/linux/common
parentecb2be2c0a2f9c489663a4b01b97074dda2ceb1e (diff)
rename: Use renameat if arch does not have the rename syscall
Signed-off-by: Markos Chandras <markos.chandras@imgtec.com> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Diffstat (limited to 'libc/sysdeps/linux/common')
-rw-r--r--libc/sysdeps/linux/common/rename.c9
-rw-r--r--libc/sysdeps/linux/common/renameat.c1
2 files changed, 10 insertions, 0 deletions
diff --git a/libc/sysdeps/linux/common/rename.c b/libc/sysdeps/linux/common/rename.c
index 6183cf494..3ce5a5e3e 100644
--- a/libc/sysdeps/linux/common/rename.c
+++ b/libc/sysdeps/linux/common/rename.c
@@ -9,5 +9,14 @@
#include <sys/syscall.h>
#include <stdio.h>
+#include <unistd.h>
+#if defined __NR_renameat && !defined __NR_rename
+# include <fcntl.h>
+int rename(const char *oldpath, const char *newpath)
+{
+ return renameat(AT_FDCWD, oldpath, AT_FDCWD, newpath);
+}
+#else
_syscall2(int, rename, const char *, oldpath, const char *, newpath)
+#endif
diff --git a/libc/sysdeps/linux/common/renameat.c b/libc/sysdeps/linux/common/renameat.c
index a898f7b86..b0b91fa3e 100644
--- a/libc/sysdeps/linux/common/renameat.c
+++ b/libc/sysdeps/linux/common/renameat.c
@@ -11,6 +11,7 @@
#ifdef __NR_renameat
_syscall4(int, renameat, int, oldfd, const char *, old, int, newfd, const char *, new)
+libc_hidden_def(renameat)
#else
/* should add emulation with rename() and /proc/self/fd/ ... */
#endif