Do not use off_t in sendfile decoding

sendfile parser used to decode off_t* parameter as a pointer to host
off_t type.  With this change, it is decoded as a pointer to target long
type.

* io.c (print_off_t): New function.
(sys_sendfile): Use it.
* linux/aarch64/syscallent1.h: Use sys_sendfile64 for sendfile decoding.
* linux/tile/syscallent.h: Likewise.
* linux/x32/syscallent.h: Likewise.
* linux/x86_64/syscallent.h: Likewise.
* linux/hppa/syscallent.h: Use sys_sendfile64 for sendfile64 decoding.
* linux/metag/syscallent.h: Correct sendfile syscall name.
* linux/or1k/syscallent.h: Likewise.
This commit is contained in:
Дмитрий Левин 2013-03-20 09:48:44 +00:00
parent 3b211d8df0
commit 2c42f32518
8 changed files with 35 additions and 24 deletions

43
io.c
View File

@ -250,30 +250,41 @@ sys_pwritev(struct tcb *tcp)
}
#endif /* HAVE_SYS_UIO_H */
static void
print_off_t(struct tcb *tcp, long addr)
{
unsigned long offset;
if (!addr) {
tprints("NULL");
return;
}
#if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4
if (current_wordsize == 4) {
uint32_t off;
if (umove(tcp, addr, &off) < 0)
tprintf("%#lx", addr);
else
tprintf("[%u]", off);
} else
#endif
if (umove(tcp, addr, &offset) < 0)
tprintf("%#lx", addr);
else
tprintf("[%lu]", offset);
}
int
sys_sendfile(struct tcb *tcp)
{
if (entering(tcp)) {
off_t offset;
printfd(tcp, tcp->u_arg[0]);
tprints(", ");
printfd(tcp, tcp->u_arg[1]);
tprints(", ");
if (!tcp->u_arg[2])
tprints("NULL");
//FIXME: obviously bogus.
//Probably should use explicit long.
//Arches with long long offset param should use
//sys_sendfile64, not this fn.
else if (umove(tcp, tcp->u_arg[2], &offset) < 0)
tprintf("%#lx", tcp->u_arg[2]);
else
#ifdef HAVE_LONG_LONG_OFF_T
tprintf("[%llu]", offset);
#else
tprintf("[%lu]", offset);
#endif
print_off_t(tcp, tcp->u_arg[2]);
tprintf(", %lu", tcp->u_arg[3]);
}
return 0;

View File

@ -69,7 +69,7 @@
{ 5, TD, sys_pwrite, "pwrite64" }, /* 68 */
{ 5, TD, sys_preadv, "preadv" }, /* 69 */
{ 5, TD, sys_pwritev, "pwritev" }, /* 70 */
{ 4, TD|TN, sys_sendfile, "sendfile" }, /* 71 */
{ 4, TD|TN, sys_sendfile64, "sendfile" }, /* 71 */
{ 6, TD, sys_pselect6, "pselect6" }, /* 72 */
{ 5, TD, sys_ppoll, "ppoll" }, /* 73 */
{ 4, TD|TS, sys_signalfd4, "signalfd4" }, /* 74 */
@ -294,7 +294,7 @@
{ 0, TD, sys_inotify_init, "inotify_init" }, /* 1043 */
{ 1, TD, sys_eventfd, "eventfd" }, /* 1044 */
{ 3, TD|TS, sys_signalfd, "signalfd" }, /* 1045 */
{ 4, TD|TN, sys_sendfile, "sendfile" }, /* 1046 */
{ 4, TD|TN, sys_sendfile64, "sendfile" }, /* 1046 */
{ 2, TD, sys_ftruncate, "ftruncate" }, /* 1047 */
{ 2, TF, sys_truncate, "truncate" }, /* 1048 */
{ 2, TF, sys_stat, "stat" }, /* 1049 */

View File

@ -211,7 +211,7 @@
{ 0, 0, sys_gettid, "gettid" }, /* 206 */
{ 4, TD, sys_readahead, "readahead" }, /* 207 */
{ 2, TS, sys_kill, "tkill" }, /* 208 */
{ 4, TD|TN, sys_sendfile, "sendfile64" }, /* 209 */
{ 4, TD|TN, sys_sendfile64, "sendfile64" }, /* 209 */
{ 6, 0, sys_futex, "futex" }, /* 210 */
{ 3, 0, sys_sched_setaffinity, "sched_setaffinity" }, /* 211 */
{ 3, 0, sys_sched_getaffinity, "sched_getaffinity" }, /* 212 */

View File

@ -69,7 +69,7 @@
{ 5, TD, sys_pwrite, "pwrite64" }, /* 68 */
{ 5, TD, sys_preadv, "preadv" }, /* 69 */
{ 5, TD, sys_pwritev, "pwritev" }, /* 70 */
{ 4, TD|TN, sys_sendfile64, "sendfile64" }, /* 71 */
{ 4, TD|TN, sys_sendfile64, "sendfile" }, /* 71 */
{ 6, TD, sys_pselect6, "pselect6" }, /* 72 */
{ 5, TD, sys_ppoll, "ppoll" }, /* 73 */
{ 4, TD|TS, sys_signalfd4, "signalfd4" }, /* 74 */

View File

@ -69,7 +69,7 @@
{ 6, TD, sys_pwrite, "pwrite64" }, /* 68 */
{ 5, TD, sys_preadv, "preadv" }, /* 69 */
{ 5, TD, sys_pwritev, "pwritev" }, /* 70 */
{ 4, TD|TN, sys_sendfile64, "sendfile64" }, /* 71 */
{ 4, TD|TN, sys_sendfile64, "sendfile" }, /* 71 */
{ 6, TD, sys_pselect6, "pselect6" }, /* 72 */
{ 5, TD, sys_ppoll, "ppoll" }, /* 73 */
{ 4, TD|TS, sys_signalfd4, "signalfd4" }, /* 74 */

View File

@ -69,7 +69,7 @@
{ 6, TD, sys_pwrite, "pwrite64" }, /* 68 */
{ 5, TD, sys_preadv, "preadv" }, /* 69 */
{ 5, TD, sys_pwritev, "pwritev" }, /* 70 */
{ 4, TD|TN, sys_sendfile, "sendfile" }, /* 71 */
{ 4, TD|TN, sys_sendfile64, "sendfile" }, /* 71 */
{ 6, TD, sys_pselect6, "pselect6" }, /* 72 */
{ 5, TD, sys_ppoll, "ppoll" }, /* 73 */
{ 4, TD|TS, sys_signalfd4, "signalfd4" }, /* 74 */

View File

@ -38,7 +38,7 @@
{ 1, 0, sys_alarm, "alarm" }, /* 37 */
{ 3, 0, sys_setitimer, "setitimer" }, /* 38 */
{ 0, 0, sys_getpid, "getpid" }, /* 39 */
{ 4, TD|TN, sys_sendfile, "sendfile" }, /* 40 */
{ 4, TD|TN, sys_sendfile64, "sendfile" }, /* 40 */
{ 3, TN, sys_socket, "socket" }, /* 41 */
{ 3, TN, sys_connect, "connect" }, /* 42 */
{ 3, TN, sys_accept, "accept" }, /* 43 */

View File

@ -38,7 +38,7 @@
{ 1, 0, sys_alarm, "alarm" }, /* 37 */
{ 3, 0, sys_setitimer, "setitimer" }, /* 38 */
{ 0, 0, sys_getpid, "getpid" }, /* 39 */
{ 4, TD|TN, sys_sendfile, "sendfile" }, /* 40 */
{ 4, TD|TN, sys_sendfile64, "sendfile" }, /* 40 */
{ 3, TN, sys_socket, "socket" }, /* 41 */
{ 3, TN, sys_connect, "connect" }, /* 42 */
{ 3, TN, sys_accept, "accept" }, /* 43 */