MCPcopy Create free account
hub / github.com/axboe/liburing / do_splice_op

Function do_splice_op

test/splice.c:135–183  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

133}
134
135static int do_splice_op(struct io_uring *ring,
136 int fd_in, loff_t off_in,
137 int fd_out, loff_t off_out,
138 unsigned int len,
139 __u8 opcode)
140{
141 struct io_uring_cqe *cqe;
142 struct io_uring_sqe *sqe;
143 int ret = -1;
144
145 do {
146 sqe = io_uring_get_sqe(ring);
147 if (!sqe) {
148 fprintf(stderr, "get sqe failed\n");
149 return -1;
150 }
151 io_uring_prep_splice(sqe, fd_in, off_in, fd_out, off_out,
152 len, splice_flags);
153 sqe->flags |= sqe_flags;
154 sqe->user_data = 42;
155 sqe->opcode = opcode;
156
157 ret = io_uring_submit(ring);
158 if (ret != 1) {
159 fprintf(stderr, "sqe submit failed: %d\n", ret);
160 return ret;
161 }
162
163 ret = io_uring_wait_cqe(ring, &cqe);
164 if (ret < 0) {
165 fprintf(stderr, "wait completion %d\n", cqe->res);
166 return ret;
167 }
168
169 if (cqe->res <= 0) {
170 io_uring_cqe_seen(ring, cqe);
171 return cqe->res;
172 }
173
174 len -= cqe->res;
175 if (off_in != -1)
176 off_in += cqe->res;
177 if (off_out != -1)
178 off_out += cqe->res;
179 io_uring_cqe_seen(ring, cqe);
180 } while (len);
181
182 return 0;
183}
184
185static int do_splice(struct io_uring *ring,
186 int fd_in, loff_t off_in,

Callers 3

do_spliceFunction · 0.85
do_teeFunction · 0.85
fail_tee_offsetFunction · 0.85

Calls 3

io_uring_prep_spliceFunction · 0.85
io_uring_submitFunction · 0.85
io_uring_get_sqeFunction · 0.50

Tested by

no test coverage detected