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

List:       uclibc
Subject:    [PATCH v3 32/48] fstat: Use fstat64 if arch does not have the fstat syscall
From:       Markos Chandras <markos.chandras () gmail ! com>
Date:       2013-01-23 11:41:56
Message-ID: 1358941332-6190-33-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>
---
 libc/sysdeps/linux/common/fstat.c   | 20 ++++++++++++++++++++
 libc/sysdeps/linux/common/fstat64.c |  4 ++++
 2 files changed, 24 insertions(+)

diff --git a/libc/sysdeps/linux/common/fstat.c b/libc/sysdeps/linux/common/fstat.c
index 4726a68..3034bd0 100644
--- a/libc/sysdeps/linux/common/fstat.c
+++ b/libc/sysdeps/linux/common/fstat.c
@@ -12,6 +12,24 @@
 #include <sys/stat.h>
 #include "xstatconv.h"
 
+#if defined(__NR_fstat64) && !defined(__NR_fstat)
+int fstat(int fd, struct stat *buf)
+{
+	int result = INLINE_SYSCALL(fstat64, 2, fd, buf);
+	if (result == 0) {
+		/* Did we overflow? */
+		if (buf->__pad1 || buf->__pad2 || buf->__pad3
+		    || buf->__pad4 || buf->__pad5
+		    || buf->__pad6 || buf->__pad7) {
+			__set_errno(EOVERFLOW);
+			return -1;
+		}
+	}
+	return result;
+}
+libc_hidden_def(fstat)
+
+#elif defined(__NR_fstat)
 int fstat(int fd, struct stat *buf)
 {
 	int result;
@@ -42,3 +60,5 @@ libc_hidden_def(fstat)
 strong_alias_untyped(fstat,fstat64)
 libc_hidden_def(fstat64)
 #endif
+
+#endif
diff --git a/libc/sysdeps/linux/common/fstat64.c b/libc/sysdeps/linux/common/fstat64.c
index 7460c26..4a14a74 100644
--- a/libc/sysdeps/linux/common/fstat64.c
+++ b/libc/sysdeps/linux/common/fstat64.c
@@ -21,6 +21,7 @@ static __always_inline _syscall2(int, __syscall_fstat64,
 int fstat64(int fd, struct stat64 *buf)
 {
 	int result;
+#ifdef __ARCH_HAS_DEPRECATED_SYSCALLS__
 	struct kernel_stat64 kbuf;
 
 	result = __syscall_fstat64(fd, &kbuf);
@@ -28,6 +29,9 @@ int fstat64(int fd, struct stat64 *buf)
 		__xstat64_conv(&kbuf, buf);
 	}
 	return result;
+#else
+	return __syscall_fstat64(fd, buf);
+#endif
 }
 libc_hidden_def(fstat64)
 #endif
-- 
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