]> granicus.if.org Git - strace/commitdiff
Implement dumping of vmsplice syscall
authorDmitry V. Levin <ldv@altlinux.org>
Sat, 13 Feb 2016 23:18:15 +0000 (23:18 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Sun, 14 Feb 2016 00:36:38 +0000 (00:36 +0000)
* 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.

NEWS
syscall.c
tests/.gitignore
tests/Makefile.am
tests/vmsplice.c [new file with mode: 0644]
tests/vmsplice.test [new file with mode: 0755]

diff --git a/NEWS b/NEWS
index c51938297ab7cc6fd7efe8c7856c148b88641267..7779f6587e0a65f98b34807a4aa543df5bad789d 100644 (file)
--- 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.
index 9729fe57813b78c0ae46b00728b7c6af453cb3ed..8e63db9a7b2eb9ae784411eb02557409a5d923d1 100644 (file)
--- 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:
index fe05d1ed1446283bc88f06a7260b79065c1d77d9..ef187d91010d7c98ccec69b4b91e80b2d25aa8e7 100644 (file)
@@ -121,6 +121,7 @@ userfaultfd
 utime
 utimensat
 vfork-f
+vmsplice
 wait
 xattr
 xet_robust_list
index 4b443fccd0fbed471c4515db8e010daaff24012c..9855c0ac8f9bcd89129d90f1bebe610e0e03304e 100644 (file)
@@ -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 (file)
index 0000000..dcf13fc
--- /dev/null
@@ -0,0 +1,106 @@
+/*
+ * This file is part of vmsplice strace test.
+ *
+ * Copyright (c) 2016 Dmitry V. Levin <ldv@altlinux.org>
+ * 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 <sys/syscall.h>
+
+#if defined __NR_vmsplice
+
+# include <assert.h>
+# include <stdio.h>
+# include <unistd.h>
+# include <sys/uio.h>
+
+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 (executable)
index 0000000..0da1976
--- /dev/null
@@ -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"