| 41 | } |
| 42 | |
| 43 | static int get_file_size(int fd, off_t *size) |
| 44 | { |
| 45 | struct stat st; |
| 46 | |
| 47 | if (fstat(fd, &st) < 0) |
| 48 | return -1; |
| 49 | if (S_ISREG(st.st_mode)) { |
| 50 | *size = st.st_size; |
| 51 | return 0; |
| 52 | } else if (S_ISBLK(st.st_mode)) { |
| 53 | unsigned long long bytes; |
| 54 | |
| 55 | if (ioctl(fd, BLKGETSIZE64, &bytes) != 0) |
| 56 | return -1; |
| 57 | |
| 58 | *size = bytes; |
| 59 | return 0; |
| 60 | } |
| 61 | |
| 62 | return -1; |
| 63 | } |
| 64 | |
| 65 | static void queue_prepped(struct io_uring *ring, struct io_data *data) |
| 66 | { |