authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-05-26 17:57:33 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-05-26 17:57:33 -07:00
log90ff1ca33f1482bb8011e97bb12a4335eabfe36a
tree5556a9b423d0342aee3e30d6fb122dc3bb97afc4
parentfe5b90180fa5a24523d286c348a8d01ba4d21469
signaturebadge-check Signed by SSH key SHA256:4hHJbtBRU58AYXwjL7fkz2fnQHdiye8x1QpTCQ0sHNw

remove sys_linux decl


2 files changed, 20 insertions(+), 36 deletions(-)

Dir.zig+1-2
......@@ -1,6 +1,5 @@
11const std = @import("std");
22const builtin = @import("builtin");
3const sys_linux = @import("sys-linux");
43
54const nfs = @import("./nfs.zig");
65const File = nfs.File;
......@@ -9,7 +8,7 @@ const Dir = @This();
98const os = builtin.target.os.tag;
109
1110const sys = switch (os) {
12 .linux => sys_linux,
11 .linux => @import("sys-linux"),
1312 else => unreachable,
1413};
1514
File.zig+19-34
......@@ -1,6 +1,5 @@
11const std = @import("std");
22const builtin = @import("builtin");
3const sys_linux = @import("sys-linux");
43const nio = @import("nio");
54const time = @import("time");
65
......@@ -11,7 +10,7 @@ const File = @This();
1110const os = builtin.target.os.tag;
1211
1312const sys = switch (os) {
14 .linux => sys_linux,
13 .linux => @import("sys-linux"),
1514 else => unreachable,
1615};
1716
......@@ -19,8 +18,7 @@ fd: nfs.Handle,
1918
2019// Resource allocation may fail; resource deallocation must succeed.
2120pub fn close(self: File) void {
22 if (os == .linux)
23 sys_linux.close(@intFromEnum(self.fd)) catch {};
21 sys.close(@intFromEnum(self.fd)) catch {};
2422}
2523
2624const R = nio.Readable(@This(), ._bare);
......@@ -38,13 +36,9 @@ pub const readAlloc = R.readAlloc;
3836pub const readInt = R.readInt;
3937pub const readUntilDelimitersAlloc = R.readUntilDelimitersAlloc;
4038
41pub const ReadError = switch (builtin.target.os.tag) {
42 .linux => sys_linux.errno.Error,
43 else => @compileError("TODO"),
44};
39pub const ReadError = sys.errno.Error;
4540pub fn read(self: File, buffer: []u8) ReadError!usize {
46 if (os == .linux)
47 return sys_linux.read(@intFromEnum(self.fd), buffer);
41 return sys.read(@intFromEnum(self.fd), buffer);
4842}
4943
5044pub fn anyReadable(self: File) nio.AnyReadable {
......@@ -62,8 +56,7 @@ pub fn anyReadable(self: File) nio.AnyReadable {
6256}
6357
6458pub fn stat(self: File) !Stat {
65 if (os != .linux) @compileError("TODO: File.stat");
66 return .fromPosix(try sys_linux.fstat(@intFromEnum(self.fd)));
59 return .fromPosix(try sys.fstat(@intFromEnum(self.fd)));
6760}
6861
6962pub fn getEndPos(self: File) !u64 {
......@@ -132,7 +125,7 @@ pub const Stat = struct {
132125 /// Last status/metadata change time in nanoseconds, relative to UTC 1970-01-01.
133126 ctime: i128,
134127
135 pub fn fromPosix(st: sys_linux.struct_stat) Stat {
128 pub fn fromPosix(st: sys.struct_stat) Stat {
136129 if (os == .linux) {
137130 if (builtin.target.cpu.arch.isMIPS64()) {
138131 return .{
......@@ -156,32 +149,24 @@ pub const Stat = struct {
156149 }
157150
158151 pub fn kind(self: Stat) Kind {
159 if (os == .linux) {
160 const m = self.mode & sys_linux.S.IFMT;
161 switch (m) {
162 sys_linux.S.IFBLK => return .block_device,
163 sys_linux.S.IFCHR => return .character_device,
164 sys_linux.S.IFIFO => return .named_pipe,
165 sys_linux.S.IFREG => return .file,
166 sys_linux.S.IFDIR => return .directory,
167 sys_linux.S.IFLNK => return .symlink,
168 sys_linux.S.IFSOCK => return .unix_socket,
169 else => {},
170 }
171 return .unknown;
152 const m = self.mode & sys.S.IFMT;
153 switch (m) {
154 sys.S.IFBLK => return .block_device,
155 sys.S.IFCHR => return .character_device,
156 sys.S.IFIFO => return .named_pipe,
157 sys.S.IFREG => return .file,
158 sys.S.IFDIR => return .directory,
159 sys.S.IFLNK => return .symlink,
160 sys.S.IFSOCK => return .unix_socket,
161 else => {},
172162 }
163 return .unknown;
173164 }
174165};
175166
176pub const INode = switch (builtin.target.os.tag) {
177 .linux => sys_linux.ino_t,
178 else => |v| @compileError("TODO: " ++ @tagName(v)),
179};
167pub const INode = sys.ino_t;
180168
181pub const Mode = switch (builtin.target.os.tag) {
182 .linux => sys_linux.mode_t,
183 else => |v| @compileError("TODO: " ++ @tagName(v)),
184};
169pub const Mode = sys.mode_t;
185170
186171pub const Kind = enum {
187172 block_device,