Implement decoding of splice, tee and vmsplice(2) syscalls

* io.c (print_loff_t): New function.
(sys_sendfile64): Use it.
(splice_flags): New xlat structure.
(sys_tee, sys_splice, sys_vmsplice): New functions.
* linux/syscall.h (sys_tee, sys_splice, sys_vmsplice): Declare them.
* linux/*/syscallent.h: Use them.
This commit is contained in:
Дмитрий Левин 2011-10-11 17:07:05 +00:00
parent c327d71258
commit d99e48c0f3
20 changed files with 148 additions and 66 deletions

95
io.c
View File

@ -361,27 +361,106 @@ sys_sendfile(struct tcb *tcp)
return 0;
}
static void
print_loff_t(struct tcb *tcp, long addr)
{
loff_t offset;
if (!addr)
tprints("NULL");
else if (umove(tcp, addr, &offset) < 0)
tprintf("%#lx", addr);
else
tprintf("[%llu]", (unsigned long long int) offset);
}
int
sys_sendfile64(struct tcb *tcp)
{
if (entering(tcp)) {
loff_t offset;
printfd(tcp, tcp->u_arg[0]);
tprints(", ");
printfd(tcp, tcp->u_arg[1]);
tprints(", ");
if (!tcp->u_arg[2])
tprints("NULL");
else if (umove(tcp, tcp->u_arg[2], &offset) < 0)
tprintf("%#lx", tcp->u_arg[2]);
else
tprintf("[%llu]", (unsigned long long int) offset);
print_loff_t(tcp, tcp->u_arg[2]);
tprintf(", %lu", tcp->u_arg[3]);
}
return 0;
}
static const struct xlat splice_flags[] = {
#ifdef SPLICE_F_MOVE
{ SPLICE_F_MOVE, "SPLICE_F_MOVE" },
#endif
#ifdef SPLICE_F_NONBLOCK
{ SPLICE_F_NONBLOCK, "SPLICE_F_NONBLOCK" },
#endif
#ifdef SPLICE_F_MORE
{ SPLICE_F_MORE, "SPLICE_F_MORE" },
#endif
#ifdef SPLICE_F_GIFT
{ SPLICE_F_GIFT, "SPLICE_F_GIFT" },
#endif
{ 0, NULL },
};
int
sys_tee(struct tcb *tcp)
{
if (entering(tcp)) {
/* int fd_in */
printfd(tcp, tcp->u_arg[0]);
tprints(", ");
/* int fd_out */
printfd(tcp, tcp->u_arg[1]);
tprints(", ");
/* size_t len */
tprintf("%lu, ", tcp->u_arg[2]);
/* unsigned int flags */
printflags(splice_flags, tcp->u_arg[3], "SPLICE_F_???");
}
return 0;
}
int
sys_splice(struct tcb *tcp)
{
if (entering(tcp)) {
/* int fd_in */
printfd(tcp, tcp->u_arg[0]);
tprints(", ");
/* loff_t *off_in */
print_loff_t(tcp, tcp->u_arg[1]);
tprints(", ");
/* int fd_out */
printfd(tcp, tcp->u_arg[2]);
tprints(", ");
/* loff_t *off_out */
print_loff_t(tcp, tcp->u_arg[3]);
tprints(", ");
/* size_t len */
tprintf("%lu, ", tcp->u_arg[4]);
/* unsigned int flags */
printflags(splice_flags, tcp->u_arg[5], "SPLICE_F_???");
}
return 0;
}
int
sys_vmsplice(struct tcb *tcp)
{
if (entering(tcp)) {
/* int fd */
printfd(tcp, tcp->u_arg[0]);
tprints(", ");
/* const struct iovec *iov, unsigned long nr_segs */
tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1], 1);
tprints(", ");
/* unsigned int flags */
printflags(splice_flags, tcp->u_arg[3], "SPLICE_F_???");
}
return 0;
}
#endif /* LINUX */
#if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T

View File

@ -496,10 +496,10 @@
{ 1, TP, sys_unshare, "unshare" }, /* 465 */
{ 2, 0, printargs, "set_robust_list" }, /* 466 */
{ 3, 0, printargs, "get_robust_list" }, /* 467 */
{ 6, TD, printargs, "splice" }, /* 468 */
{ 6, TD, sys_splice, "splice" }, /* 468 */
{ 4, TD, printargs, "sync_file_range" }, /* 469 */
{ 4, TD, printargs, "tee" }, /* 470 */
{ 4, TD, printargs, "vmsplice" }, /* 471 */
{ 4, TD, sys_tee, "tee" }, /* 470 */
{ 4, TD, sys_vmsplice, "vmsplice" }, /* 471 */
{ 6, 0, sys_move_pages, "move_pages" }, /* 472 */
{ 3, 0, sys_getcpu, "getcpu" }, /* 473 */
{ 5, TD, sys_epoll_pwait, "epoll_pwait" }, /* 474 */

View File

@ -370,10 +370,10 @@
{ 1, TP, sys_unshare, "unshare" }, /* 337 */
{ 2, 0, printargs, "set_robust_list" }, /* 338 */
{ 3, 0, printargs, "get_robust_list" }, /* 339 */
{ 6, TD, printargs, "splice" }, /* 340 */
{ 6, TD, sys_splice, "splice" }, /* 340 */
{ 5, 0, printargs, "SYS_341" }, /* 341 */
{ 4, TD, printargs, "tee" }, /* 342 */
{ 4, TD, printargs, "vmsplice" }, /* 343 */
{ 4, TD, sys_tee, "tee" }, /* 342 */
{ 4, TD, sys_vmsplice, "vmsplice" }, /* 343 */
{ 6, 0, sys_move_pages, "move_pages" }, /* 344 */
{ 3, 0, sys_getcpu, "getcpu" }, /* 345 */
{ 5, TD, sys_epoll_pwait, "epoll_pwait" }, /* 346 */

View File

@ -288,10 +288,10 @@
{ 1, TD, sys_unshare, "unshare" }, /* 258 */
{ 2, 0, printargs, "set_robust_list" }, /* 259 */
{ 3, 0, printargs, "get_robust_list" }, /* 260 */
{ 6, TD, printargs, "splice" }, /* 261 */
{ 6, TD, sys_splice, "splice" }, /* 261 */
{ 4, TD, printargs, "sync_file_range" }, /* 262 */
{ 4, TD, printargs, "tee" }, /* 263 */
{ 4, TD, printargs, "vmsplice" }, /* 264 */
{ 4, TD, sys_tee, "tee" }, /* 263 */
{ 4, TD, sys_vmsplice, "vmsplice" }, /* 264 */
{ 5, TD, sys_epoll_pwait, "epoll_pwait" }, /* 265 */
{ 4, TI, sys_msgget, "msgget" }, /* 266 */
{ 4, TI, sys_msgsnd, "msgsnd" }, /* 267 */

View File

@ -370,10 +370,10 @@
{ 4, TI, sys_shmctl, "shmctl" }, /* 339 */
{ 4, TI, sys_shmdt, "shmdt" }, /* 340 */
{ 4, TI, sys_shmget, "shmget" }, /* 341 */
{ 6, TD, printargs, "splice" }, /* 342 */
{ 6, TD, sys_splice, "splice" }, /* 342 */
{ 4, TD, printargs, "sync_file_range" }, /* 343 */
{ 4, TD, printargs, "tee" }, /* 344 */
{ 4, TD, printargs, "vmsplice" }, /* 345 */
{ 4, TD, sys_tee, "tee" }, /* 344 */
{ 4, TD, sys_vmsplice, "vmsplice" }, /* 345 */
{ 5, TD, sys_epoll_pwait, "epoll_pwait" }, /* 346 */
{ 4, TD|TF, sys_utimensat, "utimensat" }, /* 347 */
{ 3, TD|TS, sys_signalfd, "signalfd" }, /* 348 */

View File

@ -296,10 +296,10 @@
{ 1, TP, sys_unshare, "unshare" }, /* 288 */
{ 2, 0, printargs, "set_robust_list" }, /* 289 */
{ 3, 0, printargs, "get_robust_list" }, /* 290 */
{ 6, TD, printargs, "splice" }, /* 291 */
{ 6, TD, sys_splice, "splice" }, /* 291 */
{ 4, TD, printargs, "sync_file_range" }, /* 292 */
{ 4, TD, printargs, "tee" }, /* 293 */
{ 4, TD, printargs, "vmsplice" }, /* 294 */
{ 4, TD, sys_tee, "tee" }, /* 293 */
{ 4, TD, sys_vmsplice, "vmsplice" }, /* 294 */
{ 6, 0, sys_move_pages, "move_pages" }, /* 295 */
{ 3, 0, sys_getcpu, "getcpu" }, /* 296 */
{ 6, TD, sys_epoll_pwait, "epoll_pwait" }, /* 297 */

View File

@ -343,10 +343,10 @@
{ 1, TP, sys_unshare, "unshare" }, /* 310 */
{ 2, 0, printargs, "set_robust_list" }, /* 311 */
{ 3, 0, printargs, "get_robust_list" }, /* 312 */
{ 6, TD, printargs, "splice" }, /* 313 */
{ 6, TD, sys_splice, "splice" }, /* 313 */
{ 4, TD, printargs, "sync_file_range" }, /* 314 */
{ 4, TD, printargs, "tee" }, /* 315 */
{ 4, TD, printargs, "vmsplice" }, /* 316 */
{ 4, TD, sys_tee, "tee" }, /* 315 */
{ 4, TD, sys_vmsplice, "vmsplice" }, /* 316 */
{ 6, 0, sys_move_pages, "move_pages" }, /* 317 */
{ 3, 0, sys_getcpu, "getcpu" }, /* 318 */
{ 5, TD, sys_epoll_pwait, "epoll_pwait" }, /* 319 */

View File

@ -1103,10 +1103,10 @@
{ 1, TP, sys_unshare, "unshare" }, /* 1296 */
{ 2, 0, printargs, "set_robust_list" }, /* 1297 */
{ 3, 0, printargs, "get_robust_list" }, /* 1298 */
{ 6, TD, printargs, "splice" }, /* 1299 */
{ 6, TD, sys_splice, "splice" }, /* 1299 */
{ 4, TD, printargs, "sync_file_range" }, /* 1300 */
{ 4, TD, printargs, "tee" }, /* 1301 */
{ 4, TD, printargs, "vmsplice" }, /* 1302 */
{ 4, TD, sys_tee, "tee" }, /* 1301 */
{ 4, TD, sys_vmsplice, "vmsplice" }, /* 1302 */
{ MA, 0, printargs, "SYS_1303" }, /* 1303 */
{ 3, 0, sys_getcpu, "getcpu" }, /* 1304 */
{ 5, TD, sys_epoll_pwait, "epoll_pwait" }, /* 1305 */

View File

@ -334,10 +334,10 @@
{ 1, TP, sys_unshare, "unshare" }, /* 303 */
{ 2, 0, printargs, "set_robust_list" }, /* 304 */
{ 3, 0, printargs, "get_robust_list" }, /* 305 */
{ 6, TD, printargs, "splice" }, /* 306 */
{ 6, TD, sys_splice, "splice" }, /* 306 */
{ 4, TD, printargs, "sync_file_range" }, /* 307 */
{ 4, TD, printargs, "tee" }, /* 308 */
{ 4, TD, printargs, "vmsplice" }, /* 309 */
{ 4, TD, sys_tee, "tee" }, /* 308 */
{ 4, TD, sys_vmsplice, "vmsplice" }, /* 309 */
{ 6, 0, sys_move_pages, "move_pages" }, /* 310 */
{ 3, 0, sys_sched_setaffinity, "sched_setaffinity" },/* 311 */
{ 3, 0, sys_sched_getaffinity, "sched_getaffinity" },/* 312 */

View File

@ -342,10 +342,10 @@
{ 1, TP, sys_unshare, "unshare" }, /* 310 */
{ 2, 0, printargs, "set_robust_list" }, /* 311 */
{ 3, 0, printargs, "get_robust_list" }, /* 312 */
{ 6, TD, printargs, "splice" }, /* 313 */
{ 6, TD, sys_splice, "splice" }, /* 313 */
{ 4, TD, printargs, "sync_file_range"}, /* 314 */
{ 4, TD, printargs, "tee" }, /* 315 */
{ 5, TD, printargs, "vmsplice" }, /* 316 */
{ 4, TD, sys_tee, "tee" }, /* 315 */
{ 5, TD, sys_vmsplice, "vmsplice" }, /* 316 */
{ 6, 0, sys_move_pages, "move_pages" }, /* 317 */
{ 3, 0, sys_getcpu, "getcpu" }, /* 318 */
{ 5, TD, sys_epoll_pwait, "epoll_pwait" }, /* 319 */

View File

@ -4306,10 +4306,10 @@
{ 6, TD, sys_pselect6, "pselect6" }, /* 4301 */
{ 5, TD, sys_ppoll, "ppoll" }, /* 4302 */
{ 1, TP, sys_unshare, "unshare" }, /* 4303 */
{ 6, TD, printargs, "splice" }, /* 4304 */
{ 6, TD, sys_splice, "splice" }, /* 4304 */
{ 4, TD, printargs, "sync_file_range" }, /* 4305 */
{ 4, TD, printargs, "tee" }, /* 4306 */
{ 4, TD, printargs, "vmsplice" }, /* 4307 */
{ 4, TD, sys_tee, "tee" }, /* 4306 */
{ 4, TD, sys_vmsplice, "vmsplice" }, /* 4307 */
{ 6, 0, sys_move_pages, "move_pages" }, /* 4308 */
{ 2, 0, printargs, "set_robust_list" }, /* 4309 */
{ 3, 0, printargs, "get_robust_list" }, /* 4310 */
@ -5608,10 +5608,10 @@
{ 6, TD, sys_pselect6, "pselect6" }, /* 5260 */
{ 5, TD, sys_ppoll, "ppoll" }, /* 5261 */
{ 1, TP, sys_unshare, "unshare" }, /* 5262 */
{ 6, TD, printargs, "splice" }, /* 5263 */
{ 6, TD, sys_splice, "splice" }, /* 5263 */
{ 4, TD, printargs, "sync_file_range" }, /* 5264 */
{ 4, TD, printargs, "tee" }, /* 5265 */
{ 4, TD, printargs, "vmsplice" }, /* 5266 */
{ 4, TD, sys_tee, "tee" }, /* 5265 */
{ 4, TD, sys_vmsplice, "vmsplice" }, /* 5266 */
{ 6, 0, printargs, "move_pages" }, /* 5267 */
{ 2, 0, printargs, "set_robust_list" }, /* 5268 */
{ 3, 0, printargs, "get_robust_list" }, /* 5269 */
@ -6918,10 +6918,10 @@
{ 6, TD, sys_pselect6, "pselect6" }, /* 6264 */
{ 5, TD, sys_ppoll, "ppoll" }, /* 6265 */
{ 1, TP, sys_unshare, "unshare" }, /* 6266 */
{ 6, TD, printargs, "splice" }, /* 6267 */
{ 6, TD, sys_splice, "splice" }, /* 6267 */
{ 4, TD, printargs, "sync_file_range" }, /* 6268 */
{ 4, TD, printargs, "tee" }, /* 6269 */
{ 4, TD, printargs, "vmsplice" }, /* 6270 */
{ 4, TD, sys_tee, "tee" }, /* 6269 */
{ 4, TD, sys_vmsplice, "vmsplice" }, /* 6270 */
{ 6, 0, printargs, "move_pages" }, /* 6271 */
{ 2, 0, printargs, "set_robust_list" }, /* 6272 */
{ 3, 0, printargs, "get_robust_list" }, /* 6273 */

View File

@ -311,9 +311,9 @@
{ 6, TD, sys_pselect6, "pselect6" }, /* 280 */
{ 5, TD, sys_ppoll, "ppoll" }, /* 281 */
{ 1, TP, sys_unshare, "unshare" }, /* 282 */
{ 6, TD, printargs, "splice" }, /* 283 */
{ 4, TD, printargs, "tee" }, /* 284 */
{ 4, TD, printargs, "vmsplice" }, /* 285 */
{ 6, TD, sys_splice, "splice" }, /* 283 */
{ 4, TD, sys_tee, "tee" }, /* 284 */
{ 4, TD, sys_vmsplice, "vmsplice" }, /* 285 */
{ 4, TD|TF, sys_openat, "openat" }, /* 286 */
{ 3, TD|TF, sys_mkdirat, "mkdirat" }, /* 287 */
{ 4, TD|TF, sys_mknodat, "mknodat" }, /* 288 */

View File

@ -334,10 +334,10 @@
{ 1, TP, sys_unshare, "unshare" }, /* 303 */
{ 2, 0, printargs, "set_robust_list" }, /* 304 */
{ 3, 0, printargs, "get_robust_list" }, /* 305 */
{ 6, TD, printargs, "splice" }, /* 306 */
{ 6, TD, sys_splice, "splice" }, /* 306 */
{ 4, TD, printargs, "sync_file_range" }, /* 307 */
{ 4, TD, printargs, "tee" }, /* 308 */
{ 4, TD, printargs, "vmsplice" }, /* 309 */
{ 4, TD, sys_tee, "tee" }, /* 308 */
{ 4, TD, sys_vmsplice, "vmsplice" }, /* 309 */
{ 6, 0, sys_move_pages, "move_pages" }, /* 310 */
{ 3, 0, sys_getcpu, "getcpu" }, /* 311 */
{ 5, TD, sys_epoll_pwait, "epoll_pwait" }, /* 312 */

View File

@ -333,10 +333,10 @@
{ 1, TP, sys_unshare, "unshare" }, /* 303 */
{ 2, 0, printargs, "set_robust_list" }, /* 304 */
{ 3, 0, printargs, "get_robust_list" }, /* 305 */
{ 6, TD, printargs, "splice" }, /* 306 */
{ 6, TD, sys_splice, "splice" }, /* 306 */
{ 4, TD, printargs, "sync_file_range" }, /* 307 */
{ 4, TD, printargs, "tee" }, /* 308 */
{ 4, TD, printargs, "vmsplice" }, /* 309 */
{ 4, TD, sys_tee, "tee" }, /* 308 */
{ 4, TD, sys_vmsplice, "vmsplice" }, /* 309 */
{ 6, 0, sys_move_pages, "move_pages" }, /* 310 */
{ 3, 0, sys_getcpu, "getcpu" }, /* 311 */
{ 5, TD, sys_epoll_pwait, "epoll_pwait" }, /* 312 */

View File

@ -345,10 +345,10 @@
{ 1, TP, sys_unshare, "unshare" }, /* 310 */
{ 2, 0, printargs, "set_robust_list"}, /* 311 */
{ 3, 0, printargs, "get_robust_list"}, /* 312 */
{ 6, TD, printargs, "splice" }, /* 313 */
{ 6, TD, sys_splice, "splice" }, /* 313 */
{ 4, TD, printargs, "sync_file_range"}, /* 314 */
{ 4, TD, printargs, "tee" }, /* 315 */
{ 5, TD, printargs, "vmsplice" }, /* 316 */
{ 4, TD, sys_tee, "tee" }, /* 315 */
{ 5, TD, sys_vmsplice, "vmsplice" }, /* 316 */
{ 6, 0, sys_move_pages, "move_pages" }, /* 317 */
{ 3, 0, sys_getcpu, "getcpu" }, /* 318 */
{ 5, TD, sys_epoll_pwait, "epoll_pwait" }, /* 319 */

View File

@ -369,10 +369,10 @@
{ 1, TP, sys_unshare, "unshare" }, /* 338 */
{ 2, 0, printargs, "set_robust_list"}, /* 339 */
{ 3, 0, printargs, "get_robust_list"}, /* 340 */
{ 6, TD, printargs, "splice" }, /* 341 */
{ 6, TD, sys_splice, "splice" }, /* 341 */
{ 4, TD, printargs, "sync_file_range"}, /* 342 */
{ 4, TD, printargs, "tee" }, /* 343 */
{ 5, TD, printargs, "vmsplice" }, /* 344 */
{ 4, TD, sys_tee, "tee" }, /* 343 */
{ 5, TD, sys_vmsplice, "vmsplice" }, /* 344 */
{ 6, 0, sys_move_pages, "move_pages" }, /* 345 */
{ 3, 0, sys_getcpu, "getcpu" }, /* 346 */
{ 5, TD, sys_epoll_pwait, "epoll_pwait" }, /* 347 */

View File

@ -278,7 +278,7 @@
{ 2, 0, sys_mq_notify, "mq_notify" }, /* 277 */
{ 3, 0, sys_mq_getsetattr, "mq_getsetattr" }, /* 278 */
{ 5, TP, sys_waitid, "waitid" }, /* 279 */
{ 4, TD, printargs, "tee" }, /* 280 */
{ 4, TD, sys_tee, "tee" }, /* 280 */
{ 5, 0, printargs, "add_key" }, /* 281 */
{ 4, 0, printargs, "request_key" }, /* 282 */
{ 5, 0, printargs, "keyctl" }, /* 283 */

View File

@ -141,6 +141,9 @@ int sys_inotify_init1();
int sys_pselect6();
int sys_ppoll();
int sys_unshare();
int sys_tee();
int sys_splice();
int sys_vmsplice();
/* architecture-specific calls */
#ifdef ALPHA

View File

@ -283,10 +283,10 @@
{ 1, TP, sys_unshare, "unshare" }, /* 282 */
{ 2, 0, printargs, "set_robust_list" }, /* 283 */
{ 3, 0, printargs, "get_robust_list" }, /* 284 */
{ 6, TD, printargs, "splice" }, /* 285 */
{ 6, TD, sys_splice, "splice" }, /* 285 */
{ 4, TD, printargs, "sync_file_range" }, /* 286 */
{ 4, TD, printargs, "tee" }, /* 287 */
{ 4, TD, printargs, "vmsplice" }, /* 288 */
{ 4, TD, sys_tee, "tee" }, /* 287 */
{ 4, TD, sys_vmsplice, "vmsplice" }, /* 288 */
{ 6, TP, sys_move_pages, "move_pages" }, /* 289 */
{ 1, TP, printargs, "unused" }, /* 290 */
{ 1, 0, printargs, "cmpxchg_badaddr" }, /* 291 */

View File

@ -273,10 +273,10 @@
{ 1, TP, sys_unshare, "unshare" }, /* 272 */
{ 2, 0, printargs, "set_robust_list" }, /* 273 */
{ 3, 0, printargs, "get_robust_list" }, /* 274 */
{ 6, TD, printargs, "splice" }, /* 275 */
{ 4, TD, printargs, "tee" }, /* 276 */
{ 6, TD, sys_splice, "splice" }, /* 275 */
{ 4, TD, sys_tee, "tee" }, /* 276 */
{ 4, TD, printargs, "sync_file_range" }, /* 277 */
{ 4, TD, printargs, "vmsplice" }, /* 278 */
{ 4, TD, sys_vmsplice, "vmsplice" }, /* 278 */
{ 6, 0, sys_move_pages, "move_pages" }, /* 279 */
{ 4, TD|TF, sys_utimensat, "utimensat" }, /* 280 */
{ 5, TD, sys_epoll_pwait, "epoll_pwait" }, /* 281 */