[PATCH 10/46] rename: Use renameat if arch does not have the rename syscall
Markos Chandras
markos.chandras at gmail.com
Tue Nov 13 11:31:19 UTC 2012
From: Markos Chandras <markos.chandras at imgtec.com>
Signed-off-by: Markos Chandras <markos.chandras at imgtec.com>
---
libc/sysdeps/linux/common/rename.c | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/libc/sysdeps/linux/common/rename.c b/libc/sysdeps/linux/common/rename.c
index 9d8397a..05f1411 100644
--- a/libc/sysdeps/linux/common/rename.c
+++ b/libc/sysdeps/linux/common/rename.c
@@ -8,11 +8,18 @@
*/
#include <sys/syscall.h>
+#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <sys/param.h>
#include <stdio.h>
+#if defined(__NR_renameat) && ! defined(__NR_rename)
+int rename(const char* oldpath, const char* newpath)
+{
+ return renameat(AT_FDCWD, oldpath, AT_FDCWD, newpath);
+}
+#else
#define __NR___syscall_rename __NR_rename
static __inline__ _syscall2(int, __syscall_rename, const char *, oldpath,
const char *, newpath)
@@ -21,4 +28,4 @@ int rename(const char * oldpath, const char * newpath)
{
return __syscall_rename(oldpath, newpath);
}
-
+#endif
--
1.7.1
More information about the uClibc
mailing list