[git commit] fstatfs: Add __libc_fstatfs wrapper

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=09e782b088e77eff01e9b08dd0f5dd4896e9d417
branch: http://git.uclibc.org/uClibc/commit/?id=refs/heads/master

New architectures don't have fstatfs anymore, so we use a wrapper for
__libc_fstatfs which will use fstatfs64 internally. The interface however
needs to remain the same (i.e accepting a struct statfs as a second
argument) for backwards compatibility

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

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop at gmail.com>
---
 libc/sysdeps/linux/common/fstatfs.c |   23 +++++++++++++++++++++--
 libc/sysdeps/linux/common/stubs.c   |    3 ++-
 2 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/libc/sysdeps/linux/common/fstatfs.c b/libc/sysdeps/linux/common/fstatfs.c
index fa0024a..111a399 100644
--- a/libc/sysdeps/linux/common/fstatfs.c
+++ b/libc/sysdeps/linux/common/fstatfs.c
@@ -9,8 +9,9 @@
 
 #include <sys/syscall.h>
 #include <sys/vfs.h>
+#include <string.h>
 
-#ifndef __USE_FILE_OFFSET64
+#ifndef __USE_FILE_OFFSET64__
 extern int fstatfs (int __fildes, struct statfs *__buf)
      __THROW __nonnull ((2));
 #else
@@ -23,8 +24,26 @@ extern int __REDIRECT_NTH (fstatfs, (int __fildes, struct statfs *__buf),
 #endif
 
 extern __typeof(fstatfs) __libc_fstatfs attribute_hidden;
-#define __NR___libc_fstatfs __NR_fstatfs
+#ifdef __NR_fstatfs
+# define __NR___libc_fstatfs __NR_fstatfs
 _syscall2(int, __libc_fstatfs, int, fd, struct statfs *, buf)
+#else
+int __libc_fstatfs (int __fildes, struct statfs *__buf)
+{
+	int err = INLINE_SYSCALL(fstatfs64, 3, __fildes, sizeof(*__buf), __buf);
+
+	if (err == 0) {
+		/* Did we overflow? */
+		if (__buf->__pad1 || __buf->__pad2 || __buf->__pad3 ||
+		    __buf->__pad4 || __buf->__pad5) {
+			__set_errno(EOVERFLOW);
+			return -1;
+		}
+	}
+	return err;
+};
+/* Redefined fstatfs because we need it for backwards compatibility */
+#endif /* __NR_fstatfs */
 
 #if defined __UCLIBC_LINUX_SPECIFIC__
 weak_alias(__libc_fstatfs,fstatfs)
diff --git a/libc/sysdeps/linux/common/stubs.c b/libc/sysdeps/linux/common/stubs.c
index 36fcc62..83bcf47 100644
--- a/libc/sysdeps/linux/common/stubs.c
+++ b/libc/sysdeps/linux/common/stubs.c
@@ -140,7 +140,8 @@ make_stub(fremovexattr)
 make_stub(fsetxattr)
 #endif
 
-#if !defined __NR_fstatfs && defined __UCLIBC_LINUX_SPECIFIC__
+#if !defined __NR_fstatfs && !defined __NR_fstatfs64 \
+	&& defined __UCLIBC_LINUX_SPECIFIC__
 make_stub(fstatfs)
 #endif
 


More information about the uClibc-cvs mailing list