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)
67 #define NPSTATSIZ(namlen, uidnam, gidnam, unam) \
68 (6 + QIDSIZE + 20 + 2 + namlen + 2 + uidnam + 2 + gidnam + 2 + unam)
70 /* bits in Qid.type */
71 #define QTDIR 0x80 /* type bit for directories */
72 #define QTAPPEND 0x40 /* type bit for append only files */
73 #define QTEXCL 0x20 /* type bit for exclusive use files */
74 #define QTMOUNT 0x10 /* type bit for mounted channel */
75 #define QTAUTH 0x08 /* type bit for authentication file */
76 #define QTTMP 0x04 /* type bit for non-backed-up file */
77 #define QTSYMLINK 0x02 /* type bit for symbolic link */
78 #define QTFILE 0x00 /* type bits for plain file */
80 /* Topen mode/flags */
88 /* 9p message types */
90 Treaddir = 40, /* .L */
93 Tversion = 100, /* 0x64 */
95 Tauth = 102, /* 0x66 */
97 Tattach = 104, /* 0x68 */
99 Terror = 106, /* illegal */
101 Tflush = 108, /* 0x6c */
103 Twalk = 110, /* 0x6e */
105 Topen = 112, /* 0x70 */
107 Tcreate = 114, /* 0x72 */
109 Tread = 116, /* 0x74 */
111 Twrite = 118, /* 0x76 */
113 Tclunk = 120, /* 0x78 */
115 Tremove = 122, /* 0x7a */
117 Tstat = 124, /* 0x7c */
119 Twstat = 126, /* 0x7e */
124 * plan9ports' include/fcall.h also has a
129 * which it's not mentioned in the 9p "rfc" over at
130 * 9p.cat-v.org. Ignoring that for now.