Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/benh/powerpc
[cascardo/linux.git] / fs / hostfs / hostfs_user.c
index 67838f3..9765dab 100644 (file)
@@ -14,6 +14,7 @@
 #include <sys/time.h>
 #include <sys/types.h>
 #include <sys/vfs.h>
+#include <sys/syscall.h>
 #include "hostfs.h"
 #include <utime.h>
 
@@ -360,6 +361,33 @@ int rename_file(char *from, char *to)
        return 0;
 }
 
+int rename2_file(char *from, char *to, unsigned int flags)
+{
+       int err;
+
+#ifndef SYS_renameat2
+#  ifdef __x86_64__
+#    define SYS_renameat2 316
+#  endif
+#  ifdef __i386__
+#    define SYS_renameat2 353
+#  endif
+#endif
+
+#ifdef SYS_renameat2
+       err = syscall(SYS_renameat2, AT_FDCWD, from, AT_FDCWD, to, flags);
+       if (err < 0) {
+               if (errno != ENOSYS)
+                       return -errno;
+               else
+                       return -EINVAL;
+       }
+       return 0;
+#else
+       return -EINVAL;
+#endif
+}
+
 int do_statfs(char *root, long *bsize_out, long long *blocks_out,
              long long *bfree_out, long long *bavail_out,
              long long *files_out, long long *ffree_out,