2 fb1a36c0 2022-01-09 op * Copyright (c) 2021, 2022 Omar Polo <op@omarpolo.com>
4 fb1a36c0 2022-01-09 op * Permission to use, copy, modify, and distribute this software for any
5 fb1a36c0 2022-01-09 op * purpose with or without fee is hereby granted, provided that the above
6 fb1a36c0 2022-01-09 op * copyright notice and this permission notice appear in all copies.
8 fb1a36c0 2022-01-09 op * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 fb1a36c0 2022-01-09 op * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 fb1a36c0 2022-01-09 op * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 fb1a36c0 2022-01-09 op * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 fb1a36c0 2022-01-09 op * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 fb1a36c0 2022-01-09 op * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 fb1a36c0 2022-01-09 op * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 fb1a36c0 2022-01-09 op #ifndef KAMI_H
18 fb1a36c0 2022-01-09 op #define KAMI_H
21 fb1a36c0 2022-01-09 op * 9p message header.
23 fb1a36c0 2022-01-09 op * The message itself is len bytes long (counting the whole header
26 fb1a36c0 2022-01-09 op struct np_msg_header {
33 fb1a36c0 2022-01-09 op uint64_t path;
34 fb1a36c0 2022-01-09 op uint32_t vers;
38 fb1a36c0 2022-01-09 op /* useful constants */
39 fb1a36c0 2022-01-09 op #define HEADERSIZE (4 + 1 + 2)
40 fb1a36c0 2022-01-09 op #define VERSION9P "9P2000"
41 fb1a36c0 2022-01-09 op #define MSIZE9P ((uint32_t)4*1024*1024)
42 fb1a36c0 2022-01-09 op #define NOTAG ((uint16_t)~0U)
43 fb1a36c0 2022-01-09 op #define NOFID ((uint32_t)~0U)
44 fb1a36c0 2022-01-09 op #define NOUID (-1)
45 fb1a36c0 2022-01-09 op #define QIDSIZE 13
46 fb1a36c0 2022-01-09 op #define MAXWELEM 16
48 fb1a36c0 2022-01-09 op #define NPSTATSIZ(namlen, uidnam, gidnam, unam) \
49 fb1a36c0 2022-01-09 op (6 + QIDSIZE + 20 + 2 + namlen + 2 + uidnam + 2 + gidnam + 2 + unam)
51 fb1a36c0 2022-01-09 op /* bits in Qid.type */
52 fb1a36c0 2022-01-09 op #define QTDIR 0x80 /* type bit for directories */
53 fb1a36c0 2022-01-09 op #define QTAPPEND 0x40 /* type bit for append only files */
54 fb1a36c0 2022-01-09 op #define QTEXCL 0x20 /* type bit for exclusive use files */
55 fb1a36c0 2022-01-09 op #define QTMOUNT 0x10 /* type bit for mounted channel */
56 fb1a36c0 2022-01-09 op #define QTAUTH 0x08 /* type bit for authentication file */
57 fb1a36c0 2022-01-09 op #define QTTMP 0x04 /* type bit for non-backed-up file */
58 fb1a36c0 2022-01-09 op #define QTSYMLINK 0x02 /* type bit for symbolic link */
59 fb1a36c0 2022-01-09 op #define QTFILE 0x00 /* type bits for plain file */
61 fb1a36c0 2022-01-09 op /* Topen mode/flags */
62 fb1a36c0 2022-01-09 op #define KOREAD 0x00
63 fb1a36c0 2022-01-09 op #define KOWRITE 0x01
64 fb1a36c0 2022-01-09 op #define KORDWR 0x02
65 fb1a36c0 2022-01-09 op #define KOEXEC 0x03
66 fb1a36c0 2022-01-09 op #define KOTRUNC 0x10
67 fb1a36c0 2022-01-09 op #define KORCLOSE 0x40
69 fb1a36c0 2022-01-09 op /* 9p message types */
71 fb1a36c0 2022-01-09 op Treaddir = 40, /* .L */
74 fb1a36c0 2022-01-09 op Tversion = 100,
78 fb1a36c0 2022-01-09 op Tattach = 104,
80 fb1a36c0 2022-01-09 op Terror = 106, /* illegal */
88 fb1a36c0 2022-01-09 op Tcreate = 114,
96 fb1a36c0 2022-01-09 op Tremove = 122,
100 fb1a36c0 2022-01-09 op Twstat = 126,
105 fb1a36c0 2022-01-09 op * plan9ports' include/fcall.h also has a
107 fb1a36c0 2022-01-09 op * Topenfd = 98,
110 fb1a36c0 2022-01-09 op * which it's not mentioned in the 9p "rfc" over at
111 fb1a36c0 2022-01-09 op * 9p.cat-v.org. Ignoring that for now.