| ... | ... | @@ -1186,6 +1186,28 @@ pub fn register_files_update(self: *IoUring, offset: u32, fds: []const posix.fd_ |
| 1186 | 1186 | try handle_registration_result(res); |
| 1187 | 1187 | } |
| 1188 | 1188 | |
| 1189 | /// Registers an empty (-1) file table of `nr_files` number of file descriptors. |
| 1190 | pub fn register_files_sparse(self: *IoUring, nr_files: u32) !void { |
| 1191 | assert(self.fd >= 0); |
| 1192 | |
| 1193 | const reg = &linux.io_uring_rsrc_register{ |
| 1194 | .nr = nr_files, |
| 1195 | .flags = linux.IORING_RSRC_REGISTER_SPARSE, |
| 1196 | .resv2 = 0, |
| 1197 | .data = 0, |
| 1198 | .tags = 0, |
| 1199 | }; |
| 1200 | |
| 1201 | const res = linux.io_uring_register( |
| 1202 | self.fd, |
| 1203 | .REGISTER_FILES2, |
| 1204 | @ptrCast(reg), |
| 1205 | @as(u32, @sizeOf(linux.io_uring_rsrc_register)), |
| 1206 | ); |
| 1207 | |
| 1208 | return handle_registration_result(res); |
| 1209 | } |
| 1210 | |
| 1189 | 1211 | /// Registers the file descriptor for an eventfd that will be notified of completion events on |
| 1190 | 1212 | /// an io_uring instance. |
| 1191 | 1213 | /// Only a single a eventfd can be registered at any given point in time. |