authorgravatar for topecongiro@fastmail.comSeiichi Uchida <topecongiro@fastmail.com> 2025-05-05 19:43:21+09:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-05-06 18:01:07+02:00
logbbc21393b407bea0f8346083bfda9425ab3ff40e
treee07bbf33984a9f6d3f01a865e99b9655d1411374
parenta14352b0b24b295e1857f306de5877680dd80d2b

Add register_file_alloc_range


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

lib/std/os/linux/IoUring.zig+21
......@@ -1208,6 +1208,27 @@ pub fn register_files_sparse(self: *IoUring, nr_files: u32) !void {
12081208 return handle_registration_result(res);
12091209}
12101210
1211// Registers range for fixed file allocations.
1212// Available since 6.0
1213pub fn register_file_alloc_range(self: *IoUring, offset: u32, len: u32) !void {
1214 assert(self.fd >= 0);
1215
1216 const range = &linux.io_uring_file_index_range{
1217 .off = offset,
1218 .len = len,
1219 .resv = 0,
1220 };
1221
1222 const res = linux.io_uring_register(
1223 self.fd,
1224 .REGISTER_FILE_ALLOC_RANGE,
1225 @ptrCast(range),
1226 @as(u32, @sizeOf(linux.io_uring_file_index_range)),
1227 );
1228
1229 return handle_registration_result(res);
1230}
1231
12111232/// Registers the file descriptor for an eventfd that will be notified of completion events on
12121233/// an io_uring instance.
12131234/// Only a single a eventfd can be registered at any given point in time.