| 162 | } |
| 163 | |
| 164 | InputStreamPtr |
| 165 | OpenUringInputStream(const char *path, Mutex &mutex) |
| 166 | { |
| 167 | if (!uring_input_initialized) { |
| 168 | BlockingCall(*uring_input_event_loop, [](){ |
| 169 | if (uring_input_initialized) |
| 170 | return; |
| 171 | |
| 172 | uring_input_queue = uring_input_event_loop->GetUring(); |
| 173 | uring_input_initialized = true; |
| 174 | }); |
| 175 | } |
| 176 | |
| 177 | if (uring_input_queue == nullptr) |
| 178 | return nullptr; |
| 179 | |
| 180 | // TODO: use IORING_OP_OPENAT |
| 181 | auto fd = OpenReadOnly(path); |
| 182 | |
| 183 | // TODO: use IORING_OP_STATX |
| 184 | struct stat st; |
| 185 | if (fstat(fd.Get(), &st) < 0) |
| 186 | throw FmtErrno("Failed to access {}", path); |
| 187 | |
| 188 | if (!S_ISREG(st.st_mode)) |
| 189 | throw FmtRuntimeError("Not a regular file: {}", path); |
| 190 | |
| 191 | return std::make_unique<UringInputStream>(*uring_input_event_loop, |
| 192 | *uring_input_queue, |
| 193 | path, std::move(fd), |
| 194 | st.st_size, mutex); |
| 195 | } |
| 196 | |
| 197 | void |
| 198 | InitUringInputPlugin(EventLoop &event_loop) noexcept |
no test coverage detected