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

Function test_sync_file_range

test/fsync.c:146–188  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

144#define FILE_SIZE 1024
145
146static int test_sync_file_range(struct io_uring *ring)
147{
148 int ret, fd, save_errno;
149 struct io_uring_sqe *sqe;
150 struct io_uring_cqe *cqe;
151
152 t_create_file(".sync_file_range", FILE_SIZE);
153
154 fd = open(".sync_file_range", O_RDWR);
155 save_errno = errno;
156 unlink(".sync_file_range");
157 errno = save_errno;
158 if (fd < 0) {
159 perror("file open");
160 return 1;
161 }
162
163 sqe = io_uring_get_sqe(ring);
164 if (!sqe) {
165 fprintf(stderr, "sqe get failed\n");
166 return 1;
167 }
168 io_uring_prep_sync_file_range(sqe, fd, 0, 0, 0);
169 sqe->user_data = 1;
170
171 ret = io_uring_submit(ring);
172 if (ret != 1) {
173 fprintf(stderr, "submit failed: %d\n", ret);
174 return 1;
175 }
176 ret = io_uring_wait_cqe(ring, &cqe);
177 if (ret) {
178 fprintf(stderr, "wait_cqe failed: %d\n", ret);
179 return 1;
180 }
181 if (cqe->res) {
182 fprintf(stderr, "sfr failed: %d\n", cqe->res);
183 return 1;
184 }
185
186 io_uring_cqe_seen(ring, cqe);
187 return 0;
188}
189
190int main(int argc, char *argv[])
191{

Callers 1

mainFunction · 0.85

Calls 3

t_create_fileFunction · 0.85
io_uring_submitFunction · 0.85
io_uring_get_sqeFunction · 0.50

Tested by

no test coverage detected