[PATCH] Add support for compat_statfs64

Andreas Schwab schwab at linux-m68k.org
Tue Jan 17 22:58:02 UTC 2012


* file.c (struct compat_statfs64, printcompat_statfs64): Define.
(sys_statfs64, sys_fstatfs64): Use it.
---
 file.c |   52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 52 insertions(+), 0 deletions(-)

diff --git a/file.c b/file.c
index 473e6fd..343f64a 100644
--- a/file.c
+++ b/file.c
@@ -1794,6 +1794,54 @@ printstatfs64(struct tcb *tcp, long addr)
 	tprints("}");
 }
 
+struct compat_statfs64 {
+	uint32_t f_type;
+	uint32_t f_bsize;
+	uint64_t f_blocks;
+	uint64_t f_bfree;
+	uint64_t f_bavail;
+	uint64_t f_files;
+	uint64_t f_ffree;
+	fsid_t f_fsid;
+	uint32_t f_namelen;
+	uint32_t f_frsize;
+	uint32_t f_flags;
+	uint32_t f_spare[4];
+}
+#if defined(X86_64) || defined(IA64)
+  __attribute__ ((packed, aligned(4)))
+#endif
+;
+
+static void
+printcompat_statfs64(struct tcb *tcp, long addr)
+{
+	struct compat_statfs64 statbuf;
+
+	if (syserror(tcp) || !verbose(tcp)) {
+		tprintf("%#lx", addr);
+		return;
+	}
+	if (umove(tcp, addr, &statbuf) < 0) {
+		tprints("{...}");
+		return;
+	}
+	tprintf("{f_type=%s, f_bsize=%lu, f_blocks=%llu, f_bfree=%llu, ",
+		sprintfstype(statbuf.f_type),
+		(unsigned long)statbuf.f_bsize,
+		(unsigned long long)statbuf.f_blocks,
+		(unsigned long long)statbuf.f_bfree);
+	tprintf("f_bavail=%llu, f_files=%llu, f_ffree=%llu, f_fsid={%d, %d}",
+		(unsigned long long)statbuf.f_bavail,
+		(unsigned long long)statbuf.f_files,
+		(unsigned long long)statbuf.f_ffree,
+		statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1]);
+	tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen);
+	tprintf(", f_frsize=%lu", (unsigned long)statbuf.f_frsize);
+	tprintf(", f_flags=%lu", (unsigned long)statbuf.f_frsize);
+	tprints("}");
+}
+
 int
 sys_statfs64(struct tcb *tcp)
 {
@@ -1803,6 +1851,8 @@ sys_statfs64(struct tcb *tcp)
 	} else {
 		if (tcp->u_arg[1] == sizeof(struct statfs64))
 			printstatfs64(tcp, tcp->u_arg[2]);
+		else if (tcp->u_arg[1] == sizeof(struct compat_statfs64))
+			printcompat_statfs64(tcp, tcp->u_arg[2]);
 		else
 			tprints("{???}");
 	}
@@ -1818,6 +1868,8 @@ sys_fstatfs64(struct tcb *tcp)
 	} else {
 		if (tcp->u_arg[1] == sizeof(struct statfs64))
 			printstatfs64(tcp, tcp->u_arg[2]);
+		else if (tcp->u_arg[1] == sizeof(struct compat_statfs64))
+			printcompat_statfs64(tcp, tcp->u_arg[2]);
 		else
 			tprints("{???}");
 	}
-- 
1.7.8.3


-- 
Andreas Schwab, schwab at linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."




More information about the Strace-devel mailing list