//! The editor's 9P surface. The wire protocol, the client, the transports //! and the file-server engine (`cloud9.fs.Server`) live in cloud9; this //! module names the two engine configurations Pardes builds, the editor's //! and the board's, and re-exports what the transports and firmware use. const cloud9 = @import("cloud9"); pub const fs = cloud9.fs; pub const Server = cloud9.fs.Server; pub const Error = cloud9.Error; pub const Type = cloud9.Type; pub const isT = cloud9.isT; pub const header_len = cloud9.header_len; pub const qid_len = cloud9.qid_len; pub const stat_fixed = cloud9.stat_fixed; pub const notag = cloud9.notag; pub const nofid = cloud9.nofid; pub const max_welem = cloud9.max_welem; pub const iohdrsz = cloud9.iohdrsz; pub const Qid = cloud9.Qid; pub const Stat = cloud9.Stat; pub const Msg = cloud9.Msg; pub const Decoded = cloud9.Decoded; pub const frameLen = cloud9.frameLen; pub const encode = cloud9.encode; pub const decode = cloud9.decode; pub const qtdir = cloud9.qtdir; pub const qtappend = cloud9.qtappend; pub const qtexcl = cloud9.qtexcl; pub const qtmount = cloud9.qtmount; pub const qtauth = cloud9.qtauth; pub const qttmp = cloud9.qttmp; pub const qtfile = cloud9.qtfile; pub const dmdir = cloud9.dmdir; pub const dmappend = cloud9.dmappend; pub const dmexcl = cloud9.dmexcl; pub const dmmount = cloud9.dmmount; pub const dmauth = cloud9.dmauth; pub const dmtmp = cloud9.dmtmp; pub const dmperm = cloud9.dmperm; pub const Client = cloud9.Client; pub const ClientError = cloud9.ClientError; pub const max_tags = cloud9.max_tags; pub const oread = cloud9.oread; pub const owrite = cloud9.owrite; pub const ordwr = cloud9.ordwr; pub const oexec = cloud9.oexec; pub const otrunc = cloud9.otrunc; pub const ocexec = cloud9.ocexec; pub const orclose = cloud9.orclose; pub const errmax = cloud9.fs.errmax; pub const errString = cloud9.fs.errString; pub const msize_min = cloud9.fs.msize_min; /// The smallest msize a native listener offers (src/9p_io.zig). pub const min_msize: u32 = 4096; /// What a native listener negotiates. pub const msize: u32 = 65536; /// The editor's engine: native fid count, native file names, and room to /// park a write of any size a frame can carry -- a request that would change /// a pane while the editor is out in a syscall waits in the engine /// (src/9p_io.zig, `serve`), and a write it cannot keep would fail instead. /// The largest write is msize less the Twrite header, 23 bytes (the test /// below asks a client), one byte more than `iohdrsz` allows for. /// Up to 128 reads held on one connection (a follower each of the log or /// an event file); the next is refused `too many reads waiting: 128`. A /// mount (9ns) keeps a wider window, 256, so held reads never take every /// one of its workers. pub const editor: cloud9.fs.Options = .{ .fid_capacity = max_fids, .name_capacity = 255, .park_data_max = msize - 23, .slot_capacity = max_held }; pub const max_held: usize = 128; /// The board's engine: the GPIO firmware's budget (src/esp32p4_9p.zig). pub const board: cloud9.fs.Options = .{ .fid_capacity = board_fids, .name_capacity = board_name_capacity }; pub const max_fids: usize = 256; pub const board_fids: usize = 32; pub const board_name_capacity: usize = 28; const std = @import("std"); const testing = std.testing; const Stub = struct { pub const Req = cloud9.fs.Req; pub const Reply = cloud9.fs.Reply; }; test "9p server: the editor's engine can park the largest write a client sends" { var in: [4096]u8 = undefined; var out: [4096]u8 = undefined; var client: Client = .init(.{ .in = &in, .out = &out }); client.msize = msize; try testing.expect(editor.park_data_max >= client.maxWrite()); } test "9p server: board and native capacities size the actual fid storage" { const Board = Server(Stub, board); const Native = Server(Stub, editor); const BoardFids = @FieldType(Board, "fids"); const NativeFids = @FieldType(Native, "fids"); try testing.expectEqual(32, @typeInfo(BoardFids).array.len); try testing.expectEqual(256, @typeInfo(NativeFids).array.len); try testing.expectEqual(28, @sizeOf(@FieldType(Board.Fid, "name"))); try testing.expectEqual(255, @sizeOf(@FieldType(Native.Fid, "name"))); try testing.expectEqual(32 * @sizeOf(Board.Fid), @sizeOf(BoardFids)); try testing.expectEqual(256 * @sizeOf(Native.Fid), @sizeOf(NativeFids)); try testing.expect(@sizeOf(BoardFids) <= 3 * 1024); try testing.expect(@sizeOf(@FieldType(Board, "slots")) <= 8 * 1024); try testing.expect(3 * 4096 + @sizeOf(Board) <= 24 * 1024); try testing.expect(min_msize >= msize_min); }