summaryrefslogtreecommitdiff
path: root/core/ninep
diff options
context:
space:
mode:
Diffstat (limited to 'core/ninep')
-rw-r--r--core/ninep/tree.zig8
1 files changed, 8 insertions, 0 deletions
diff --git a/core/ninep/tree.zig b/core/ninep/tree.zig
index 2c0ce1b0..01cfe297 100644
--- a/core/ninep/tree.zig
+++ b/core/ninep/tree.zig
@@ -57,6 +57,10 @@ pub fn failText(tag: u64, errno: u16, text: []const u8) Reply {
}
pub const e_bad_ctl = "ill-formed control message";
+/// A revision's text refused a write (cloud9's E has no EROFS; its words
+/// map back to it: enameErrno).
+pub const e_revision = "a revision is read-only";
+const rofs: u16 = 30;
pub const e_bad_event = "bad event syntax";
/// A second open reading a file whose reads consume: rio's word for it
/// (windows/rio/xfid.c:25), which 9ns turns into EBUSY.
@@ -933,6 +937,10 @@ fn open(p: *Pardes, req: Req, target: Target) Reply {
const pn = p.panes[p.paneBySerial(t.serial) orelse return Reply.fail(req.tag, E.NOENT)].?;
if (t.file.inPty() and !pn.isTerminal()) return Reply.fail(req.tag, E.NOENT);
pane_of = pn;
+ // A file at a revision is read-only (jj.zig): no open writes its
+ // text, the one road 9P has to it.
+ if (req.omode & 3 != 0 and (t.file == .body or t.file == .data or t.file == .xdata or t.file == .sel))
+ if (pn.file) |*f| if (@import("../jj.zig").of(f) != null) return failText(req.tag, rofs, e_revision);
const reader = req.omode & 3 != 1; // OWRITE is the one mode that never reads
break :what switch (t.file) {
.body => if (pn.isTerminal()) .{ .snapshot = null } else if (req.omode & 3 == 0) return .{ .tag = req.tag } else .writes,