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 {
38 /* useful constants */
39 #define HEADERSIZE (4 + 1 + 2)
40 #define VERSION9P "9P2000"
41 #define MSIZE9P ((uint32_t)4*1024*1024)
42 #define NOTAG ((uint16_t)~0U)
43 #define NOFID ((uint32_t)~0U)
48 #define NPSTATSIZ(namlen, uidnam, gidnam, unam) \
49 (6 + QIDSIZE + 20 + 2 + namlen + 2 + uidnam + 2 + gidnam + 2 + unam)
51 /* bits in Qid.type */
52 #define QTDIR 0x80 /* type bit for directories */
53 #define QTAPPEND 0x40 /* type bit for append only files */
54 #define QTEXCL 0x20 /* type bit for exclusive use files */
55 #define QTMOUNT 0x10 /* type bit for mounted channel */
56 #define QTAUTH 0x08 /* type bit for authentication file */
57 #define QTTMP 0x04 /* type bit for non-backed-up file */
58 #define QTSYMLINK 0x02 /* type bit for symbolic link */
59 #define QTFILE 0x00 /* type bits for plain file */
61 /* Topen mode/flags */
69 /* 9p message types */
71 Treaddir = 40, /* .L */
80 Terror = 106, /* illegal */
105 * plan9ports' include/fcall.h also has a
110 * which it's not mentioned in the 9p "rfc" over at
111 * 9p.cat-v.org. Ignoring that for now.