[git commit] stat64: Use fstatat64 if arch does not have the stat64 syscall

Bernhard Reutner-Fischer rep.dot.nop at gmail.com
Wed Feb 20 12:45:13 UTC 2013


commit: http://git.uclibc.org/uClibc/commit/?id=36b3c53f924f049e32d677e914592389b875d28b
branch: http://git.uclibc.org/uClibc/commit/?id=refs/heads/master

Signed-off-by: Markos Chandras <markos.chandras at imgtec.com>

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop at gmail.com>
---
 include/sys/stat.h                    |    1 +
 libc/sysdeps/linux/common/fstatat64.c |    1 +
 libc/sysdeps/linux/common/stat64.c    |   23 +++++++++++++++++++----
 3 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/include/sys/stat.h b/include/sys/stat.h
index 9283a89..f3a52ad 100644
--- a/include/sys/stat.h
+++ b/include/sys/stat.h
@@ -256,6 +256,7 @@ extern int __REDIRECT_NTH (fstatat, (int __fd, const char *__restrict __file,
 extern int fstatat64 (int __fd, const char *__restrict __file,
 		      struct stat64 *__restrict __buf, int __flag)
      __THROW __nonnull ((2, 3));
+libc_hidden_proto(fstatat64)
 # endif
 #endif
 
diff --git a/libc/sysdeps/linux/common/fstatat64.c b/libc/sysdeps/linux/common/fstatat64.c
index fbf0963..015f57d 100644
--- a/libc/sysdeps/linux/common/fstatat64.c
+++ b/libc/sysdeps/linux/common/fstatat64.c
@@ -33,6 +33,7 @@ int fstatat64(int fd, const char *file, struct stat64 *buf, int flag)
 	return INLINE_SYSCALL(fstatat64, 4, fd, file, buf, flag);
 # endif
 }
+libc_hidden_def(fstatat64)
 #else
 /* should add emulation with fstat64() and /proc/self/fd/ ... */
 #endif
diff --git a/libc/sysdeps/linux/common/stat64.c b/libc/sysdeps/linux/common/stat64.c
index ef34faf..cb3a0e1 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__ */


More information about the uClibc-cvs mailing list