From 84b3bb51d7009902659e05f94c53c82d109ba8f6 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 1 Oct 2026 08:37:39 -0300 Subject: DumpDir refuses a relative directory and one that may not be written, up front, and a Dump that could not make its directory says permission denied A relative DumpDir was resolved from wherever pardes started, and one under a directory that may not be written was taken, the Dump failing later as `no such directory`. DumpDir now takes an absolute or `~` path whose nearest directory there may be written, and refuses any other with what it takes; a Dump refused by a directory above says permission denied (fs.deniedAbove), as a Save does. Co-Authored-By: Claude Opus 5.5 --- src/pardes.zig | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/pardes.zig') diff --git a/src/pardes.zig b/src/pardes.zig index 2b0ed8f0..dbb37084 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -5563,7 +5563,12 @@ pub const Pardes = struct { const parent = std.fs.path.dirname(path) orelse "/"; const kind: ?std.Io.File.Kind = if (comptime hosted) (if (filesystem.localPath(parent)) |local| exec.kindOf(local) else .directory) else .directory; const no_dir = err == error.FileNotFound or err == error.NotDir or kind != .directory; - if (kind != null and kind != .directory) { + // Not there because one above refuses: that is why, EACCES. + const denied = no_dir and kind == null and (if (comptime hosted) (if (filesystem.localPath(parent)) |local| filesystem.deniedAbove(local) else false) else false); + if (denied) { + var said: [limits.host_path_cap + 48]u8 = undefined; + p.reportFailure(p.active, std.fmt.bufPrint(&said, "{s}: permission denied", .{operation}) catch "Dump: permission denied"); + } else if (kind != null and kind != .directory) { var said: [limits.host_path_cap + 48]u8 = undefined; p.reportFailure(p.active, std.fmt.bufPrint(&said, "{s}: {s} is not a directory", .{ operation, parent }) catch "Dump: not a directory"); } else if (no_dir) { -- cgit v1.3