Skip to content

Commit bbc2139

Browse files
topecongiroalexrp
authored andcommitted
Add register_file_alloc_range
1 parent a14352b commit bbc2139

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

lib/std/os/linux/IoUring.zig

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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
1213+
pub 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.

0 commit comments

Comments
 (0)