//! The VFS wire protocol — the message format spoken between a client (via the 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 FileStatus). Everything fits //! in one IPC message (<= ipc MESSAGE_MAXIMUM = 256 bytes). //! //! This is a danos-native contract, so it uses danos names throughout — the POSIX //! spellings (`stat`, `O_CREAT`, ...) live only in the POSIX layer //! (library/posix/unistd.zig), which translates to these. //! //! This is user-space only — the kernel knows nothing of files or paths; it only moves the bytes. //! Shared by library/posix/unistd.zig (client) and system/services/vfs/vfs.zig (server). pub const Operation = enum(u32) { open, // open(path) -> node id close, // close(node) read, // read(node, offset, len) -> bytes write, // write(node, offset, bytes) -> count status, // status(node) -> FileStatus }; /// 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 { operation: Operation, 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 /// FileStatus size). pub const Reply = extern struct { status: i32, _padding: u32 = 0, node: u64 = 0, len: u32 = 0, _padding2: u32 = 0, }; /// A file's metadata (the danos-native answer to a `status` request). The POSIX /// layer maps this onto `struct stat`. pub const FileStatus = extern struct { size: u64, kind: u32, _padding: u32 = 0, }; pub const message_maximum: usize = 256; pub const request_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 - request_size; /// Open flags (danos-native; the POSIX layer maps `O_CREAT` onto `create`). pub const create: u32 = 1;