2 * This file is part of vmsplice strace test.
4 * Copyright (c) 2016 Dmitry V. Levin <ldv@altlinux.org>
5 * Copyright (c) 2016-2018 The strace developers.
8 * SPDX-License-Identifier: GPL-2.0-or-later
12 #include <asm/unistd.h>
14 #if defined __NR_vmsplice
28 perror_msg_and_fail("pipe");
32 static const char w0_c[] = "012";
33 const char *w0_d = hexdump_strdup(w0_c);
34 void *w0 = tail_memdup(w0_c, LENGTH_OF(w0_c));
36 static const char w1_c[] = "34567";
37 const char *w1_d = hexdump_strdup(w1_c);
38 void *w1 = tail_memdup(w1_c, LENGTH_OF(w1_c));
40 static const char w2_c[] = "89abcde";
41 const char *w2_d = hexdump_strdup(w2_c);
42 void *w2 = tail_memdup(w2_c, LENGTH_OF(w2_c));
44 const struct iovec iov_[] = {
47 .iov_len = LENGTH_OF(w0_c)
50 .iov_len = LENGTH_OF(w1_c)
53 .iov_len = LENGTH_OF(w2_c)
56 const struct iovec *iov = tail_memdup(iov_, sizeof(iov_));
57 const unsigned int len =
58 LENGTH_OF(w0_c) + LENGTH_OF(w1_c) + LENGTH_OF(w2_c);
60 tprintf("vmsplice(1, [{iov_base=\"%s\", iov_len=%u}"
61 ", {iov_base=\"%s\", iov_len=%u}"
62 ", {iov_base=\"%s\", iov_len=%u}], %u, %s) = %u\n"
63 " * %u bytes in buffer 0\n"
64 " | 00000 %-49s %-16s |\n"
65 " * %u bytes in buffer 1\n"
66 " | 00000 %-49s %-16s |\n"
67 " * %u bytes in buffer 2\n"
68 " | 00000 %-49s %-16s |\n",
69 w0_c, LENGTH_OF(w0_c), w1_c, LENGTH_OF(w1_c),
70 w2_c, LENGTH_OF(w2_c), (unsigned int) ARRAY_SIZE(iov_),
71 "SPLICE_F_NONBLOCK", len,
72 LENGTH_OF(w0_c), w0_d, w0_c,
73 LENGTH_OF(w1_c), w1_d, w1_c, LENGTH_OF(w2_c), w2_d, w2_c);
75 const long rc = syscall(__NR_vmsplice, 1, iov, ARRAY_SIZE(iov_), 2);
77 perror_msg_and_skip("vmsplice");
78 assert(rc == (int) len);
80 tprintf("+++ exited with 0 +++\n");
86 SKIP_MAIN_UNDEFINED("__NR_vmsplice")