//! The VFS wire protocol — the message format spoken between a client (via the //! `runtime` file API) and the user-space VFS server over IPC. A request is a fixed //! `Request` header followed by an inline payload (a path, or write bytes); a //! reply is a fixed `Reply` header followed by an inline payload (read bytes, or //! a Stat). Everything fits in one IPC message (<= ipc MESSAGE_MAXIMUM = 256 bytes). //! //! This is user-space only — the kernel knows nothing of files or paths; it only //! moves the bytes. Shared by lib/unistd.zig (client) and sbin/vfs.zig (server). pub const Op = enum(u32) { open, // open(path) -> node id close, // close(node) read, // read(node, offset, len) -> bytes write, // write(node, offset, bytes) -> count stat, // stat(node) -> Stat }; /// Request header. `node` is the server-side open-file id (from a prior open); /// for `open` the path is the payload and `len` is its length. `offset`/`len` /// carry the read/write position and count. pub const Request = extern struct { op: Op, node: u64, offset: u64, len: u32, flags: u32, }; /// Reply header. `status` is 0 on success or a negative errno; `node` is the new /// open-file id (for `open`); `len` is the payload length (bytes read, or the /// Stat size). pub const Reply = extern struct { status: i32, _pad: u32 = 0, node: u64 = 0, len: u32 = 0, _pad2: u32 = 0, }; pub const Stat = extern struct { size: u64, kind: u32, _pad: u32 = 0, }; pub const message_maximum: usize = 256; pub const req_size: usize = @sizeOf(Request); pub const reply_size: usize = @sizeOf(Reply); /// Largest inline payload that still fits one IPC message alongside a header. pub const maximum_payload: usize = message_maximum - req_size; /// Open flags. pub const O_CREAT: u32 = 1;