[prev in list] [next in list] [prev in thread] [next in thread] 

List:       uclibc
Subject:    [PATCH v3 40/48] stat: Use fstatat64 if arch does not have the stat syscall
From:       Markos Chandras <markos.chandras () gmail ! com>
Date:       2013-01-23 11:42:04
Message-ID: 1358941332-6190-41-git-send-email-markos.chandras () gmail ! com
[Download RAW message or body]

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

Signed-off-by: Markos Chandras <markos.chandras@imgtec.com>
---
 include/sys/stat.h                  |  1 +
 libc/sysdeps/linux/common/fstatat.c |  1 +
 libc/sysdeps/linux/common/stat.c    | 17 ++++++++++++++---
 3 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/include/sys/stat.h b/include/sys/stat.h
index f3a52ad..495a68c 100644
--- a/include/sys/stat.h
+++ b/include/sys/stat.h
@@ -241,6 +241,7 @@ libc_hidden_proto(fstat64)
 extern int fstatat (int __fd, const char *__restrict __file,
 		    struct stat *__restrict __buf, int __flag)
      __THROW __nonnull ((2, 3));
+libc_hidden_proto(fstatat)
 # else
 #  ifdef __REDIRECT_NTH
 extern int __REDIRECT_NTH (fstatat, (int __fd, const char *__restrict __file,
diff --git a/libc/sysdeps/linux/common/fstatat.c b/libc/sysdeps/linux/common/fstatat.c
index 2fde220..51c2922 100644
--- a/libc/sysdeps/linux/common/fstatat.c
+++ b/libc/sysdeps/linux/common/fstatat.c
@@ -38,6 +38,7 @@ int fstatat(int fd, const char *file, struct stat *buf, int flag)
 #endif /* __ARCH_HAS_DEPRECATED_SYSCALLS__ */
 	return ret;
 }
+libc_hidden_def(fstatat)
 #else
 /* should add emulation with fstat() and /proc/self/fd/ ... */
 #endif
diff --git a/libc/sysdeps/linux/common/stat.c b/libc/sysdeps/linux/common/stat.c
index 829f35a..41cb363 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_fstatat64) && !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.1.1


_______________________________________________
uClibc mailing list
uClibc@uclibc.org
http://lists.busybox.net/mailman/listinfo/uclibc
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic