authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-02-15 16:45:23 -08:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-02-15 16:45:23 -08:00
log3ec5617e97cd6ecdbefb9f04c25ac5a77d2ab427
treef487585967d05f69bd62b793fd0ccb3db7c68d7a
parent15f2610d55de464f9448a4557c03fe191d6faeac

add root.memfd_create()


1 files changed, 14 insertions(+), 9 deletions(-)

nfs.zig+14-9
......@@ -7,27 +7,32 @@ pub const File = @import("./File.zig");
77
88const os = builtin.target.os.tag;
99
10const sys = switch (os) {
11 .linux => sys_linux,
12 else => unreachable,
13};
14
1015pub const Handle = switch (os) {
1116 .linux => enum(c_int) { _ },
12 else => @compileError("TODO"),
17 else => unreachable,
1318};
1419
1520pub fn cwd() Dir {
16 if (os == .linux)
17 return .{ .fd = @enumFromInt(sys_linux.AT.FDCWD) };
21 return .{ .fd = @enumFromInt(sys.AT.FDCWD) };
1822}
1923
2024pub fn stdin() File {
21 if (os == .linux)
22 return .{ .fd = @enumFromInt(0) };
25 return .{ .fd = @enumFromInt(0) };
2326}
2427
2528pub fn stdout() File {
26 if (os == .linux)
27 return .{ .fd = @enumFromInt(1) };
29 return .{ .fd = @enumFromInt(1) };
2830}
2931
3032pub fn stderr() File {
31 if (os == .linux)
32 return .{ .fd = @enumFromInt(2) };
33 return .{ .fd = @enumFromInt(2) };
34}
35
36pub fn memfd_create(name: [*:0]const u8, flags: c_uint) !File {
37 return .{ .fd = @enumFromInt(try sys.memfd_create(name, flags)) };
3338}