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");...@@ -7,27 +7,32 @@ pub const File = @import("./File.zig");
77
8const os = builtin.target.os.tag;8const os = builtin.target.os.tag;
99
10const sys = switch (os) {
11 .linux => sys_linux,
12 else => unreachable,
13};
14
10pub const Handle = switch (os) {15pub const Handle = switch (os) {
11 .linux => enum(c_int) { _ },16 .linux => enum(c_int) { _ },
12 else => @compileError("TODO"),17 else => unreachable,
13};18};
1419
15pub fn cwd() Dir {20pub fn cwd() Dir {
16 if (os == .linux)21 return .{ .fd = @enumFromInt(sys.AT.FDCWD) };
17 return .{ .fd = @enumFromInt(sys_linux.AT.FDCWD) };
18}22}
1923
20pub fn stdin() File {24pub fn stdin() File {
21 if (os == .linux)25 return .{ .fd = @enumFromInt(0) };
22 return .{ .fd = @enumFromInt(0) };
23}26}
2427
25pub fn stdout() File {28pub fn stdout() File {
26 if (os == .linux)29 return .{ .fd = @enumFromInt(1) };
27 return .{ .fd = @enumFromInt(1) };
28}30}
2931
30pub fn stderr() File {32pub fn stderr() File {
31 if (os == .linux)33 return .{ .fd = @enumFromInt(2) };
32 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)) };
33}38}