Browse Source

access: Use faccessat if arch does not have the access syscall

Signed-off-by: Markos Chandras <markos.chandras@imgtec.com>

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Markos Chandras 11 years ago
parent
commit
695e274cf7
3 changed files with 12 additions and 0 deletions
  1. 1 0
      include/unistd.h
  2. 10 0
      libc/sysdeps/linux/common/access.c
  3. 1 0
      libc/sysdeps/linux/common/faccessat.c

+ 1 - 0
include/unistd.h

@@ -307,6 +307,7 @@ extern int eaccess (const char *__name, int __type)
    otherwise use real IDs like `access'.  */
 extern int faccessat (int __fd, const char *__file, int __type, int __flag)
      __THROW __nonnull ((2)) __wur;
+libc_hidden_proto(faccessat)
 #endif /* Use GNU.  */
 
 

+ 10 - 0
libc/sysdeps/linux/common/access.c

@@ -9,4 +9,14 @@
 
 #include <sys/syscall.h>
 #include <unistd.h>
+
+#if defined __NR_faccessat && !defined __NR_access
+# include <fcntl.h>
+int access(const char *pathname, int mode)
+{
+	return faccessat(AT_FDCWD, pathname, mode, 0);
+}
+
+#else
 _syscall2(int, access, const char *, pathname, int, mode)
+#endif

+ 1 - 0
libc/sysdeps/linux/common/faccessat.c

@@ -11,6 +11,7 @@
 
 #ifdef __NR_faccessat
 _syscall4(int, faccessat, int, fd, const char *, file, int, type, int, flag)
+libc_hidden_def(faccessat)
 #else
 /* should add emulation with faccess() and /proc/self/fd/ ... */
 #endif