Subversion Repositories planix.SVN

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
68 7u83 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
#define U9P_PERM_EXCL(m)    ((m)&0x20000000)
28
#define U9P_PERM_APPEND(m)  ((m)&0x40000000)
29
#define U9P_PERM_NONPERM(m) ((m)&0xfffffe00)
30
 
31
/* this is too small */
32
typedef u_int32_t u9fsfh_t;
33
 
34
struct u9fs_qid {
35
	u9fsfh_t	path;
36
	u_int32_t	vers;
37
};
38
 
39
struct	u9fsreq {
40
  TAILQ_ENTRY(u9fsreq) r_chain;
41
  struct u9fsreq * r_rep;
42
  struct mbuf * r_mrep;
43
  struct proc	*r_procp;	/* Proc that did I/O system call */
44
  struct u9fsmount *r_nmp;
45
 
46
  /* actual content of the 9P message */
47
	char	r_type;
48
	short	r_fid;
49
	u_short	r_tag;
50
	union {
51
		struct {
52
			u_short	oldtag;		/* Tflush */
53
			struct u9fs_qid qid;		/* Rattach, Rwalk, Ropen, Rcreate */
54
			char	rauth[U9FS_AUTHLEN];	/* Rattach */
55
		} u1;
56
		struct {
57
			char	uname[U9FS_NAMELEN];		/* Tattach */
58
			char	aname[U9FS_NAMELEN];		/* Tattach */
59
			char	ticket[U9FS_TICKETLEN];	/* Tattach */
60
			char	auth[U9FS_AUTHLEN];	/* Tattach */
61
		} u2;
62
		struct {
63
			char	ename[U9FS_ERRLEN];		/* Rerror */
64
			char	authid[U9FS_NAMELEN];	/* Rsession */
65
			char	authdom[U9FS_DOMLEN];	/* Rsession */
66
			char	chal[U9FS_CHALLEN];		/* Tsession/Rsession */
67
		} u3;
68
		struct {
69
			u_int32_t	perm;		/* Tcreate */ 
70
			short	newfid;		/* Tclone, Tclwalk */
71
			char	name[U9FS_NAMELEN];	/* Twalk, Tclwalk, Tcreate */
72
			char	mode;		/* Tcreate, Topen */
73
		} u4;
74
		struct {
75
			u_int64_t	offset;		/* Tread, Twrite */
76
			u_short	        count;		/* Tread, Twrite, Rread */
77
			char	*data;		/* Twrite, Rread */
78
		} u5;
79
			char	stat[U9FS_DIRLEN];	/* Twstat, Rstat */
80
	} u;
81
};
82
 
83
#define r_oldtag u.u1.oldtag
84
#define r_qid u.u1.qid
85
#define r_rauth u.u1.rauth
86
#define r_uname u.u2.uname
87
#define r_aname u.u2.aname
88
#define r_ticket  u.u2.ticket
89
#define r_auth  u.u2.auth
90
#define r_ename  u.u3.ename
91
#define r_authid  u.u3.authid
92
#define r_authdom  u.u3.authdom
93
#define r_chal  u.u3.chal
94
#define r_perm  u.u4.perm
95
#define r_newfid  u.u4.newfid
96
#define r_name  u.u4.name
97
#define r_mode  u.u4.mode
98
#define r_offset  u.u5.offset
99
#define r_count  u.u5.count
100
#define r_data  u.u5.data
101
#define r_stat  u.stat
102
 
103
struct u9fsdir {
104
  char	dir_name[U9FS_NAMELEN];
105
  char	dir_uid[U9FS_NAMELEN];
106
  char	dir_gid[U9FS_NAMELEN];
107
  struct u9fs_qid	dir_qid;
108
  u_int32_t	dir_mode;
109
  u_int32_t	dir_atime;
110
  u_int32_t	dir_mtime;
111
  union {
112
    u_int64_t	length;
113
    struct {	/* little endian */
114
      u_int32_t	llength;
115
      u_int32_t	hlength;
116
    } l;
117
  } u;
118
  u_short	dir_type;
119
  u_short	dir_dev;
120
};
121
 
122
#define dir_length u.length
123
#define dir_llength u.l.llength
124
#define dir_hlength u.l.hlength
125
 
126
enum
127
{
128
	Tnop =		50,
129
	Rnop,
130
	Tosession =	52,	/* illegal */
131
	Rosession,		/* illegal */
132
	Terror =	54,	/* illegal */
133
	Rerror,
134
	Tflush =	56,
135
	Rflush,
136
	Toattach =	58,	/* illegal */
137
	Roattach,		/* illegal */
138
	Tclone =	60,
139
	Rclone,
140
	Twalk =		62,
141
	Rwalk,
142
	Topen =		64,
143
	Ropen,
144
	Tcreate =	66,
145
	Rcreate,
146
	Tread =		68,
147
	Rread,
148
	Twrite =	70,
149
	Rwrite,
150
	Tclunk =	72,
151
	Rclunk,
152
	Tremove =	74,
153
	Rremove,
154
	Tstat =		76,
155
	Rstat,
156
	Twstat =	78,
157
	Rwstat,
158
	Tclwalk =	80,
159
	Rclwalk,
160
	Tauth =		82,	/* illegal */
161
	Rauth,			/* illegal */
162
	Tsession =	84,
163
	Rsession,
164
	Tattach =	86,
165
	Rattach,
166
	Ttunnel =	88,
167
	Rtunnel,
168
	Tmax
169
};
170
 
171
int u9p_m2s __P((char *ap, int n, struct u9fsreq *f));
172
int u9p_s2m __P((struct u9fsreq *f, char *ap, int copydata));
173
int u9p_m2d __P((char *ap, struct u9fsdir *f));
174
int u9p_d2m __P((struct u9fsdir *f, char *ap));
175
int u9p_type __P((char * t));
176
 
177
int u9p_m_m2s __P((struct mbuf **m, struct u9fsreq *f));
178
struct mbuf * u9p_m_s2m __P((struct u9fsreq *f));
179
int u9p_m_m2d __P((struct mbuf **m, struct u9fsdir *f));
180
struct mbuf * u9p_m_d2m __P((struct u9fsdir *f));
181
u_short u9p_m_tag __P((struct mbuf **m));
182
 
183
#endif