summaryrefslogtreecommitdiff
path: root/libc/sysdeps/linux/common/stat64.c
diff options
context:
space:
mode:
authorMarkos Chandras <markos.chandras@imgtec.com>2012-10-11 12:18:54 +0100
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2013-02-20 13:45:13 +0100
commit36b3c53f924f049e32d677e914592389b875d28b (patch)
treea51ebe06b3010f19f1ae3d4d6d1725d1792fe572 /libc/sysdeps/linux/common/stat64.c
parent82fd359bcccb162d78c3b7fbd572ac074aee98e9 (diff)
stat64: Use fstatat64 if arch does not have the stat64 syscall
Signed-off-by: Markos Chandras <markos.chandras@imgtec.com> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Diffstat (limited to 'libc/sysdeps/linux/common/stat64.c')
-rw-r--r--libc/sysdeps/linux/common/stat64.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/libc/sysdeps/linux/common/stat64.c b/libc/sysdeps/linux/common/stat64.c
index ef34faf7d..cb3a0e169 100644
--- a/libc/sysdeps/linux/common/stat64.c
+++ b/libc/sysdeps/linux/common/stat64.c
@@ -9,11 +9,24 @@
#include <_lfs_64.h>
#include <sys/syscall.h>
+#include <sys/stat.h>
-#ifdef __NR_stat64
-# include <sys/stat.h>
-# include "xstatconv.h"
+#if defined __UCLIBC_HAS_LFS__
+
+# if defined __NR_fstatat64 && !defined __NR_stat64
+# include <fcntl.h>
+# include <unistd.h>
+
+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 "xstatconv.h"
static __always_inline _syscall2(int, __syscall_stat64,
const char *, file_name, struct kernel_stat64 *, buf)
@@ -29,4 +42,6 @@ int stat64(const char *file_name, struct stat64 *buf)
return result;
}
libc_hidden_def(stat64)
-#endif
+# endif
+
+#endif /* __UCLIBC_HAS_LFS__ */