[git commit] libc/statfs64: Skip conversion code for new architectures

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


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

Fixes the following tests in LTP

statfs02_64 ( test case #5 )

The purpose of this test is to pass an invalid pointer to the statfs64
syscall and check if the kernel returns EFAULT or not. However,
uClibc creates a new statfs struct which is then passed to the kernel.
As a result of which, the kernel returns 0 because the newly created
statfs structure is valid. But, when copying the contens of the new
pointer to the old userspace one, the uClibc segfauls because the old
pointer is invalid. Old architectures are doomed to suffer by this
problem but new architectures can use the statfs64 syscall directly
so that the userspace pointer is passed directly to the kernel and get
the correct errno at the end.

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

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop at gmail.com>
---
 libc/misc/statfs/statfs64.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/libc/misc/statfs/statfs64.c b/libc/misc/statfs/statfs64.c
index ce8211b..b1a33b7 100644
--- a/libc/misc/statfs/statfs64.c
+++ b/libc/misc/statfs/statfs64.c
@@ -21,9 +21,11 @@
 #include <string.h>
 #include <stddef.h>
 #include <sys/statfs.h>
+#include <sys/syscall.h>
 
 extern __typeof(statfs) __libc_statfs;
 
+#if defined __NR_statfs
 /* Return information about the filesystem on which FILE resides.  */
 int statfs64 (const char *file, struct statfs64 *buf)
 {
@@ -51,4 +53,11 @@ int statfs64 (const char *file, struct statfs64 *buf)
 
     return 0;
 }
+#else
+int statfs64 (const char *file, struct statfs64 *buf)
+{
+    return INLINE_SYSCALL(statfs64, 3, file, sizeof(*buf), buf);
+}
+#endif
+
 libc_hidden_def(statfs64)


More information about the uClibc-cvs mailing list