Browse Source

lstat64: Use fstatat64 if arch does not have the lstat64 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
789e2402f3
1 changed files with 12 additions and 2 deletions
  1. 12 2
      libc/sysdeps/linux/common/lstat64.c

+ 12 - 2
libc/sysdeps/linux/common/lstat64.c

@@ -10,11 +10,21 @@
 #include <_lfs_64.h>
 #include <sys/syscall.h>
 
-#ifdef __NR_lstat64
 # include <unistd.h>
 # include <sys/stat.h>
-# include "xstatconv.h"
 
+#if defined __NR_fstatat64 && !defined __NR_lstat64
+# include <fcntl.h>
+
+int lstat64(const char *file_name, struct stat64 *buf)
+{
+	return fstatat64(AT_FDCWD, file_name, buf, AT_SYMLINK_NOFOLLOW);
+}
+libc_hidden_def(lstat64)
+
+/* For systems which have both, prefer the old one */
+#elif defined __NR_lstat64
+# include "xstatconv.h"
 # define __NR___syscall_lstat64 __NR_lstat64
 static __always_inline _syscall2(int, __syscall_lstat64, const char *, file_name,
 				 struct kernel_stat64 *, buf)