x32: fix struct dirent decoding
* kernel_types.h: New file.
* Makefile.am (strace_SOURCES): Add it.
* configure.ac (AC_CHECK_TYPES): Check for __kernel_long_t
and __kernel_ulong_t in <asm/posix_types.h>.
* dirent.c: Stop including <dirent.h>.
(kernel_dirent): Remove.
Include "kernel_types.h".
(print_old_dirent, SYS_FUNC(getdents)): Print variables
of kernel_ulong_t type using %Lu format.
* syscall.c (kernel_long_t, kernel_ulong_t): Remove.
Include "kernel_types.h".
* tests/getdents.c (kernel_dirent): Remove.
Include "kernel_types.h".
(print_dirent): Print variables of kernel_ulong_t type using %Lu format.
diff --git a/dirent.c b/dirent.c
index cd50968..bad9bcd 100644
--- a/dirent.c
+++ b/dirent.c
@@ -33,14 +33,7 @@
#include DEF_MPERS_TYPE(kernel_dirent)
-#include <dirent.h>
-
-typedef struct {
- unsigned long d_ino;
- unsigned long d_off;
- unsigned short d_reclen;
- char d_name[1];
-} kernel_dirent;
+#include "kernel_types.h"
#include MPERS_DEFS
@@ -54,8 +47,9 @@
if (umove_or_printaddr(tcp, addr, &d))
return;
- tprintf("{d_ino=%lu, d_off=%lu, d_reclen=%u, d_name=",
- (unsigned long) d.d_ino, (unsigned long) d.d_off, d.d_reclen);
+ tprintf("{d_ino=%Lu, d_off=%Lu, d_reclen=%u, d_name=",
+ (unsigned long long) d.d_ino,
+ (unsigned long long) d.d_off, d.d_reclen);
if (d.d_reclen > D_NAME_LEN_MAX)
d.d_reclen = D_NAME_LEN_MAX;
printpathn(tcp, addr + offsetof(kernel_dirent, d_name), d.d_reclen);
@@ -128,9 +122,10 @@
if (d_name_len > D_NAME_LEN_MAX)
d_name_len = D_NAME_LEN_MAX;
- tprintf("%s{d_ino=%lu, d_off=%lu, d_reclen=%u, d_name=",
- i ? ", " : "", (unsigned long) d->d_ino,
- (unsigned long) d->d_off, d->d_reclen);
+ tprintf("%s{d_ino=%Lu, d_off=%Lu, d_reclen=%u"
+ ", d_name=", i ? ", " : "",
+ (unsigned long long) d->d_ino,
+ (unsigned long long) d->d_off, d->d_reclen);
if (print_quoted_string(d->d_name, d_name_len,
QUOTE_0_TERMINATED) > 0) {
@@ -146,7 +141,7 @@
}
dents++;
if (d->d_reclen < sizeof(kernel_dirent)) {
- tprints("/* d_reclen < sizeof(kernel_dirent) */");
+ tprints("/* d_reclen < sizeof(struct dirent) */");
break;
}
i += d->d_reclen;