x32: use generic printstat/printstat64 parsers
* file.c (printstat) [X32]: Define.
(printstat64) [X32]: Use "struct stat64" instead of "struct stat".
Use printstat for x32 personality processes.
(printstat64_x32): Remove.
(sys_stat64, sys_fstat64) [X32]: Use printstat64 instead of
printstat64_x32.
diff --git a/file.c b/file.c
index f210652..cac3cb3 100644
--- a/file.c
+++ b/file.c
@@ -314,7 +314,6 @@
#include "printstat.h"
-#ifndef X32
static void
printstat(struct tcb *tcp, long addr)
{
@@ -334,12 +333,12 @@
printstatsol(tcp, addr);
return;
}
-#ifdef SPARC64
+# ifdef SPARC64
else if (current_personality == 2) {
printstat_sparc64(tcp, addr);
return;
}
-#endif
+# endif
#endif /* SPARC[64] */
#if defined POWERPC64
@@ -356,9 +355,6 @@
do_printstat(tcp, &statbuf);
}
-#else /* X32 */
-# define printstat printstat64
-#endif
#if !defined HAVE_STAT64 && (defined AARCH64 || defined X86_64 || defined X32)
/*
@@ -405,11 +401,7 @@
static void
printstat64(struct tcb *tcp, long addr)
{
-#ifdef X32
- struct stat statbuf;
-#else
struct stat64 statbuf;
-#endif
#ifdef STAT64_SIZE
(void) sizeof(char[sizeof statbuf == STAT64_SIZE ? 1 : -1]);
@@ -443,7 +435,7 @@
return;
}
#endif
-#if defined X86_64
+#if defined X86_64 || defined X32
if (current_personality != 1) {
printstat(tcp, addr);
return;
@@ -575,63 +567,6 @@
return 0;
}
-#ifdef X32
-static void
-printstat64_x32(struct tcb *tcp, long addr)
-{
- struct stat64 statbuf;
-
- if (!addr) {
- tprints("NULL");
- return;
- }
- if (syserror(tcp) || !verbose(tcp)) {
- tprintf("%#lx", addr);
- return;
- }
-
- if (umove(tcp, addr, &statbuf) < 0) {
- tprints("{...}");
- return;
- }
-
- if (!abbrev(tcp)) {
- tprintf("{st_dev=makedev(%lu, %lu), st_ino=%llu, st_mode=%s, ",
- (unsigned long) major(statbuf.st_dev),
- (unsigned long) minor(statbuf.st_dev),
- (unsigned long long) statbuf.st_ino,
- sprintmode(statbuf.st_mode));
- tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
- (unsigned long) statbuf.st_nlink,
- (unsigned long) statbuf.st_uid,
- (unsigned long) statbuf.st_gid);
- tprintf("st_blksize=%lu, ",
- (unsigned long) statbuf.st_blksize);
- tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
- }
- else
- tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
- switch (statbuf.st_mode & S_IFMT) {
- case S_IFCHR: case S_IFBLK:
- tprintf("st_rdev=makedev(%lu, %lu), ",
- (unsigned long) major(statbuf.st_rdev),
- (unsigned long) minor(statbuf.st_rdev));
- break;
- default:
- tprintf("st_size=%llu, ", (unsigned long long) statbuf.st_size);
- break;
- }
- if (!abbrev(tcp)) {
- tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
- tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
- tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime));
- tprints("}");
- }
- else
- tprints("...}");
-}
-#endif /* X32 */
-
int
sys_stat64(struct tcb *tcp)
{
@@ -640,11 +575,7 @@
printpath(tcp, tcp->u_arg[0]);
tprints(", ");
} else {
-# ifdef X32
- printstat64_x32(tcp, tcp->u_arg[1]);
-# else
printstat64(tcp, tcp->u_arg[1]);
-# endif
}
return 0;
#else
@@ -710,11 +641,7 @@
printfd(tcp, tcp->u_arg[0]);
tprints(", ");
} else {
-# ifdef X32
- printstat64_x32(tcp, tcp->u_arg[1]);
-# else
printstat64(tcp, tcp->u_arg[1]);
-# endif
}
return 0;
#else