feature. See also
. The project being documented here (as the example) is the Zig library itself.
Uring.openat
fn openat(
ev: *Evented,
cancel_region: *CancelRegion,
dir: fd_t,
path: [*:0]const u8,
flags: linux.O,
mode: linux.mode_t,
) !fd_t
File
Code
fn openat(
ev: *Evented,
cancel_region: *CancelRegion,
dir: fd_t,
path: [*:0]const u8,
flags: linux.O,
mode: linux.mode_t,
) !fd_t {
var mut_flags = flags;
if (@hasField(linux.O, "LARGEFILE")) mut_flags.LARGEFILE = true;
while (true) {
const thread = try cancel_region.awaitIoUring();
thread.enqueue().* = .{
.opcode = .OPENAT,
.flags = 0,
.ioprio = 0,
.fd = dir,
.off = 0,
.addr = @intFromPtr(path),
.len = mode,
.rw_flags = @bitCast(mut_flags),
.user_data = @intFromPtr(cancel_region.fiber),
.buf_index = 0,
.personality = 0,
.splice_fd_in = 0,
.addr3 = 0,
.resv = 0,
};
ev.yield(null, .nothing);
const completion = cancel_region.completion();
switch (completion.errno()) {
.SUCCESS => return completion.result,
.INTR, .CANCELED => {},
.FAULT => |err| return errnoBug(err),
.INVAL => return error.BadPathName,
.BADF => |err| return errnoBug(err),
.ACCES => return error.AccessDenied,
.FBIG => return error.FileTooBig,
.OVERFLOW => return error.FileTooBig,
.ISDIR => return error.IsDir,
.LOOP => return error.SymLinkLoop,
.MFILE => return error.ProcessFdQuotaExceeded,
.NAMETOOLONG => return error.NameTooLong,
.NFILE => return error.SystemFdQuotaExceeded,
.NODEV => return error.NoDevice,
.NOENT => return error.FileNotFound,
.SRCH => return error.FileNotFound,
.NOMEM => return error.SystemResources,
.NOSPC => return error.NoSpaceLeft,
.NOTDIR => return error.NotDir,
.PERM => return error.PermissionDenied,
.EXIST => return error.PathAlreadyExists,
.BUSY => return error.DeviceBusy,
// flags are mutually exclusive.
.OPNOTSUPP => return error.OperationUnsupported,
.AGAIN => return error.WouldBlock,
.TXTBSY => return error.FileBusy,
.NXIO => return error.NoDevice,
.ROFS => return error.ReadOnlyFileSystem,
.ILSEQ => return error.BadPathName,
else => |err| return unexpectedErrno(err),
}
}
}