| 17 | #define QD 4 |
| 18 | |
| 19 | int main(int argc, char *argv[]) |
| 20 | { |
| 21 | struct io_uring ring; |
| 22 | int i, fd, ret, pending, done; |
| 23 | struct io_uring_sqe *sqe; |
| 24 | struct io_uring_cqe *cqe; |
| 25 | struct iovec *iovecs; |
| 26 | struct stat sb; |
| 27 | ssize_t fsize; |
| 28 | off_t offset; |
| 29 | void *buf; |
| 30 | |
| 31 | if (argc < 2) { |
| 32 | printf("%s: file\n", argv[0]); |
| 33 | return 1; |
| 34 | } |
| 35 | |
| 36 | ret = io_uring_queue_init(QD, &ring, 0); |
| 37 | if (ret < 0) { |
| 38 | fprintf(stderr, "queue_init: %s\n", strerror(-ret)); |
| 39 | return 1; |
| 40 | } |
| 41 | |
| 42 | ret = io_uring_register_ring_fd(&ring); |
| 43 | if (ret < 0) { |
| 44 | fprintf(stderr, "register_ring_fd: %s\n", strerror(-ret)); |
| 45 | return 1; |
| 46 | } |
| 47 | ret = io_uring_close_ring_fd(&ring); |
| 48 | if (ret < 0) { |
| 49 | fprintf(stderr, "close_ring_fd: %s\n", strerror(-ret)); |
| 50 | return 1; |
| 51 | } |
| 52 | |
| 53 | fd = open(argv[1], O_RDONLY); |
| 54 | if (fd < 0) { |
| 55 | perror("open"); |
| 56 | return 1; |
| 57 | } |
| 58 | |
| 59 | if (fstat(fd, &sb) < 0) { |
| 60 | perror("fstat"); |
| 61 | return 1; |
| 62 | } |
| 63 | |
| 64 | fsize = 0; |
| 65 | iovecs = calloc(QD, sizeof(struct iovec)); |
| 66 | for (i = 0; i < QD; i++) { |
| 67 | if (posix_memalign(&buf, 4096, 4096)) |
| 68 | return 1; |
| 69 | iovecs[i].iov_base = buf; |
| 70 | iovecs[i].iov_len = 4096; |
| 71 | fsize += 4096; |
| 72 | } |
| 73 | |
| 74 | offset = 0; |
| 75 | i = 0; |
| 76 | do { |
nothing calls this directly
no test coverage detected