summaryrefslogtreecommitdiff
path: root/libc
diff options
context:
space:
mode:
authorMarkos Chandras <markos.chandras@imgtec.com>2012-10-18 16:51:43 +0100
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2013-02-20 13:45:13 +0100
commite87a63c1d87904a24fca393a840207cf0451bab9 (patch)
treeedf596ae6946dd3c5c1b5e27a88c3f54753049f7 /libc
parent09e782b088e77eff01e9b08dd0f5dd4896e9d417 (diff)
fstatfs64: Prefer fstatfs64 system call instead of __libc_fstatfs
Using __libc_fstatfs for fstatfs64 adds a small delay as it needs to use a 32-bit data structure to get the file info and them pass them to the 64-bit data structure which was given as a fstatfs64 argument. Using the system call directly should make the entire process much faster. Also fix the arguments for fstatfs64. It takes three arguments (see fs/fstatfs.c in Linux kernel sources) so despite what the manpage says, the size of the buffer needs to be passed as the second argument Signed-off-by: Markos Chandras <markos.chandras@imgtec.com> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Diffstat (limited to 'libc')
-rw-r--r--libc/misc/statfs/fstatfs64.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/libc/misc/statfs/fstatfs64.c b/libc/misc/statfs/fstatfs64.c
index ecdfabed1..7221a0b79 100644
--- a/libc/misc/statfs/fstatfs64.c
+++ b/libc/misc/statfs/fstatfs64.c
@@ -22,8 +22,10 @@
#include <string.h>
#include <sys/statfs.h>
#include <sys/statvfs.h>
+#include <sys/syscall.h>
#include <stddef.h>
+#if defined __NR_fstatfs
extern __typeof(fstatfs) __libc_fstatfs;
/* Return information about the filesystem on which FD resides. */
@@ -42,12 +44,24 @@ int fstatfs64 (int fd, struct statfs64 *buf)
buf->f_files = buf32.f_files;
buf->f_ffree = buf32.f_ffree;
buf->f_fsid = buf32.f_fsid;
-#ifdef _STATFS_F_FRSIZE
+# ifdef _STATFS_F_FRSIZE
buf->f_frsize = buf32.f_frsize;
-#endif
+# endif
buf->f_namelen = buf32.f_namelen;
memcpy (buf->f_spare, buf32.f_spare, sizeof (buf32.f_spare));
return 0;
}
+#else
+/*
+ * Use the fstatfs64 system call if fstatfs is not defined
+ * This is for backwards compatibility and it should be
+ * made default in the future
+ */
+int fstatfs64(int fd, struct statfs64 *buf)
+{
+ /* Signature has 2 arguments but syscalls wants 3 */
+ return INLINE_SYSCALL(fstatfs64, 3, fd, sizeof(*buf), buf);
+}
+#endif
libc_hidden_def(fstatfs64)