diff --git a/nfs.zig b/nfs.zig index f720dc5a3b66f2e9b37f11c47dcb66e9593c0a68..3c18dff389718e9075dd57bc2c0ee77881533e67 100644 --- a/nfs.zig +++ b/nfs.zig @@ -7,27 +7,32 @@ pub const File = @import("./File.zig"); const os = builtin.target.os.tag; +const sys = switch (os) { + .linux => sys_linux, + else => unreachable, +}; + pub const Handle = switch (os) { .linux => enum(c_int) { _ }, - else => @compileError("TODO"), + else => unreachable, }; pub fn cwd() Dir { - if (os == .linux) - return .{ .fd = @enumFromInt(sys_linux.AT.FDCWD) }; + return .{ .fd = @enumFromInt(sys.AT.FDCWD) }; } pub fn stdin() File { - if (os == .linux) - return .{ .fd = @enumFromInt(0) }; + return .{ .fd = @enumFromInt(0) }; } pub fn stdout() File { - if (os == .linux) - return .{ .fd = @enumFromInt(1) }; + return .{ .fd = @enumFromInt(1) }; } pub fn stderr() File { - if (os == .linux) - return .{ .fd = @enumFromInt(2) }; + return .{ .fd = @enumFromInt(2) }; +} + +pub fn memfd_create(name: [*:0]const u8, flags: c_uint) !File { + return .{ .fd = @enumFromInt(try sys.memfd_create(name, flags)) }; }