[PATCH 30/46] stat64: Use fstatat64 if arch does not have the stat64 syscall

Markos Chandras markos.chandras at gmail.com
Tue Nov 13 11:31:39 UTC 2012


From: Markos Chandras <markos.chandras at imgtec.com>

Signed-off-by: Markos Chandras <markos.chandras at imgtec.com>
---
 libc/sysdeps/linux/common/stat64.c |   16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/libc/sysdeps/linux/common/stat64.c b/libc/sysdeps/linux/common/stat64.c
index a76f182..52e82ec 100644
--- a/libc/sysdeps/linux/common/stat64.c
+++ b/libc/sysdeps/linux/common/stat64.c
@@ -9,11 +9,21 @@
 
 #include <sys/syscall.h>
 #include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
 
-#if defined __UCLIBC_HAS_LFS__ && defined __NR_stat64
+#if defined __UCLIBC_HAS_LFS__
 
+#if defined(__NR_fstatat64) && ! defined(__NR_stat64)
+int stat64(const char* file_name, struct stat64* buf)
+{
+	return fstatat64(AT_FDCWD, file_name, buf, 0);
+}
+libc_hidden_def(stat64)
+
+/* For systems which have both, prefer the old one */
+#elif defined(__NR_stat64)
 # define __NR___syscall_stat64 __NR_stat64
-# include <unistd.h>
 # include "xstatconv.h"
 
 static __inline__ _syscall2(int, __syscall_stat64,
@@ -32,3 +42,5 @@ int stat64(const char *file_name, struct stat64 *buf)
 }
 libc_hidden_def(stat64)
 #endif
+
+#endif /* __UCLIBC_HAS_LFS__ */
-- 
1.7.1




More information about the uClibc mailing list