From: Dmitry V. Levin Date: Tue, 18 Aug 2015 22:17:52 +0000 (+0000) Subject: sendfile: decode file offset both on entering and exiting syscall X-Git-Tag: v4.11~267 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=22f8b2753c2faf0650187301d40728405fa4737c;p=strace sendfile: decode file offset both on entering and exiting syscall When sendfile is called with a valid pointer to a file offset variable, kernel updates this variable on successfull exit from syscall. * sendfile.c (sys_sendfile, sys_sendfile64): Print tcp->u_arg[2] on exiting syscall as well as on entering. --- diff --git a/sendfile.c b/sendfile.c index 91c16e2a..97fd7c50 100644 --- a/sendfile.c +++ b/sendfile.c @@ -29,24 +29,45 @@ SYS_FUNC(sendfile64) { - printfd(tcp, tcp->u_arg[0]); - tprints(", "); - printfd(tcp, tcp->u_arg[1]); - tprints(", "); - printnum_int64(tcp, tcp->u_arg[2], "%" PRIu64); - tprintf(", %lu", tcp->u_arg[3]); + if (entering(tcp)) { + printfd(tcp, tcp->u_arg[0]); + tprints(", "); + printfd(tcp, tcp->u_arg[1]); + tprints(", "); + if (!printnum_int64(tcp, tcp->u_arg[2], "%" PRIu64)) { + tprintf(", %lu", tcp->u_arg[3]); + return RVAL_DECODED; + } + } else { + if (!syserror(tcp) && tcp->u_rval) { + tprints(" => "); + printnum_int64(tcp, tcp->u_arg[2], "%" PRIu64); + } + tprintf(", %lu", tcp->u_arg[3]); + } - return RVAL_DECODED; + return 0; } SYS_FUNC(sendfile) { - printfd(tcp, tcp->u_arg[0]); - tprints(", "); - printfd(tcp, tcp->u_arg[1]); - tprints(", "); - printnum_ulong(tcp, tcp->u_arg[2]); - tprintf(", %lu", tcp->u_arg[3]); + if (entering(tcp)) { + printfd(tcp, tcp->u_arg[0]); + tprints(", "); + printfd(tcp, tcp->u_arg[1]); + tprints(", "); + if (!printnum_ulong(tcp, tcp->u_arg[2]) + || !tcp->u_arg[3]) { + tprintf(", %lu", tcp->u_arg[3]); + return RVAL_DECODED; + } + } else { + if (!syserror(tcp) && tcp->u_rval) { + tprints(" => "); + printnum_ulong(tcp, tcp->u_arg[2]); + } + tprintf(", %lu", tcp->u_arg[3]); + } - return RVAL_DECODED; + return 0; }