authorgravatar for halildrk@gmail.comnikneym <halildrk@gmail.com> 2025-02-11 13:19:05+03:00
committergravatar for halildrk@gmail.comnikneym <halildrk@gmail.com> 2025-02-11 13:19:05+03:00
log408c817e1e9b4f68f2d0c6b4cc1c6673c591bb2f
treebd36176a765d031ac907b1163f15db8de05b1b74
parent6f6b85e29827ad269ab397a3db14e9574204cb2d

linux/IoUring: add register_files_sparse


1 files changed, 22 insertions(+), 0 deletions(-)

lib/std/os/linux/IoUring.zig+22
......@@ -1186,6 +1186,28 @@ pub fn register_files_update(self: *IoUring, offset: u32, fds: []const posix.fd_
11861186 try handle_registration_result(res);
11871187}
11881188
1189/// Registers an empty (-1) file table of `nr_files` number of file descriptors.
1190pub 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
11891211/// Registers the file descriptor for an eventfd that will be notified of completion events on
11901212/// an io_uring instance.
11911213/// Only a single a eventfd can be registered at any given point in time.