diff options
author | Dmitry V. Levin <ldv@altlinux.org> | 2020-04-11 18:09:11 +0000 |
---|---|---|
committer | Dmitry V. Levin <ldv@altlinux.org> | 2020-04-11 18:09:11 +0000 |
commit | 1740c1cca0039c3338cde8f9b42ed0711ddb00b3 (patch) | |
tree | c750062c5c322672c3623a92b0be2bd31a3e7370 | |
parent | b482f026fb59cf24078e85a31e43688b545ab259 (diff) | |
download | strace-1740c1cca0039c3338cde8f9b42ed0711ddb00b3.tar.gz |
Print the second argument of getdents/getdents64 syscalls in abbrev mode
* dirent.c (SYS_FUNC(getdents)) [!abbrev(tcp)]: Print u_arg[1] along
with the number of entries.
* dirent64.c (SYS_FUNC(getdents64)) [!abbrev(tcp)]: Likewise.
* tests/xgetdents.c (ls): Update expected output.
-rw-r--r-- | dirent.c | 20 | ||||
-rw-r--r-- | dirent64.c | 20 | ||||
-rw-r--r-- | tests/xgetdents.c | 9 |
3 files changed, 28 insertions, 21 deletions
@@ -63,10 +63,11 @@ SYS_FUNC(getdents) return 0; } + tprints(", "); + const unsigned int count = tcp->u_arg[2]; if (syserror(tcp) || !verbose(tcp)) { - tprints(", "); printaddr(tcp->u_arg[1]); tprintf(", %u", count); return 0; @@ -83,7 +84,6 @@ SYS_FUNC(getdents) if (len) { buf = malloc(len); if (!buf || umoven(tcp, tcp->u_arg[1], len, buf) < 0) { - tprints(", "); printaddr(tcp->u_arg[1]); tprintf(", %u", count); free(buf); @@ -93,9 +93,11 @@ SYS_FUNC(getdents) buf = NULL; } - tprints(","); - if (!abbrev(tcp)) - tprints(" ["); + if (abbrev(tcp)) + printaddr(tcp->u_arg[1]); + else + tprints("["); + for (i = 0; len && i <= len - sizeof(kernel_dirent_t); ) { kernel_dirent_t *d = (kernel_dirent_t *) &buf[i]; @@ -129,10 +131,12 @@ SYS_FUNC(getdents) } i += d->d_reclen; } - if (!abbrev(tcp)) - tprints("]"); - else + + if (abbrev(tcp)) tprintf_comment("%u entries", dents); + else + tprints("]"); + tprintf(", %u", count); free(buf); return 0; diff --git a/dirent64.c b/dirent64.c index f7d68daa4..cffa9a81a 100644 --- a/dirent64.c +++ b/dirent64.c @@ -30,10 +30,11 @@ SYS_FUNC(getdents64) return 0; } + tprints(", "); + const unsigned int count = tcp->u_arg[2]; if (syserror(tcp) || !verbose(tcp)) { - tprints(", "); printaddr(tcp->u_arg[1]); tprintf(", %u", count); return 0; @@ -50,7 +51,6 @@ SYS_FUNC(getdents64) if (len) { buf = malloc(len); if (!buf || umoven(tcp, tcp->u_arg[1], len, buf) < 0) { - tprints(", "); printaddr(tcp->u_arg[1]); tprintf(", %u", count); free(buf); @@ -60,9 +60,11 @@ SYS_FUNC(getdents64) buf = NULL; } - tprints(","); - if (!abbrev(tcp)) - tprints(" ["); + if (abbrev(tcp)) + printaddr(tcp->u_arg[1]); + else + tprints("["); + for (i = 0; len && i <= len - d_name_offset; ) { struct dirent64 *d = (struct dirent64 *) &buf[i]; if (!abbrev(tcp)) { @@ -96,10 +98,12 @@ SYS_FUNC(getdents64) i += d->d_reclen; dents++; } - if (!abbrev(tcp)) - tprints("]"); - else + + if (abbrev(tcp)) tprintf_comment("%u entries", dents); + else + tprints("]"); + tprintf(", %u", count); free(buf); return 0; diff --git a/tests/xgetdents.c b/tests/xgetdents.c index 772c0c333..c550625ef 100644 --- a/tests/xgetdents.c +++ b/tests/xgetdents.c @@ -77,17 +77,16 @@ ls(int fd, char *buf, unsigned int size) #if VERBOSE printf("]"); #else - printf("/* %lu entries */", entries); + printf("%p /* %lu entries */", buf, entries); #endif printf(", %u) = %ld\n", size, rc); } - printf("%s(%d, %s, %u) = 0\n", STR_getdents, fd, #if VERBOSE - "[]", + printf("%s(%d, [], %u) = 0\n", STR_getdents, fd, size); #else - "/* 0 entries */", + printf("%s(%d, %p /* 0 entries */, %u) = 0\n", + STR_getdents, fd, buf, size); #endif - size); } int |