tfcall.h - plan9port - [fork] Plan 9 from user space | |
git clone git://src.adamsgaard.dk/plan9port | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
tfcall.h (3245B) | |
--- | |
1 #ifndef _FCALL_H_ | |
2 #define _FCALL_H_ 1 | |
3 #ifdef __cplusplus | |
4 extern "C" { | |
5 #endif | |
6 /* | |
7 #pragma src "/sys/src/libc/9sys" | |
8 #pragma lib "libc.a" | |
9 */ | |
10 | |
11 #define VERSION9P "9P2000" | |
12 #define MAXWELEM 16 | |
13 | |
14 typedef | |
15 struct Fcall | |
16 { | |
17 uchar type; | |
18 u32int fid; | |
19 ushort tag; | |
20 u32int msize; /* Tversion, Rversion */ | |
21 char *version; /* Tversion, Rversion */ | |
22 ushort oldtag; /* Tflush */ | |
23 char *ename; /* Rerror */ | |
24 Qid qid; /* Rattach, Ropen, Rcreate */ | |
25 u32int iounit; /* Ropen, Rcreate */ | |
26 Qid aqid; /* Rauth */ | |
27 u32int afid; /* Tauth, Tattach */ | |
28 char *uname; /* Tauth, Tattach */ | |
29 char *aname; /* Tauth, Tattach */ | |
30 u32int perm; /* Tcreate */ | |
31 char *name; /* Tcreate */ | |
32 uchar mode; /* Tcreate, Topen */ | |
33 u32int newfid; /* Twalk */ | |
34 ushort nwname; /* Twalk */ | |
35 char *wname[MAXWELEM]; /* Twalk */ | |
36 ushort nwqid; /* Rwalk */ | |
37 Qid wqid[MAXWELEM]; /* Rwalk */ | |
38 vlong offset; /* Tread, Twrite */ | |
39 u32int count; /* Tread, Twrite, Rread */ | |
40 char *data; /* Twrite, Rread */ | |
41 ushort nstat; /* Twstat, Rstat */ | |
42 uchar *stat; /* Twstat, Rstat */ | |
43 int unixfd; /* Ropenfd */ | |
44 | |
45 /* 9P2000.u extensions */ | |
46 int errornum; /* Rerror */ | |
47 int uidnum; /* Tattach, Tauth */ | |
48 char *extension; /* Tcreate */ | |
49 } Fcall; | |
50 | |
51 | |
52 #define GBIT8(p) ((p)[0]) | |
53 #define GBIT16(p) ((p)[0]|((p)[1]<<8)) | |
54 #define GBIT32(p) ((u32int)((p)[0]|((p)[1]<<8)|((p)[2]<<16… | |
55 #define GBIT64(p) ((u32int)((p)[0]|((p)[1]<<8)|((p)[2]<<16… | |
56 ((vlong)((p)[4]|((p)[5]<<8)|((p)[6]<<16)… | |
57 | |
58 #define PBIT8(p,v) (p)[0]=(v) | |
59 #define PBIT16(p,v) (p)[0]=(v);(p)[1]=(v)>>8 | |
60 #define PBIT32(p,v) (p)[0]=(v);(p)[1]=(v)>>8;(p)[2]=(v)>>1… | |
61 #define PBIT64(p,v) (p)[0]=(v);(p)[1]=(v)>>8;(p)[2]=(v)>>1… | |
62 (p)[4]=(v)>>32;(p)[5]=(v)>>40;(p)[6]=(v)>>48;(p)… | |
63 | |
64 #define BIT8SZ 1 | |
65 #define BIT16SZ 2 | |
66 #define BIT32SZ 4 | |
67 #define BIT64SZ 8 | |
68 #define QIDSZ (BIT8SZ+BIT32SZ+BIT64SZ) | |
69 | |
70 /* STATFIXLEN includes leading 16-bit count */ | |
71 /* The count, however, excludes itself; total size is BIT16SZ+count */ | |
72 #define STATFIXLEN (BIT16SZ+QIDSZ+5*BIT16SZ+4*BIT32SZ+1*BIT64SZ) … | |
73 #define STATFIXLENU (STATFIXLEN+BIT16SZ+3*BIT32SZ) /* for … | |
74 | |
75 #define NOTAG (ushort)~0U /* Dummy tag */ | |
76 #define NOFID (u32int)~0U /* Dummy fid */ | |
77 #define NOUID (-1) /* Dummy uid */ | |
78 #define IOHDRSZ 24 /* ample room for Twrite… | |
79 | |
80 enum | |
81 { | |
82 Tversion = 100, | |
83 Rversion, | |
84 Tauth = 102, | |
85 Rauth, | |
86 Tattach = 104, | |
87 Rattach, | |
88 Terror = 106, /* illegal */ | |
89 Rerror, | |
90 Tflush = 108, | |
91 Rflush, | |
92 Twalk = 110, | |
93 Rwalk, | |
94 Topen = 112, | |
95 Ropen, | |
96 Tcreate = 114, | |
97 Rcreate, | |
98 Tread = 116, | |
99 Rread, | |
100 Twrite = 118, | |
101 Rwrite, | |
102 Tclunk = 120, | |
103 Rclunk, | |
104 Tremove = 122, | |
105 Rremove, | |
106 Tstat = 124, | |
107 Rstat, | |
108 Twstat = 126, | |
109 Rwstat, | |
110 Tmax, | |
111 | |
112 Topenfd = 98, | |
113 Ropenfd | |
114 }; | |
115 | |
116 uint convM2S(uchar*, uint, Fcall*); | |
117 uint convS2M(Fcall*, uchar*, uint); | |
118 uint sizeS2M(Fcall*); | |
119 | |
120 int statcheck(uchar *abuf, uint nbuf); | |
121 uint convM2D(uchar*, uint, Dir*, char*); | |
122 uint convD2M(Dir*, uchar*, uint); | |
123 uint sizeD2M(Dir*); | |
124 | |
125 int fcallfmt(Fmt*); | |
126 int dirfmt(Fmt*); | |
127 int dirmodefmt(Fmt*); | |
128 | |
129 int read9pmsg(int, void*, uint); | |
130 | |
131 /* | |
132 #pragma varargck type "F" Fcall* | |
133 #pragma varargck type "M" ulong | |
134 #pragma varargck type "D" Dir* | |
135 */ | |
136 | |
137 #ifdef __cplusplus | |
138 } | |
139 #endif | |
140 #endif |