//! 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 engine configuration Pardes builds, the editor's, and //! re-exports what the transports use. const cloud9 = @import("cloud9"); pub const fs = cloud9.fs; pub const Server = cloud9.fs.Server; pub const header_len = cloud9.header_len; pub const notag = cloud9.notag; pub const nofid = cloud9.nofid; pub const max_welem = cloud9.max_welem; 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 Client = cloud9.Client; pub const oread = cloud9.oread; pub const owrite = cloud9.owrite; pub const ordwr = cloud9.ordwr; pub const otrunc = cloud9.otrunc; 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; pub const max_fids: usize = 256; 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: the editor's capacities size the actual fid storage" { const Native = Server(Stub, editor); const NativeFids = @FieldType(Native, "fids"); try testing.expectEqual(256, @typeInfo(NativeFids).array.len); try testing.expectEqual(255, @sizeOf(@FieldType(Native.Fid, "name"))); try testing.expectEqual(256 * @sizeOf(Native.Fid), @sizeOf(NativeFids)); try testing.expect(min_msize >= msize_min); }