| 85 | } |
| 86 | |
| 87 | static int init_splice_ctx(struct test_ctx *ctx) |
| 88 | { |
| 89 | int ret, rnd_fd; |
| 90 | |
| 91 | ctx->buf_in = t_calloc(BUF_SIZE, 1); |
| 92 | ctx->buf_out = t_calloc(BUF_SIZE, 1); |
| 93 | |
| 94 | ctx->fd_in = create_file(".splice-test-in"); |
| 95 | if (ctx->fd_in < 0) { |
| 96 | perror("file open"); |
| 97 | return 1; |
| 98 | } |
| 99 | |
| 100 | ctx->fd_out = create_file(".splice-test-out"); |
| 101 | if (ctx->fd_out < 0) { |
| 102 | perror("file open"); |
| 103 | return 1; |
| 104 | } |
| 105 | |
| 106 | /* get random data */ |
| 107 | rnd_fd = open("/dev/urandom", O_RDONLY); |
| 108 | if (rnd_fd < 0) |
| 109 | return 1; |
| 110 | |
| 111 | ret = read_buf(rnd_fd, ctx->buf_in, BUF_SIZE); |
| 112 | if (ret != 0) |
| 113 | return 1; |
| 114 | close(rnd_fd); |
| 115 | |
| 116 | /* populate file */ |
| 117 | ret = write_buf(ctx->fd_in, ctx->buf_in, BUF_SIZE); |
| 118 | if (ret) |
| 119 | return ret; |
| 120 | |
| 121 | if (pipe(ctx->pipe1) < 0) |
| 122 | return 1; |
| 123 | if (pipe(ctx->pipe2) < 0) |
| 124 | return 1; |
| 125 | |
| 126 | ctx->real_pipe1[0] = ctx->pipe1[0]; |
| 127 | ctx->real_pipe1[1] = ctx->pipe1[1]; |
| 128 | ctx->real_pipe2[0] = ctx->pipe2[0]; |
| 129 | ctx->real_pipe2[1] = ctx->pipe2[1]; |
| 130 | ctx->real_fd_in = ctx->fd_in; |
| 131 | ctx->real_fd_out = ctx->fd_out; |
| 132 | return 0; |
| 133 | } |
| 134 | |
| 135 | static int do_splice_op(struct io_uring *ring, |
| 136 | int fd_in, loff_t off_in, |
no test coverage detected