aboutsummaryrefslogtreecommitdiff
path: root/tests/getdents64.c
diff options
context:
space:
mode:
authorDmitry V. Levin <ldv@altlinux.org>2016-04-26 22:38:10 +0000
committerDmitry V. Levin <ldv@altlinux.org>2016-04-26 22:38:10 +0000
commitf443fd40cba0c49e5d0a121df9d433225332d607 (patch)
tree1639d8d1f722991a00c03e83f60da26cbb065f34 /tests/getdents64.c
parentb83bb1cc7a748158a3d969d09262f5016bd3dee5 (diff)
downloadstrace-f443fd40cba0c49e5d0a121df9d433225332d607.tar.gz
Fix decoding of 3rd argument of getdents/getdents64 syscalls
* dirent.c (SYS_FUNC(getdents)): Always print 3rd syscall argument as unsigned int. * dirent64.c (SYS_FUNC(getdents64)): Likewise. * tests/getdents.c (main): Check it. * tests/getdents64.c (main): Likewise.
Diffstat (limited to 'tests/getdents64.c')
-rw-r--r--tests/getdents64.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/tests/getdents64.c b/tests/getdents64.c
index 7077d9c7..54149d21 100644
--- a/tests/getdents64.c
+++ b/tests/getdents64.c
@@ -101,7 +101,6 @@ int
main(int ac, const char **av)
{
char *dname;
- int rc;
assert(ac == 1);
assert(asprintf(&dname, "%s.test.tmp.dir", av[0]) > 0);
@@ -111,9 +110,16 @@ main(int ac, const char **av)
assert(!creat(fname, 0600));
assert(!close(0));
assert(!open(".", O_RDONLY | O_DIRECTORY));
- while ((rc = syscall(__NR_getdents64, 0, buf, sizeof(buf)))) {
+
+ unsigned long count = (unsigned long) 0xfacefeeddeadbeef;
+ long rc = syscall(__NR_getdents64, (long) 0xdefacedffffffff, NULL, count);
+ printf("getdents64(-1, NULL, %u) = %ld %s (%m)\n",
+ (unsigned) count, rc, errno2name());
+
+ count = (unsigned long) 0xfacefeed00000000 | sizeof(buf);
+ while ((rc = syscall(__NR_getdents64, 0, buf, count))) {
kernel_dirent64 *d;
- int i;
+ long i;
if (rc < 0)
perror_msg_and_skip("getdents64");
@@ -124,9 +130,9 @@ main(int ac, const char **av)
printf(", ");
print_dirent(d);
}
- printf("], %zu) = %d\n", sizeof(buf), rc);
+ printf("], %u) = %ld\n", (unsigned) count, rc);
}
- printf("getdents64(0, [], %zu) = 0\n", sizeof(buf));
+ printf("getdents64(0, [], %u) = 0\n", (unsigned) count);
puts("+++ exited with 0 +++");
assert(!unlink(fname));
assert(!chdir(".."));