Skip to content

Commit 22f8b27

Browse files
committed
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.
1 parent ac2e728 commit 22f8b27

File tree

1 file changed

+35
-14
lines changed

1 file changed

+35
-14
lines changed

sendfile.c

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,24 +29,45 @@
2929

3030
SYS_FUNC(sendfile64)
3131
{
32-
printfd(tcp, tcp->u_arg[0]);
33-
tprints(", ");
34-
printfd(tcp, tcp->u_arg[1]);
35-
tprints(", ");
36-
printnum_int64(tcp, tcp->u_arg[2], "%" PRIu64);
37-
tprintf(", %lu", tcp->u_arg[3]);
32+
if (entering(tcp)) {
33+
printfd(tcp, tcp->u_arg[0]);
34+
tprints(", ");
35+
printfd(tcp, tcp->u_arg[1]);
36+
tprints(", ");
37+
if (!printnum_int64(tcp, tcp->u_arg[2], "%" PRIu64)) {
38+
tprintf(", %lu", tcp->u_arg[3]);
39+
return RVAL_DECODED;
40+
}
41+
} else {
42+
if (!syserror(tcp) && tcp->u_rval) {
43+
tprints(" => ");
44+
printnum_int64(tcp, tcp->u_arg[2], "%" PRIu64);
45+
}
46+
tprintf(", %lu", tcp->u_arg[3]);
47+
}
3848

39-
return RVAL_DECODED;
49+
return 0;
4050
}
4151

4252
SYS_FUNC(sendfile)
4353
{
44-
printfd(tcp, tcp->u_arg[0]);
45-
tprints(", ");
46-
printfd(tcp, tcp->u_arg[1]);
47-
tprints(", ");
48-
printnum_ulong(tcp, tcp->u_arg[2]);
49-
tprintf(", %lu", tcp->u_arg[3]);
54+
if (entering(tcp)) {
55+
printfd(tcp, tcp->u_arg[0]);
56+
tprints(", ");
57+
printfd(tcp, tcp->u_arg[1]);
58+
tprints(", ");
59+
if (!printnum_ulong(tcp, tcp->u_arg[2])
60+
|| !tcp->u_arg[3]) {
61+
tprintf(", %lu", tcp->u_arg[3]);
62+
return RVAL_DECODED;
63+
}
64+
} else {
65+
if (!syserror(tcp) && tcp->u_rval) {
66+
tprints(" => ");
67+
printnum_ulong(tcp, tcp->u_arg[2]);
68+
}
69+
tprintf(", %lu", tcp->u_arg[3]);
70+
}
5071

51-
return RVAL_DECODED;
72+
return 0;
5273
}

0 commit comments

Comments
 (0)