[PATCH 32/46] lstat64: Use fstatat64 if arch does not have the lstat64 syscall
Markos Chandras
markos.chandras at gmail.com
Tue Nov 13 11:31:41 UTC 2012
From: Markos Chandras <markos.chandras at imgtec.com>
Signed-off-by: Markos Chandras <markos.chandras at imgtec.com>
---
libc/sysdeps/linux/common/lstat64.c | 14 +++++++++++++-
1 files changed, 13 insertions(+), 1 deletions(-)
diff --git a/libc/sysdeps/linux/common/lstat64.c b/libc/sysdeps/linux/common/lstat64.c
index 235b76d..9717335 100644
--- a/libc/sysdeps/linux/common/lstat64.c
+++ b/libc/sysdeps/linux/common/lstat64.c
@@ -9,12 +9,22 @@
#include <sys/syscall.h>
-#if defined __UCLIBC_HAS_LFS__ && defined __NR_lstat64
+#if defined __UCLIBC_HAS_LFS__
+# include <fcntl.h>
# include <unistd.h>
# include <sys/stat.h>
# include "xstatconv.h"
+#if defined(__NR_fstatat64) && ! defined(__NR_lstat64)
+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)
# define __NR___syscall_lstat64 __NR_lstat64
static __inline__ _syscall2(int, __syscall_lstat64, const char *, file_name,
struct kernel_stat64 *, buf)
@@ -33,3 +43,5 @@ int lstat64(const char *file_name, struct stat64 *buf)
libc_hidden_def(lstat64)
#endif
+
+#endif /* __UCLIBC_HAS_LFS__ */
--
1.7.1
More information about the uClibc
mailing list