]> granicus.if.org Git - strace/commitdiff
Fix printing of negative offsets in splice syscall
authorDmitry V. Levin <ldv@altlinux.org>
Sat, 13 Feb 2016 22:31:30 +0000 (22:31 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Sun, 14 Feb 2016 00:36:38 +0000 (00:36 +0000)
* io.c (SYS_FUNC(splice)): Use PRId64 instead of PRIu64 for printing
offsets.
* tests/splice.c: New file.
* tests/splice.test: New test.
* tests/.gitignore: Add splice.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(TESTS): Add splice.test.

io.c
tests/.gitignore
tests/Makefile.am
tests/splice.c [new file with mode: 0644]
tests/splice.test [new file with mode: 0755]

diff --git a/io.c b/io.c
index b98bc8a13c03bf5665b964662c0978dfef4687bf..2075d201d33b8da1fc14b07c0e32187bbbd6b545 100644 (file)
--- a/io.c
+++ b/io.c
@@ -256,13 +256,13 @@ SYS_FUNC(splice)
        printfd(tcp, tcp->u_arg[0]);
        tprints(", ");
        /* loff_t *off_in */
-       printnum_int64(tcp, tcp->u_arg[1], "%" PRIu64);
+       printnum_int64(tcp, tcp->u_arg[1], "%" PRId64);
        tprints(", ");
        /* int fd_out */
        printfd(tcp, tcp->u_arg[2]);
        tprints(", ");
        /* loff_t *off_out */
-       printnum_int64(tcp, tcp->u_arg[3], "%" PRIu64);
+       printnum_int64(tcp, tcp->u_arg[3], "%" PRId64);
        tprints(", ");
        /* size_t len */
        tprintf("%lu, ", tcp->u_arg[4]);
index ce52655af074e510628a24d446c652b4e21894bf..73b8340015b00a1efd5b411d1082004cb3963682 100644 (file)
@@ -93,6 +93,7 @@ sigaltstack
 signalfd
 sigreturn
 sleep
+splice
 stack-fcall
 stat
 stat64
index 4c7ae8f1bda5591a882d0bcac0096b96aa016692..3907637a84297778932ab3d20ffe23a0755101d4 100644 (file)
@@ -140,6 +140,7 @@ check_PROGRAMS = \
        sigaltstack \
        signalfd \
        sigreturn \
+       splice \
        stack-fcall \
        sleep \
        stat \
@@ -283,6 +284,7 @@ TESTS = \
        sigaltstack.test \
        signalfd.test \
        sigreturn.test \
+       splice.test \
        stat.test \
        stat64.test \
        statfs.test \
diff --git a/tests/splice.c b/tests/splice.c
new file mode 100644 (file)
index 0000000..ac24b2a
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * This file is part of splice 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_splice
+
+# include <assert.h>
+# include <errno.h>
+# include <stdio.h>
+# include <unistd.h>
+
+int
+main(void)
+{
+       const long int fd_in = (long int) 0xdeadbeefffffffff;
+       const long int fd_out = (long int) 0xdeadbeeffffffffe;
+       long long int *const off_in = tail_alloc(sizeof(*off_in));
+       long long int *const off_out = tail_alloc(sizeof(*off_out));
+       *off_in = 0xdeadbef1facefed1;
+       *off_out = 0xdeadbef2facefed2;
+       const size_t len = (size_t) 0xdeadbef3facefed3ULL;
+       const unsigned int flags = 15;
+
+       assert(syscall(__NR_splice, fd_in, off_in, fd_out, off_out,
+                      len, flags) == -1);
+       printf("splice(%d, [%lld], %d, [%lld], %zu, %s) = -1 %s (%m)\n",
+              (int) fd_in, *off_in, (int) fd_out, *off_out, len,
+              "SPLICE_F_MOVE|SPLICE_F_NONBLOCK|SPLICE_F_MORE|SPLICE_F_GIFT",
+              errno == ENOSYS ? "ENOSYS" : "EBADF");
+       puts("+++ exited with 0 +++");
+       return 0;
+}
+
+#else
+
+SKIP_MAIN_UNDEFINED("__NR_splice")
+
+#endif
diff --git a/tests/splice.test b/tests/splice.test
new file mode 100755 (executable)
index 0000000..e3bb093
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+# Check splice syscall decoding.
+
+. "${srcdir=.}/init.sh"
+
+run_prog > /dev/null
+OUT="$LOG.out"
+run_strace -esplice $args > "$OUT"
+match_diff "$LOG" "$OUT"
+rm -f "$OUT"