From: Dmitry V. Levin Date: Sat, 13 Feb 2016 23:18:15 +0000 (+0000) Subject: Implement dumping of vmsplice syscall X-Git-Tag: v4.12~548 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=13870c5482fe56cb2c942668c9f583cf339e8197;p=strace Implement dumping of vmsplice syscall * syscall.c (dumpio): Add SEN_vmsplice. * NEWS: Mention this. * tests/vmsplice.c: New file. * tests/vmsplice.test: New test. * tests/.gitignore: Add vmsplice. * tests/Makefile.am (check_PROGRAMS): Likewise. (TESTS): Add vmsplice.test. --- diff --git a/NEWS b/NEWS index c5193829..7779f658 100644 --- a/NEWS +++ b/NEWS @@ -11,6 +11,7 @@ Noteworthy changes in release ?.?? (????-??-??) * Implemented caching of netlink conversations to reduce amount of time spent in decoding socket details in -yy mode. * Implemented decoding of copy_file_range syscall. + * Implemented dumping of vmsplice syscall. * Bug fixes * Fixed build on arc, metag, nios2, or1k, and tile architectures. diff --git a/syscall.c b/syscall.c index 9729fe57..8e63db9a 100644 --- a/syscall.c +++ b/syscall.c @@ -707,6 +707,7 @@ dumpio(struct tcb *tcp) dumpstr(tcp, tcp->u_arg[1], tcp->u_arg[2]); break; case SEN_writev: + case SEN_vmsplice: dumpiov(tcp, tcp->u_arg[2], tcp->u_arg[1]); break; case SEN_sendmsg: diff --git a/tests/.gitignore b/tests/.gitignore index fe05d1ed..ef187d91 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -121,6 +121,7 @@ userfaultfd utime utimensat vfork-f +vmsplice wait xattr xet_robust_list diff --git a/tests/Makefile.am b/tests/Makefile.am index 4b443fcc..9855c0ac 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -169,6 +169,7 @@ check_PROGRAMS = \ utime \ utimensat \ vfork-f \ + vmsplice \ wait \ xattr \ xet_robust_list \ @@ -312,6 +313,7 @@ TESTS = \ utime.test \ utimensat.test \ vfork-f.test \ + vmsplice.test \ wait.test \ xattr.test \ xet_robust_list.test \ diff --git a/tests/vmsplice.c b/tests/vmsplice.c new file mode 100644 index 00000000..dcf13fce --- /dev/null +++ b/tests/vmsplice.c @@ -0,0 +1,106 @@ +/* + * This file is part of vmsplice strace test. + * + * Copyright (c) 2016 Dmitry V. Levin + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "tests.h" +#include + +#if defined __NR_vmsplice + +# include +# include +# include +# include + +int +main(void) +{ + tprintf("%s", ""); + + int fds[2]; + if (pipe(fds)) + perror_msg_and_fail("pipe"); + assert(0 == fds[0]); + assert(1 == fds[1]); + + static const char w0_c[] = "012"; + const char *w0_d = hexdump_strdup(w0_c); + void *w0 = tail_memdup(w0_c, LENGTH_OF(w0_c)); + + static const char w1_c[] = "34567"; + const char *w1_d = hexdump_strdup(w1_c); + void *w1 = tail_memdup(w1_c, LENGTH_OF(w1_c)); + + static const char w2_c[] = "89abcde"; + const char *w2_d = hexdump_strdup(w2_c); + void *w2 = tail_memdup(w2_c, LENGTH_OF(w2_c)); + + const struct iovec iov_[] = { + { + .iov_base = w0, + .iov_len = LENGTH_OF(w0_c) + }, { + .iov_base = w1, + .iov_len = LENGTH_OF(w1_c) + }, { + .iov_base = w2, + .iov_len = LENGTH_OF(w2_c) + } + }; + const struct iovec *iov = tail_memdup(iov_, sizeof(iov_)); + const unsigned int len = + LENGTH_OF(w0_c) + LENGTH_OF(w1_c) + LENGTH_OF(w2_c); + + tprintf("vmsplice(1, [{\"%s\", %u}, {\"%s\", %u}" + ", {\"%s\", %u}], %u, %s) = %u\n" + " * %u bytes in buffer 0\n" + " | 00000 %-49s %-16s |\n" + " * %u bytes in buffer 1\n" + " | 00000 %-49s %-16s |\n" + " * %u bytes in buffer 2\n" + " | 00000 %-49s %-16s |\n", + w0_c, LENGTH_OF(w0_c), w1_c, LENGTH_OF(w1_c), + w2_c, LENGTH_OF(w2_c), ARRAY_SIZE(iov_), + "SPLICE_F_NONBLOCK", len, + LENGTH_OF(w0_c), w0_d, w0_c, + LENGTH_OF(w1_c), w1_d, w1_c, LENGTH_OF(w2_c), w2_d, w2_c); + + const long rc = syscall(__NR_vmsplice, 1, iov, ARRAY_SIZE(iov_), 2); + if (rc < 0) + perror_msg_and_skip("vmsplice"); + assert(rc == (int) len); + + tprintf("+++ exited with 0 +++\n"); + return 0; +} + +#else + +SKIP_MAIN_UNDEFINED("__NR_vmsplice") + +#endif diff --git a/tests/vmsplice.test b/tests/vmsplice.test new file mode 100755 index 00000000..0da19769 --- /dev/null +++ b/tests/vmsplice.test @@ -0,0 +1,11 @@ +#!/bin/sh + +# Check decoding of vmsplice syscall. + +. "${srcdir=.}/init.sh" + +run_prog > /dev/null +OUT="$LOG.out" +run_strace -ewrite=1 -evmsplice $args > "$OUT" +match_diff "$LOG" "$OUT" +rm -f "$OUT"