xref: /plan9/sys/src/cmd/disk/kfs/9p1.h (revision 12fd1c83b21b4d1deeab2b58fe2c202d2038c714)
1 #define	DIRREC		116		/* size of a directory ascii record */
2 #define	ERRREC		64		/* size of a error record */
3 #define	MAXMSG		160	/* max header sans data */
4 
5 typedef	struct	Oldfcall	Oldfcall;
6 
7 struct	Oldfcall
8 {
9 	char	type;
10 	ushort	fid;
11 	short	err;
12 	short	tag;
13 	union
14 	{
15 		struct
16 		{
17 			short	uid;		/* T-Userstr */
18 			short	oldtag;		/* T-nFlush */
19 			Qid9p1	qid;		/* R-Attach, R-Clwalk, R-Walk,
20 						 * R-Open, R-Create */
21 			char	rauth[AUTHENTLEN];	/* R-attach */
22 		};
23 		struct
24 		{
25 			char	uname[NAMELEN];	/* T-nAttach */
26 			char	aname[NAMELEN];	/* T-nAttach */
27 			char	ticket[TICKETLEN];	/* T-attach */
28 			char	auth[AUTHENTLEN];	/* T-attach */
29 		};
30 		struct
31 		{
32 			char	ename[ERRREC];	/* R-nError */
33 			char	chal[CHALLEN];	/* T-session, R-session */
34 			char	authid[NAMELEN];	/* R-session */
35 			char	authdom[DOMLEN];	/* R-session */
36 		};
37 		struct
38 		{
39 			char	name[NAMELEN];	/* T-Walk, T-Clwalk, T-Create, T-Remove */
40 			long	perm;		/* T-Create */
41 			ushort	newfid;		/* T-Clone, T-Clwalk */
42 			char	mode;		/* T-Create, T-Open */
43 		};
44 		struct
45 		{
46 			long	offset;		/* T-Read, T-Write */
47 			long	count;		/* T-Read, T-Write, R-Read */
48 			char*	data;		/* T-Write, R-Read */
49 		};
50 		struct
51 		{
52 			char	stat[DIRREC];	/* T-Wstat, R-Stat */
53 		};
54 	};
55 };
56 
57 /*
58  * P9 protocol message types
59  */
60 enum
61 {
62 	Tnop9p1 =		50,
63 	Rnop9p1,
64 	Tosession9p1 =	52,
65 	Rosession9p1,
66 	Terror9p1 =	54,	/* illegal */
67 	Rerror9p1,
68 	Tflush9p1 =	56,
69 	Rflush9p1,
70 	Toattach9p1 =	58,
71 	Roattach9p1,
72 	Tclone9p1 =	60,
73 	Rclone9p1,
74 	Twalk9p1 =		62,
75 	Rwalk9p1,
76 	Topen9p1 =		64,
77 	Ropen9p1,
78 	Tcreate9p1 =	66,
79 	Rcreate9p1,
80 	Tread9p1 =		68,
81 	Rread9p1,
82 	Twrite9p1 =	70,
83 	Rwrite9p1,
84 	Tclunk9p1 =	72,
85 	Rclunk9p1,
86 	Tremove9p1 =	74,
87 	Rremove9p1,
88 	Tstat9p1 =		76,
89 	Rstat9p1,
90 	Twstat9p1 =	78,
91 	Rwstat9p1,
92 	Tclwalk9p1 =	80,
93 	Rclwalk9p1,
94 	Tauth9p1 =		82,	/* illegal */
95 	Rauth9p1,			/* illegal */
96 	Tsession9p1 =	84,
97 	Rsession9p1,
98 	Tattach9p1 =	86,
99 	Rattach9p1,
100 
101 	MAXSYSCALL
102 };
103 
104 int	convD2M9p1(Dentry*, char*);
105 int	convM2D9p1(char*, Dentry*);
106 int	convM2S9p1(uchar*, Oldfcall*, int);
107 int	convS2M9p1(Oldfcall*, uchar*);
108 void	fcall9p1(Chan*, Oldfcall*, Oldfcall*);
109 int	authorize(Chan*, Oldfcall*, Oldfcall*);
110 
111 void	(*call9p1[MAXSYSCALL])(Chan*, Oldfcall*, Oldfcall*);
112 
113 extern Nvrsafe nvr;
114