Subversion Repositories planix.SVN

Rev

Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
#ifndef _9FS_9P_H_
2
#define _9FS_9P_H_
3
 
4
 
5
#define U9FS_AUTHLEN 13
6
#define U9FS_NAMELEN    28
7
#define U9FS_TICKETLEN  72
8
#define U9FS_ERRLEN     64
9
#define U9FS_DOMLEN     48
10
#define U9FS_CHALLEN    8
11
#define U9FS_DIRLEN     116
12
#define U9FS_MAXFDATA  8192
13
#define U9FS_MAXDDATA  (((int)U9FS_MAXFDATA/U9FS_DIRLEN)*U9FS_DIRLEN)
14
 
15
#define U9P_MODE_RD    0x0
16
#define U9P_MODE_WR    0x1
17
#define U9P_MODE_RDWR  0x2
18
#define U9P_MODE_EX    0x3
19
#define U9P_MODE_TRUNC 0x10
20
#define U9P_MODE_CLOSE 0x40
21
 
22
#define U9P_PERM_CHDIR(m) (0x80000000&(m))
23
#define U9P_PERM_OWNER(m) ((m)&0x7)
24
#define U9P_PERM_GROUP(m) (((m)>>3)&0x7)
25
#define U9P_PERM_OTHER(m) (((m)>>6)&0x7)
26
#define U9P_PERM_ALL(m)   ((m)&0777)
27
 
28
/* this is too small */
29
typedef u_int32_t u9fsfh_t;
30
 
31
struct u9fd_qid {
32
	u9fsfh_t	path;
33
	u_int32_t	vers;
34
};
35
 
36
struct	u9fsreq {
37
  TAILQ_ENTRY(u9fsreq) r_chain;
38
  struct u9fsreq * r_rep;
39
  struct mbuf * r_mrep;
40
  struct proc	*r_procp;	/* Proc that did I/O system call */
41
  struct u9fsmount *r_nmp;
42
 
43
  /* actual content of the 9P message */
44
	char	r_type;
45
	short	r_fid;
46
	u_short	r_tag;
47
	union {
48
		struct {
49
			u_short	oldtag;		/* Tflush */
50
			struct u9fd_qid qid;		/* Rattach, Rwalk, Ropen, Rcreate */
51
			char	rauth[U9FS_AUTHLEN];	/* Rattach */
52
		} u1;
53
		struct {
54
			char	uname[U9FS_NAMELEN];		/* Tattach */
55
			char	aname[U9FS_NAMELEN];		/* Tattach */
56
			char	ticket[U9FS_TICKETLEN];	/* Tattach */
57
			char	auth[U9FS_AUTHLEN];	/* Tattach */
58
		} u2;
59
		struct {
60
			char	ename[U9FS_ERRLEN];		/* Rerror */
61
			char	authid[U9FS_NAMELEN];	/* Rsession */
62
			char	authdom[U9FS_DOMLEN];	/* Rsession */
63
			char	chal[U9FS_CHALLEN];		/* Tsession/Rsession */
64
		} u3;
65
		struct {
66
			u_int32_t	perm;		/* Tcreate */ 
67
			short	newfid;		/* Tclone, Tclwalk */
68
			char	name[U9FS_NAMELEN];	/* Twalk, Tclwalk, Tcreate */
69
			char	mode;		/* Tcreate, Topen */
70
		} u4;
71
		struct {
72
			u_int64_t	offset;		/* Tread, Twrite */
73
			u_short	        count;		/* Tread, Twrite, Rread */
74
			char	*data;		/* Twrite, Rread */
75
		} u5;
76
			char	stat[U9FS_DIRLEN];	/* Twstat, Rstat */
77
	} u;
78
};
79
 
80
#define r_oldtag u.u1.oldtag
81
#define r_qid u.u1.qid
82
#define r_rauth u.u1.rauth
83
#define r_uname u.u2.uname
84
#define r_aname u.u2.aname
85
#define r_ticket  u.u2.ticket
86
#define r_auth  u.u2.auth
87
#define r_ename  u.u3.ename
88
#define r_authid  u.u3.authid
89
#define r_authdom  u.u3.authdom
90
#define r_chal  u.u3.chal
91
#define r_perm  u.u4.perm
92
#define r_newfid  u.u4.newfid
93
#define r_name  u.u4.name
94
#define r_mode  u.u4.mode
95
#define r_offset  u.u5.offset
96
#define r_count  u.u5.count
97
#define r_data  u.u5.data
98
#define r_stat  u.stat
99
 
100
extern TAILQ_HEAD(u9fs_reqq, u9fsreq) u9fs_reqq;
101
 
102
struct u9fsdir {
103
  char	dir_name[U9FS_NAMELEN];
104
  char	dir_uid[U9FS_NAMELEN];
105
  char	dir_gid[U9FS_NAMELEN];
106
  struct u9fd_qid	dir_qid;
107
  u_int32_t	dir_mode;
108
  u_int32_t	dir_atime;
109
  u_int32_t	dir_mtime;
110
  union {
111
    u_int64_t	length;
112
    struct {	/* little endian */
113
      u_int32_t	llength;
114
      u_int32_t	hlength;
115
    } l;
116
  } u;
117
  u_short	dir_type;
118
  u_short	dir_dev;
119
};
120
 
121
#define dir_length u.length
122
#define dir_llength u.l.llength
123
#define dir_hlength u.l.hlength
124
 
125
enum
126
{
127
	Tnop =		50,
128
	Rnop,
129
	Tosession =	52,	/* illegal */
130
	Rosession,		/* illegal */
131
	Terror =	54,	/* illegal */
132
	Rerror,
133
	Tflush =	56,
134
	Rflush,
135
	Toattach =	58,	/* illegal */
136
	Roattach,		/* illegal */
137
	Tclone =	60,
138
	Rclone,
139
	Twalk =		62,
140
	Rwalk,
141
	Topen =		64,
142
	Ropen,
143
	Tcreate =	66,
144
	Rcreate,
145
	Tread =		68,
146
	Rread,
147
	Twrite =	70,
148
	Rwrite,
149
	Tclunk =	72,
150
	Rclunk,
151
	Tremove =	74,
152
	Rremove,
153
	Tstat =		76,
154
	Rstat,
155
	Twstat =	78,
156
	Rwstat,
157
	Tclwalk =	80,
158
	Rclwalk,
159
	Tauth =		82,	/* illegal */
160
	Rauth,			/* illegal */
161
	Tsession =	84,
162
	Rsession,
163
	Tattach =	86,
164
	Rattach,
165
	Ttunnel =	88,
166
	Rtunnel,
167
	Tmax
168
};
169
 
170
static char * u9p_types[] = {
171
  "Tnop",
172
  "Rnop",
173
  "Tosession",
174
  "Rosession",
175
  "Terror",
176
  "Rerror",
177
  "Tflush",
178
  "Rflush",
179
  "Toattach",
180
  "Roattach",
181
  "Tclone",
182
  "Rclone",
183
  "Twalk",
184
  "Rwalk",
185
  "Topen",
186
  "Ropen",
187
  "Tcreate",
188
  "Rcreate",
189
  "Tread",
190
  "Rread",
191
  "Twrite",
192
  "Rwrite",
193
  "Tclunk",
194
  "Rclunk",
195
  "Tremove",
196
  "Rremove",
197
  "Tstat",
198
  "Rstat",
199
  "Twstat",
200
  "Rwstat",
201
  "Tclwalk",
202
  "Rclwalk",
203
  "Tauth",
204
  "Rauth",
205
  "Tsession",
206
  "Rsession",
207
  "Tattach",
208
  "Rattach",
209
  "Ttunnel",
210
  "Rtunnel",
211
  "Tmax"
212
};
213
 
214
int u9p_m2s __P((char *ap, int n, struct u9fsreq *f));
215
int u9p_s2m __P((struct u9fsreq *f, char *ap, int copydata));
216
int u9p_m2d __P((char *ap, struct u9fsdir *f));
217
int u9p_d2m __P((struct u9fsdir *f, char *ap));
218
int u9p_type __P((char * t));
219
 
220
int u9p_m_m2s __P((struct mbuf **m, struct u9fsreq *f));
221
struct mbuf * u9p_m_s2m __P((struct u9fsreq *f));
222
int u9p_m_m2d __P((struct mbuf **m, struct u9fsdir *f));
223
struct mbuf * u9p_m_d2m __P((struct u9fsdir *f));
224
u_short u9p_m_tag __P((struct mbuf **m));
225
 
226
#endif