support archs with no renameat syscall, only renameat2
authorDrew DeVault <sir@cmpwn.com>
Thu, 21 Mar 2019 15:32:39 +0000 (11:32 -0400)
committerRich Felker <dalias@aerifal.cx>
Fri, 22 Mar 2019 01:18:46 +0000 (21:18 -0400)
src/stdio/rename.c
src/unistd/renameat.c

index 04c90c01343a4b84beb5cf56b348e5d5041905ed..f540adb6cd9c2ddaff0559c39ad907007dd5510f 100644 (file)
@@ -4,9 +4,11 @@
 
 int rename(const char *old, const char *new)
 {
-#ifdef SYS_rename
+#if defined(SYS_rename)
        return syscall(SYS_rename, old, new);
-#else
+#elif defined(SYS_renameat)
        return syscall(SYS_renameat, AT_FDCWD, old, AT_FDCWD, new);
+#else
+       return syscall(SYS_renameat2, AT_FDCWD, old, AT_FDCWD, new, 0);
 #endif
 }
index 125748221f13c3a4fe5fb33684f309c18f802ed7..c3b40a258b2822214ce05a0cf1788d9af6298067 100644 (file)
@@ -3,5 +3,9 @@
 
 int renameat(int oldfd, const char *old, int newfd, const char *new)
 {
+#ifdef SYS_renameat
        return syscall(SYS_renameat, oldfd, old, newfd, new);
+#else
+       return syscall(SYS_renameat2, oldfd, old, newfd, new, 0);
+#endif
 }