2 * Copyright (c) 2021, 2022 Omar Polo <op@omarpolo.com>
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23 * The message itself is len bytes long (counting the whole header
26 struct np_msg_header {
33 * The qid represents the server unique identification for the file.
34 * NOTE: the struct fields don't reflect the layout on the wire!
57 /* useful constants */
58 #define HEADERSIZE (4 + 1 + 2)
59 #define VERSION9P "9P2000"
60 #define MSIZE9P ((uint32_t)4*1024*1024)
61 #define NOTAG ((uint16_t)~0U)
62 #define NOFID ((uint32_t)~0U)
68 * from u9fs "ample room for Twrite/Rread header". It's a bit sloppy
69 * but otherwise it fails with "i/o count too large". Only for usage in
74 #define NPSTATSIZ(namlen, uidnam, gidnam, unam) \
75 (6 + QIDSIZE + 20 + 2 + namlen + 2 + uidnam + 2 + gidnam + 2 + unam)
77 /* bits in Qid.type */
78 #define QTDIR 0x80 /* type bit for directories */
79 #define QTAPPEND 0x40 /* type bit for append only files */
80 #define QTEXCL 0x20 /* type bit for exclusive use files */
81 #define QTMOUNT 0x10 /* type bit for mounted channel */
82 #define QTAUTH 0x08 /* type bit for authentication file */
83 #define QTTMP 0x04 /* type bit for non-backed-up file */
84 #define QTSYMLINK 0x02 /* type bit for symbolic link */
85 #define QTFILE 0x00 /* type bits for plain file */
87 /* Topen mode/flags */
95 /* 9p message types */
97 Treaddir = 40, /* .L */
100 Tversion = 100, /* 0x64 */
102 Tauth = 102, /* 0x66 */
104 Tattach = 104, /* 0x68 */
106 Terror = 106, /* illegal */
108 Tflush = 108, /* 0x6c */
110 Twalk = 110, /* 0x6e */
112 Topen = 112, /* 0x70 */
114 Tcreate = 114, /* 0x72 */
116 Tread = 116, /* 0x74 */
118 Twrite = 118, /* 0x76 */
120 Tclunk = 120, /* 0x78 */
122 Tremove = 122, /* 0x7a */
124 Tstat = 124, /* 0x7c */
126 Twstat = 126, /* 0x7e */
131 * plan9ports' include/fcall.h also has a
136 * which it's not mentioned in the 9p "rfc" over at
137 * 9p.cat-v.org. Ignoring that for now.