[PATCH v2 35/46] stat: Use fstatat64 if arch does not have the stat syscall
Markos Chandras
markos.chandras at gmail.com
Mon Nov 26 14:24:17 UTC 2012
From: Markos Chandras <markos.chandras at imgtec.com>
Signed-off-by: Markos Chandras <markos.chandras at imgtec.com>
---
libc/sysdeps/linux/common/stat.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/libc/sysdeps/linux/common/stat.c b/libc/sysdeps/linux/common/stat.c
index 829f35a..038e0c0 100644
--- a/libc/sysdeps/linux/common/stat.c
+++ b/libc/sysdeps/linux/common/stat.c
@@ -8,12 +8,21 @@
*/
#include <sys/syscall.h>
+#include <fcntl.h>
#include <unistd.h>
#include <sys/stat.h>
#include "xstatconv.h"
#undef stat
+#if defined(__NR_fstat64) && !defined(__NR_stat)
+int stat(const char *file_name, struct stat *buf)
+{
+ return fstatat(AT_FDCWD, file_name, buf, 0);
+}
+
+#else
+
int stat(const char *file_name, struct stat *buf)
{
int result;
@@ -35,12 +44,14 @@ int stat(const char *file_name, struct stat *buf)
if (result == 0) {
__xstat_conv(&kbuf, buf);
}
-#endif
+#endif /* __NR_stat64 */
return result;
}
+#endif /* __NR_fstat64 */
libc_hidden_def(stat)
-#if ! defined __NR_stat64 && defined __UCLIBC_HAS_LFS__
+#if ! defined __NR_stat64 && ! defined __NR_fstatat64 && \
+ defined __UCLIBC_HAS_LFS__
strong_alias_untyped(stat,stat64)
libc_hidden_def(stat64)
-#endif
+#endif /* __UCLIBC_HAS_LFS__ */
--
1.8.0
More information about the uClibc
mailing list