[PATCH v2 36/46] fstat: Use fstat64() if arch does not have the fstat syscall

Markos Chandras markos.chandras at gmail.com
Mon Nov 26 14:24:18 UTC 2012


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

Signed-off-by: Markos Chandras <markos.chandras at imgtec.com>
---
 libc/sysdeps/linux/common/fstat.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/libc/sysdeps/linux/common/fstat.c b/libc/sysdeps/linux/common/fstat.c
index 4726a68..cf69580 100644
--- a/libc/sysdeps/linux/common/fstat.c
+++ b/libc/sysdeps/linux/common/fstat.c
@@ -12,6 +12,22 @@
 #include <sys/stat.h>
 #include "xstatconv.h"
 
+#if defined(__NR_fstat64) && !defined(__NR_fstat)
+int fstat(int fd, struct stat *buf)
+{
+	int result;
+	struct kernel_stat64 kbuf;
+
+	result = INLINE_SYSCALL(fstat64, 2, fd, &kbuf);
+
+	if (result == 0)
+		__xstat32_conv(&kbuf, buf);
+
+	return result;
+}
+libc_hidden_def(fstat)
+
+#elif defined(__NR_fstat)
 int fstat(int fd, struct stat *buf)
 {
 	int result;
@@ -38,7 +54,9 @@ int fstat(int fd, struct stat *buf)
 }
 libc_hidden_def(fstat)
 
-#if ! defined __NR_fstat64 && defined __UCLIBC_HAS_LFS__
+#if ! defined (__NR_fstat64) && defined __UCLIBC_HAS_LFS__
 strong_alias_untyped(fstat,fstat64)
 libc_hidden_def(fstat64)
 #endif
+
+#endif
-- 
1.8.0




More information about the uClibc mailing list