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 @@...@@ -1,6 +1,5 @@
1const std = @import("std");1const std = @import("std");
2const builtin = @import("builtin");2const builtin = @import("builtin");
3const sys_linux = @import("sys-linux");
43
5const nfs = @import("./nfs.zig");4const nfs = @import("./nfs.zig");
6const File = nfs.File;5const File = nfs.File;
...@@ -9,7 +8,7 @@ const Dir = @This();...@@ -9,7 +8,7 @@ const Dir = @This();
9const os = builtin.target.os.tag;8const os = builtin.target.os.tag;
109
11const sys = switch (os) {10const sys = switch (os) {
12 .linux => sys_linux,11 .linux => @import("sys-linux"),
13 else => unreachable,12 else => unreachable,
14};13};
1514
File.zig+19-34
...@@ -1,6 +1,5 @@...@@ -1,6 +1,5 @@
1const std = @import("std");1const std = @import("std");
2const builtin = @import("builtin");2const builtin = @import("builtin");
3const sys_linux = @import("sys-linux");
4const nio = @import("nio");3const nio = @import("nio");
5const time = @import("time");4const time = @import("time");
65
...@@ -11,7 +10,7 @@ const File = @This();...@@ -11,7 +10,7 @@ const File = @This();
11const os = builtin.target.os.tag;10const os = builtin.target.os.tag;
1211
13const sys = switch (os) {12const sys = switch (os) {
14 .linux => sys_linux,13 .linux => @import("sys-linux"),
15 else => unreachable,14 else => unreachable,
16};15};
1716
...@@ -19,8 +18,7 @@ fd: nfs.Handle,...@@ -19,8 +18,7 @@ fd: nfs.Handle,
1918
20// Resource allocation may fail; resource deallocation must succeed.19// Resource allocation may fail; resource deallocation must succeed.
21pub fn close(self: File) void {20pub fn close(self: File) void {
22 if (os == .linux)21 sys.close(@intFromEnum(self.fd)) catch {};
23 sys_linux.close(@intFromEnum(self.fd)) catch {};
24}22}
2523
26const R = nio.Readable(@This(), ._bare);24const R = nio.Readable(@This(), ._bare);
...@@ -38,13 +36,9 @@ pub const readAlloc = R.readAlloc;...@@ -38,13 +36,9 @@ pub const readAlloc = R.readAlloc;
38pub const readInt = R.readInt;36pub const readInt = R.readInt;
39pub const readUntilDelimitersAlloc = R.readUntilDelimitersAlloc;37pub const readUntilDelimitersAlloc = R.readUntilDelimitersAlloc;
4038
41pub const ReadError = switch (builtin.target.os.tag) {39pub const ReadError = sys.errno.Error;
42 .linux => sys_linux.errno.Error,
43 else => @compileError("TODO"),
44};
45pub fn read(self: File, buffer: []u8) ReadError!usize {40pub fn read(self: File, buffer: []u8) ReadError!usize {
46 if (os == .linux)41 return sys.read(@intFromEnum(self.fd), buffer);
47 return sys_linux.read(@intFromEnum(self.fd), buffer);
48}42}
4943
50pub fn anyReadable(self: File) nio.AnyReadable {44pub fn anyReadable(self: File) nio.AnyReadable {
...@@ -62,8 +56,7 @@ pub fn anyReadable(self: File) nio.AnyReadable {...@@ -62,8 +56,7 @@ pub fn anyReadable(self: File) nio.AnyReadable {
62}56}
6357
64pub fn stat(self: File) !Stat {58pub fn stat(self: File) !Stat {
65 if (os != .linux) @compileError("TODO: File.stat");59 return .fromPosix(try sys.fstat(@intFromEnum(self.fd)));
66 return .fromPosix(try sys_linux.fstat(@intFromEnum(self.fd)));
67}60}
6861
69pub fn getEndPos(self: File) !u64 {62pub fn getEndPos(self: File) !u64 {
...@@ -132,7 +125,7 @@ pub const Stat = struct {...@@ -132,7 +125,7 @@ pub const Stat = struct {
132 /// Last status/metadata change time in nanoseconds, relative to UTC 1970-01-01.125 /// Last status/metadata change time in nanoseconds, relative to UTC 1970-01-01.
133 ctime: i128,126 ctime: i128,
134127
135 pub fn fromPosix(st: sys_linux.struct_stat) Stat {128 pub fn fromPosix(st: sys.struct_stat) Stat {
136 if (os == .linux) {129 if (os == .linux) {
137 if (builtin.target.cpu.arch.isMIPS64()) {130 if (builtin.target.cpu.arch.isMIPS64()) {
138 return .{131 return .{
...@@ -156,32 +149,24 @@ pub const Stat = struct {...@@ -156,32 +149,24 @@ pub const Stat = struct {
156 }149 }
157150
158 pub fn kind(self: Stat) Kind {151 pub fn kind(self: Stat) Kind {
159 if (os == .linux) {152 const m = self.mode & sys.S.IFMT;
160 const m = self.mode & sys_linux.S.IFMT;153 switch (m) {
161 switch (m) {154 sys.S.IFBLK => return .block_device,
162 sys_linux.S.IFBLK => return .block_device,155 sys.S.IFCHR => return .character_device,
163 sys_linux.S.IFCHR => return .character_device,156 sys.S.IFIFO => return .named_pipe,
164 sys_linux.S.IFIFO => return .named_pipe,157 sys.S.IFREG => return .file,
165 sys_linux.S.IFREG => return .file,158 sys.S.IFDIR => return .directory,
166 sys_linux.S.IFDIR => return .directory,159 sys.S.IFLNK => return .symlink,
167 sys_linux.S.IFLNK => return .symlink,160 sys.S.IFSOCK => return .unix_socket,
168 sys_linux.S.IFSOCK => return .unix_socket,161 else => {},
169 else => {},
170 }
171 return .unknown;
172 }162 }
163 return .unknown;
173 }164 }
174};165};
175166
176pub const INode = switch (builtin.target.os.tag) {167pub const INode = sys.ino_t;
177 .linux => sys_linux.ino_t,
178 else => |v| @compileError("TODO: " ++ @tagName(v)),
179};
180168
181pub const Mode = switch (builtin.target.os.tag) {169pub const Mode = sys.mode_t;
182 .linux => sys_linux.mode_t,
183 else => |v| @compileError("TODO: " ++ @tagName(v)),
184};
185170
186pub const Kind = enum {171pub const Kind = enum {
187 block_device,172 block_device,