aboutsummaryrefslogtreecommitdiff
path: root/lib/std/os/linux
diff options
context:
space:
mode:
authorSeiichi Uchida <topecongiro@fastmail.com>2025-05-05 19:43:21 +0900
committerAlex Rønne Petersen <alex@alexrp.com>2025-05-06 18:01:07 +0200
commitbbc21393b407bea0f8346083bfda9425ab3ff40e (patch)
treee07bbf33984a9f6d3f01a865e99b9655d1411374 /lib/std/os/linux
parenta14352b0b24b295e1857f306de5877680dd80d2b (diff)
downloadzig-bbc21393b407bea0f8346083bfda9425ab3ff40e.tar.gz
zig-bbc21393b407bea0f8346083bfda9425ab3ff40e.zip
Add register_file_alloc_range
Diffstat (limited to 'lib/std/os/linux')
-rw-r--r--lib/std/os/linux/IoUring.zig21
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/std/os/linux/IoUring.zig b/lib/std/os/linux/IoUring.zig
index 2daf29fd05..62a87ac103 100644
--- a/lib/std/os/linux/IoUring.zig
+++ b/lib/std/os/linux/IoUring.zig
@@ -1208,6 +1208,27 @@ pub fn register_files_sparse(self: *IoUring, nr_files: u32) !void {
return handle_registration_result(res);
}
+// Registers range for fixed file allocations.
+// Available since 6.0
+pub fn register_file_alloc_range(self: *IoUring, offset: u32, len: u32) !void {
+ assert(self.fd >= 0);
+
+ const range = &linux.io_uring_file_index_range{
+ .off = offset,
+ .len = len,
+ .resv = 0,
+ };
+
+ const res = linux.io_uring_register(
+ self.fd,
+ .REGISTER_FILE_ALLOC_RANGE,
+ @ptrCast(range),
+ @as(u32, @sizeOf(linux.io_uring_file_index_range)),
+ );
+
+ return handle_registration_result(res);
+}
+
/// Registers the file descriptor for an eventfd that will be notified of completion events on
/// an io_uring instance.
/// Only a single a eventfd can be registered at any given point in time.