summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-29 09:15:41 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:16 -0300
commit49d5bf5ebfe4a84070b7eac1e9d8ac52e1cc45fd (patch)
treea1303e7c3eb8a6a2687a90cb973e16412f45471d
parent36241daca2aaf90cc8933dffd95fc3cd6216e2b7 (diff)
downloadpardes-49d5bf5ebfe4a84070b7eac1e9d8ac52e1cc45fd.tar.gz
pardes-49d5bf5ebfe4a84070b7eac1e9d8ac52e1cc45fd.zip
A Save into a directory that is not there says no such directory, ENOENT
It failed EIO with `file not found`, which named no file that was missing. It says `Save <path>: no such directory`, and a late failure saying `no such` answers ENOENT, as a builtin's does. Co-Authored-By: Claude Opus 5.5 <[email protected]>
-rw-r--r--src/9p_io.zig6
-rw-r--r--src/pardes.zig12
-rw-r--r--test/fs.py2
3 files changed, 16 insertions, 4 deletions
diff --git a/src/9p_io.zig b/src/9p_io.zig
index 2130db27..4c9c9bcf 100644
--- a/src/9p_io.zig
+++ b/src/9p_io.zig
@@ -315,7 +315,11 @@ pub const Listener = struct {
// ponytail: one slot, so a failure of another client's effects that
// settle in the same wait is told to this write too.
if (l.core == core and core.fs.late_failure_len != 0) {
- const failed = pardes.ctlfs.failText(req.tag, pardes.ctlfs.E.IO, core.fs.late_failure[0..core.fs.late_failure_len]);
+ const late = core.fs.late_failure[0..core.fs.late_failure_len];
+ // What is not there (`no such directory`) is ENOENT, as a
+ // builtin's failure saying so is (ctl.failureErrno).
+ const errno = if (std.mem.indexOf(u8, late, "no such") != null) pardes.ctlfs.E.NOENT else pardes.ctlfs.E.IO;
+ const failed = pardes.ctlfs.failText(req.tag, errno, late);
// Its err record says it (the path in it); the msg the failure
// was also said as goes, as a builtin's failing a write does.
pardes.ctlfs.events.dropMessage(core, core.fs.late_failure[0..core.fs.late_failure_len]);
diff --git a/src/pardes.zig b/src/pardes.zig
index 1afb1e24..27cbf383 100644
--- a/src/pardes.zig
+++ b/src/pardes.zig
@@ -5271,8 +5271,16 @@ pub const Pardes = struct {
// The `-%` spelling fs.zig already uses for "make this dirty".
f.saved_revision = f.revision -% 1;
};
- var what: [limits.host_path_cap + 8]u8 = undefined;
- p.reportError(id, std.fmt.bufPrint(&what, "Save {s}", .{path}) catch "Save", err);
+ var what: [limits.host_path_cap + 32]u8 = undefined;
+ // A write into a directory that is not there: said so, in the words
+ // a mount reads as ENOENT.
+ const parent = std.fs.path.dirname(path) orelse "/";
+ const no_dir = err == error.FileNotFound or err == error.NotDir or
+ (if (comptime hosted) (if (filesystem.localPath(parent)) |local| !exec.isDirectory(local) else false) else false);
+ if (no_dir)
+ p.reportFailure(id, std.fmt.bufPrint(&what, "Save {s}: no such directory", .{path}) catch "Save: no such directory")
+ else
+ p.reportError(id, std.fmt.bufPrint(&what, "Save {s}", .{path}) catch "Save", err);
const said = if (p.panes[id]) |pane| pane.msg[0..pane.msg_len] else "Save failed";
const kept = @import("Messages.zig").clip(said, p.fs.late_failure.len);
@memcpy(p.fs.late_failure[0..kept.len], kept);
diff --git a/test/fs.py b/test/fs.py
index d2cd631c..f759d185 100644
--- a/test/fs.py
+++ b/test/fs.py
@@ -387,7 +387,7 @@ def discovery(binary, embedded=False):
client.write(f'/pane/{unsaved}/ctl', b'Save /nonexistent-pardes-dir/x.txt\n')
raise AssertionError('a Save into a missing directory succeeded')
except OSError as refused:
- assert 'Save /nonexistent-pardes-dir/x.txt: ' in str(refused), refused
+ assert 'Save /nonexistent-pardes-dir/x.txt: no such directory' in str(refused), refused
assert f'err {unsaved} ctl: Save /nonexistent-pardes-dir/x.txt: '.encode() in client.read('/log'), client.read('/log')
client.remove(f'/pane/{unsaved}')