diff options
Diffstat (limited to 'net9p_defs.txt')
-rw-r--r-- | net9p_defs.txt | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/net9p_defs.txt b/net9p_defs.txt new file mode 100644 index 0000000..3eba255 --- /dev/null +++ b/net9p_defs.txt @@ -0,0 +1,89 @@ +# net9p.txt - Definitions of 9P messages +# +# Copyright (C) 2024 Luke T. Shumaker <lukeshu@lukeshu.com> +# SPDX-Licence-Identifier: AGPL-3.0-or-later + +# In the 9P protocol, each message has a type, and message types come +# in pairs (except "Rerror"); "T" and "R"; "T" messages are +# client->server requests, and "R" messages are server->client +# responses (I do not know what the Plan 9 designers intended "T" and +# "R" to stand for). The type of a message is represented by a u8 ID. +# +# This file is a defines the the ID and format of each message type, +# and is used to generate implementation code. + +# The format of each message (excluding the "size[4] msg_type[1] +# tag[2]" header) is written here as a sequence of +# "member_name[member_type]" struct members. +# +# The primitive member types types are the following single-character +# mnemonics: +# +# - 1 = u8 +# - 2 = u16le +# - 4 = u32le +# - 8 = u16le +# +# A type expression may also be [type*count]" where "type" is the +# type, and then "count" is a previously-defined integer member. +# +# We also define a few reusable compound types: + +# data (u32le `n`, then `n` bytes of data) +d = "len[8] dat[1*len]" + +# string (u16le `n`, then `n` bytes of UTF-8) +s = "len[2] utf8[1*len]" + +# qid (TODO) +q = "type[1] vers[4] path[8]" + +# stat (TODO) +stat = "stat_size[2]" + "kern_type[2]" + "kern_dev[4]" + "file_qid[q]" + "file_mode[4]" + "file_atime[4]" + "file_mtime[4]" + "file_size[8]" + "file_name[s]" + "file_owner_uid[s]" + "file_owner_gid[s]" + "file_last_modified_uid[s]" + +# "9P2000" base protocol +# https://ericvh.github.io/9p-rfc/rfc9p2000.html +# https://github.com/ericvh/9p-rfc/blob/master/9p2000.xml +# +# But due to incompleteness of the draft RFC, the Plan 9 manual +# section-5 and the Plan 9 headers (particularly fcall.h) are a better +# references. +100 = Tversion "max_msg_size[4] version[s]" +101 = Rversion "max_msg_size[4] version[s]" +102 = Tauth "afid[4] uname[s] aname[s]" +103 = Rauth "aqid[q]" +104 = Tattach "fid[4] afid[4] uname[s] aname[s]" +105 = Rattach "qid[q]" +#106 = Terror "illegal" +107 = Rerror "ename[s]" +108 = Tflush "oldtag[2]" +109 = Rflush "" +110 = Twalk "fid[4] newfid[4] nwname[2] wname[s*nwname]" +111 = Rwalk "nwqid[2] wqid[q*nwqid]" +112 = Topen "fid[4] mode[1]" +113 = Ropen "qid[q] iounit[4]" +114 = Tcreate "fid[4] name[s] perm[4] mode[1]" +115 = Rcreate "qid[q] iounit[4]" +116 = Tread "fid[4] offset[8] count[4]" +117 = Rread "data[d]" +118 = Twrite "fid[4] offset[8] data[d]" +119 = Rwrite "count[4]" +120 = Tclunk "fid[4]" +121 = Rclunk "" +122 = Tremove "fid[4]" +123 = Rremove "" +124 = Tstat "fid[4]" +125 = Rstat "stat[stat]" +126 = Twstat "fid[4] stat[stat]" +127 = Rwstat "" |