summaryrefslogtreecommitdiff
path: root/src/fs.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-10-30 15:57:57 -0300
committerGabriel Schneider <[email protected]>2026-10-30 16:29:54 -0300
commitf7a0b6d902f001cff0343e11263868c5356f33c6 (patch)
tree5d063c3f6a7d08a360b7bd3f7955221414101299 /src/fs.zig
parent5b120f481a5e581d5252c41a4ddcc3e28c8a07f3 (diff)
downloadpardes-f7a0b6d902f001cff0343e11263868c5356f33c6.tar.gz
pardes-f7a0b6d902f001cff0343e11263868c5356f33c6.zip
tape: an error crosses by its name, a stat as fs.OsStat, and the tape's shape is in wire.semantics: a replica of another build read its session's units as its own build's, so a window client of a terminal's session, or of the box's, read every error by a number its build gives another (451 of 505 names numbered otherwise in the Linux terminal's and window's builds, 244 between Linux and FreeBSD: pardes-gui replaying a terminal's tape panicked at `unexpected error code, found error.NonLocalPath`, and so did main's window client of a session on the box at its Look of a fifo) and a FreeBSD stat out of step (nlink 8 bytes there, 4 here); a name this build's set lacks is a divergence (error.NoSuchError), never another error; an anyerror (a host's report) reads back as one of tape.Failure's, a Debug build panicking at one outside it as it is taped; tape.shape (each taped type's fields, tags, enum names and numbers) in semantics refuses, in words, builds whose tapes differ (the stat taped as before: the Linux and FreeBSD builds hash to two), and a site whose result tape.results does not list is a compile error; walk's test of an error by its name
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/fs.zig')
-rw-r--r--src/fs.zig16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/fs.zig b/src/fs.zig
index 4bbf09bb..733418da 100644
--- a/src/fs.zig
+++ b/src/fs.zig
@@ -171,8 +171,8 @@ pub fn osHandle(p: *pardes.Pardes, req: Req) Reply {
const path = osPath(p, req.node) orelse return Reply.fail(req.tag, E.NOENT);
if (req.op == .release) return .{ .tag = req.tag };
const io = std.Io.Threaded.global_single_threaded.io();
- const stat = pardes.tape.site(.os_stat, null, statPath, .{ io, path, std.Io.Dir.StatFileOptions{} }) catch return Reply.fail(req.tag, E.NOENT);
- const attr: Reply.Attr = .{ .name = if (req.node == os_root) "os" else std.fs.path.basename(path), .node = req.node, .dir = stat.kind == .directory, .size = stat.size, .mode = if (stat.kind == .directory) 0o755 else 0o644, .mtime = std.math.cast(u32, stat.mtime.toSeconds()) orelse 0 };
+ const stat = pardes.tape.site(.os_stat, null, osStat, .{ io, path }) catch return Reply.fail(req.tag, E.NOENT);
+ const attr: Reply.Attr = .{ .name = if (req.node == os_root) "os" else std.fs.path.basename(path), .node = req.node, .dir = stat.kind == .directory, .size = stat.size, .mode = if (stat.kind == .directory) 0o755 else 0o644, .mtime = stat.mtime };
switch (req.op) {
.getattr => return .{ .tag = req.tag, .attr = attr },
.open => {
@@ -223,6 +223,16 @@ pub fn osHandle(p: *pardes.Pardes, req: Req) Reply {
}
}
+/// What /os keeps of a stat, as the tape carries it to a replica: the same
+/// bytes on every OS, which std.Io.File.Stat is not (a FreeBSD one's
+/// `nlink` and `permissions` are another width than a Linux one's).
+pub const OsStat = struct { kind: std.Io.File.Kind, size: u64, mtime: u32 };
+
+fn osStat(io: std.Io, path: []const u8) !OsStat {
+ const stat = try statPath(io, path, .{});
+ return .{ .kind = stat.kind, .size = stat.size, .mtime = std.math.cast(u32, stat.mtime.toSeconds()) orelse 0 };
+}
+
/// A directory's listing under /os, the entries from `off` until `size`
/// bytes of them are staged, into `listing`: the syscalls of a readdir.
fn osListing(io: std.Io, path: []const u8, off: u64, size: u32, listing: *[16 * 1024]u8) error{ NotDir, Io }![]const u8 {
@@ -249,7 +259,7 @@ fn osListing(io: std.Io, path: []const u8, off: u64, size: u32, listing: *[16 *
return listed.items;
}
-const OsReadWrite = union(enum) { reply: Reply, read: []const u8 };
+pub const OsReadWrite = union(enum) { reply: Reply, read: []const u8 };
/// The syscalls of an /os read, write or truncate: the reply, or the bytes
/// read into `buf`.