summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authorDmitry V. Levin <ldv@altlinux.org>2011-03-04 05:08:02 +0300
committerDmitry V. Levin <ldv@altlinux.org>2011-03-04 02:08:02 +0000
commit3138213bc9a827a372ad9f8009ebcc5d8797ce2d (patch)
tree9865b7e38bc49124276807f19e96ee032bbc51da /io.c
parent9cd385010ec1e0d22be70ff5163db194f1f22735 (diff)
downloadstrace-3138213bc9a827a372ad9f8009ebcc5d8797ce2d.tar.gz
strace-3138213bc9a827a372ad9f8009ebcc5d8797ce2d.tar.bz2
strace-3138213bc9a827a372ad9f8009ebcc5d8797ce2d.tar.xz
Fix decoding of file descriptors
* defs.h (printfd): New function prototype. * util.c (printfd): New function. * file.c (print_dirfd): Update prototype to use printfd(). (sys_openat, sys_faccessat, sys_newfstatat, sys_mkdirat, sys_linkat, sys_unlinkat, sys_readlinkat, sys_renameat, sys_fchownat, sys_fchmodat, sys_futimesat, sys_utimensat, sys_mknodat): Update use of print_dirfd(). (sys_lseek, sys_llseek, sys_readahead, sys_ftruncate, sys_ftruncate64, sys_fstat, sys_fstat64, sys_oldfstat, sys_fstatfs, sys_fstatfs64, sys_fchdir, sys_fchroot, sys_linkat, sys_fchown, sys_fchmod, sys_fsync, sys_readdir, sys_getdents, sys_getdirentries, sys_fsetxattr, sys_fgetxattr, sys_flistxattr, sys_fremovexattr, sys_fadvise64, sys_fadvise64_64, sys_inotify_add_watch, sys_inotify_rm_watch, sys_fallocate): Use printfd() for decoding of file descriptors. * desc.c (sys_fcntl, sys_flock, sys_close, sys_dup, do_dup2, decode_select, sys_epoll_ctl, epoll_wait_common): Use printfd() for decoding of file descriptors. * io.c (sys_read, sys_write, sys_readv, sys_writev, sys_pread, sys_pwrite, sys_sendfile, sys_sendfile64, sys_pread64, sys_pwrite64, sys_ioctl): Likewise. * mem.c (print_mmap, sys_mmap64): Likewise. * signal.c (do_signalfd): Likewise. * stream.c (decode_poll): Likewise. * time.c (sys_timerfd_settime, sys_timerfd_gettime): Likewise. Based on patch from Grant Edwards <grant.b.edwards@gmail.com>.
Diffstat (limited to 'io.c')
-rw-r--r--io.c90
1 files changed, 48 insertions, 42 deletions
diff --git a/io.c b/io.c
index 3d2970c..3f8757c 100644
--- a/io.c
+++ b/io.c
@@ -47,11 +47,11 @@
#endif
int
-sys_read(tcp)
-struct tcb *tcp;
+sys_read(struct tcb *tcp)
{
if (entering(tcp)) {
- tprintf("%ld, ", tcp->u_arg[0]);
+ printfd(tcp, tcp->u_arg[0]);
+ tprintf(", ");
} else {
if (syserror(tcp))
tprintf("%#lx", tcp->u_arg[1]);
@@ -63,11 +63,11 @@ struct tcb *tcp;
}
int
-sys_write(tcp)
-struct tcb *tcp;
+sys_write(struct tcb *tcp)
{
if (entering(tcp)) {
- tprintf("%ld, ", tcp->u_arg[0]);
+ printfd(tcp, tcp->u_arg[0]);
+ tprintf(", ");
printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
tprintf(", %lu", tcp->u_arg[2]);
}
@@ -147,11 +147,11 @@ unsigned long addr;
}
int
-sys_readv(tcp)
-struct tcb *tcp;
+sys_readv(struct tcb *tcp)
{
if (entering(tcp)) {
- tprintf("%ld, ", tcp->u_arg[0]);
+ printfd(tcp, tcp->u_arg[0]);
+ tprintf(", ");
} else {
if (syserror(tcp)) {
tprintf("%#lx, %lu",
@@ -165,11 +165,11 @@ struct tcb *tcp;
}
int
-sys_writev(tcp)
-struct tcb *tcp;
+sys_writev(struct tcb *tcp)
{
if (entering(tcp)) {
- tprintf("%ld, ", tcp->u_arg[0]);
+ printfd(tcp, tcp->u_arg[0]);
+ tprintf(", ");
tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1]);
tprintf(", %lu", tcp->u_arg[2]);
}
@@ -180,11 +180,11 @@ struct tcb *tcp;
#if defined(SVR4)
int
-sys_pread(tcp)
-struct tcb *tcp;
+sys_pread(struct tcb *tcp)
{
if (entering(tcp)) {
- tprintf("%ld, ", tcp->u_arg[0]);
+ printfd(tcp, tcp->u_arg[0]);
+ tprintf(", ");
} else {
if (syserror(tcp))
tprintf("%#lx", tcp->u_arg[1]);
@@ -202,11 +202,11 @@ struct tcb *tcp;
}
int
-sys_pwrite(tcp)
-struct tcb *tcp;
+sys_pwrite(struct tcb *tcp)
{
if (entering(tcp)) {
- tprintf("%ld, ", tcp->u_arg[0]);
+ printfd(tcp, tcp->u_arg[0]);
+ tprintf(", ");
printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
#if UNIXWARE
/* off_t is signed int */
@@ -225,11 +225,13 @@ struct tcb *tcp;
#include <sys/socket.h>
int
-sys_sendfile(tcp)
-struct tcb *tcp;
+sys_sendfile(struct tcb *tcp)
{
if (entering(tcp)) {
- tprintf("%ld, %ld, %llu, %lu", tcp->u_arg[0], tcp->u_arg[1],
+ printfd(tcp, tcp->u_arg[0]);
+ tprintf(", ");
+ printfd(tcp, tcp->u_arg[1]);
+ tprintf(", %llu, %lu",
LONG_LONG(tcp->u_arg[2], tcp->u_arg[3]),
tcp->u_arg[4]);
} else {
@@ -276,11 +278,11 @@ struct tcb *tcp;
#endif
int
-sys_pread(tcp)
-struct tcb *tcp;
+sys_pread(struct tcb *tcp)
{
if (entering(tcp)) {
- tprintf("%ld, ", tcp->u_arg[0]);
+ printfd(tcp, tcp->u_arg[0]);
+ tprintf(", ");
} else {
if (syserror(tcp))
tprintf("%#lx", tcp->u_arg[1]);
@@ -293,11 +295,11 @@ struct tcb *tcp;
}
int
-sys_pwrite(tcp)
-struct tcb *tcp;
+sys_pwrite(struct tcb *tcp)
{
if (entering(tcp)) {
- tprintf("%ld, ", tcp->u_arg[0]);
+ printfd(tcp, tcp->u_arg[0]);
+ tprintf(", ");
printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
tprintf(", %lu, ", tcp->u_arg[2]);
printllval(tcp, "%llu", PREAD_OFFSET_ARG);
@@ -306,13 +308,15 @@ struct tcb *tcp;
}
int
-sys_sendfile(tcp)
-struct tcb *tcp;
+sys_sendfile(struct tcb *tcp)
{
if (entering(tcp)) {
off_t offset;
- tprintf("%ld, %ld, ", tcp->u_arg[0], tcp->u_arg[1]);
+ printfd(tcp, tcp->u_arg[0]);
+ tprintf(", ");
+ printfd(tcp, tcp->u_arg[1]);
+ tprintf(", ");
if (!tcp->u_arg[2])
tprintf("NULL");
else if (umove(tcp, tcp->u_arg[2], &offset) < 0)
@@ -325,13 +329,15 @@ struct tcb *tcp;
}
int
-sys_sendfile64(tcp)
-struct tcb *tcp;
+sys_sendfile64(struct tcb *tcp)
{
if (entering(tcp)) {
loff_t offset;
- tprintf("%ld, %ld, ", tcp->u_arg[0], tcp->u_arg[1]);
+ printfd(tcp, tcp->u_arg[0]);
+ tprintf(", ");
+ printfd(tcp, tcp->u_arg[1]);
+ tprintf(", ");
if (!tcp->u_arg[2])
tprintf("NULL");
else if (umove(tcp, tcp->u_arg[2], &offset) < 0)
@@ -347,11 +353,11 @@ struct tcb *tcp;
#if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
int
-sys_pread64(tcp)
-struct tcb *tcp;
+sys_pread64(struct tcb *tcp)
{
if (entering(tcp)) {
- tprintf("%ld, ", tcp->u_arg[0]);
+ printfd(tcp, tcp->u_arg[0]);
+ tprintf(", ");
} else {
if (syserror(tcp))
tprintf("%#lx", tcp->u_arg[1]);
@@ -364,11 +370,11 @@ struct tcb *tcp;
}
int
-sys_pwrite64(tcp)
-struct tcb *tcp;
+sys_pwrite64(struct tcb *tcp)
{
if (entering(tcp)) {
- tprintf("%ld, ", tcp->u_arg[0]);
+ printfd(tcp, tcp->u_arg[0]);
+ tprintf(", ");
printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
tprintf(", %lu, ", tcp->u_arg[2]);
printllval(tcp, "%#llx", 3);
@@ -378,13 +384,13 @@ struct tcb *tcp;
#endif
int
-sys_ioctl(tcp)
-struct tcb *tcp;
+sys_ioctl(struct tcb *tcp)
{
const struct ioctlent *iop;
if (entering(tcp)) {
- tprintf("%ld, ", tcp->u_arg[0]);
+ printfd(tcp, tcp->u_arg[0]);
+ tprintf(", ");
iop = ioctl_lookup(tcp->u_arg[1]);
if (iop) {
tprintf("%s", iop->symbol);