3 Fcall, convS2M, convD2M, convM2S, convM2D, fcallfmt, dirfmt, dirmodefmt, read9pmsg, statcheck, sizeS2M, sizeD2M \- interface to Plan 9 File protocol
13 uint convS2M(Fcall *f, uchar *ap, uint nap)
16 uint convD2M(Dir *d, uchar *ap, uint nap)
19 uint convM2S(uchar *ap, uint nap, Fcall *f)
22 uint convM2D(uchar *ap, uint nap, Dir *d, char *strs)
34 int read9pmsg(int fd, uchar *buf, uint nbuf)
37 int statcheck(uchar *buf, uint nbuf)
40 uint sizeS2M(Fcall *f)
46 routines convert messages in the machine-independent format of
47 the Plan 9 file protocol,
48 9P, to and from a more convenient form,
54 .if n .ta 4n +6n +5n +6n +18n +4n
55 .if t .ta \w'xxxx'u +\w'short 'u +\w'xxxx'u +\w'ushort 'u +\w'ticket[TICKETLEN]; 'u +\w'/* 'u
66 u32int msize; /* Tversion, Rversion */
67 char *version; /* Tversion, Rversion */
70 ushort oldtag; /* Tflush */
73 char *ename; /* Rerror */
76 Qid qid; /* Rattach, Ropen, Rcreate */
77 u32int iounit; /* Ropen, Rcreate */
83 u32int afid; /* Tauth, Tattach */
84 char *uname; /* Tauth, Tattach */
85 char *aname; /* Tauth, Tattach */
88 u32int perm; /* Tcreate */
89 char *name; /* Tcreate */
90 uchar mode; /* Tcreate, Topen */
93 u32int newfid; /* Twalk */
94 ushort nwname; /* Twalk */
95 char *wname[MAXWELEM]; /* Twalk */
98 ushort nwqid; /* Rwalk */
99 Qid wqid[MAXWELEM]; /* Rwalk */
102 vlong offset; /* Tread, Twrite */
103 u32int count; /* Tread, Twrite, Rread */
104 char *data; /* Twrite, Rread */
107 ushort nstat; /* Twstat, Rstat */
108 uchar *stat; /* Twstat, Rstat */
115 /* these are implemented as macros */
118 ushort GBIT16(uchar*)
122 void PBIT8(uchar*, uchar)
123 void PBIT16(uchar*, ushort)
124 void PBIT32(uchar*, ulong)
125 void PBIT64(uchar*, vlong)
133 This structure is defined in
136 for a full description of 9P messages and their encoding.
137 For all message types, the
146 etc. (defined in an enumerated type in
149 is used by most messages, and
151 is used by all messages.
152 The other fields are used selectively by the message types
156 takes a 9P message at
160 and uses it to fill in
164 If the passed message
165 including any data for
170 is formatted properly,
171 the return value is the number of bytes the message occupied in the buffer
173 which will always be less than or equal to
182 is set to a pointer into the argument message,
186 does the reverse conversion, turning
188 into a message starting at
190 The length of the resulting message is returned.
199 are copied into the message.
203 is a suitable amount of buffer to reserve for storing
205 the data portion of a
209 will be no more than the buffer size negotiated in the
210 .BR Tversion/Rversion
216 returns the number of bytes required to store the machine-independent representation of the
220 including its initial 32-bit size field.
221 In other words, it reports the number of bytes produced
222 by a successful call to
227 used by the routines described in
230 converts the machine-independent form starting at
234 and returns the length of the machine-independent encoding.
235 The strings in the returned
237 structure are stored at successive locations starting at
241 will point to storage immediately after the
246 pointer, in which case the string pointers in the returned
250 however, the return value still includes their length.
253 does the reverse translation,
254 also returning the length of the encoding.
255 If the buffer is too short, the return value will be
257 and the correct size will be returned in the first
260 (If the buffer is less that
262 the return value is zero; therefore a correct test for
263 complete packing of the message is that the return value is
268 can be used to extract the correct value.
269 The related macros with different sizes retrieve the corresponding-sized quantities.
271 and its brethren place values in messages.
272 With the exception of handling short buffers in
274 these macros are not usually needed except by internal routines.
279 returns the number of bytes required to store the machine-independent representation of the
283 including its initial 16-bit size field.
291 contain a validly formatted machine-independent
293 entry suitable as an argument, for example, for the
298 It checks that the sizes of all the elements of the the entry sum to exactly
300 which is a simple but effective test of validity.
304 should include the second two-byte (16-bit) length field that precedes the entry when
305 formatted in a 9P message (see
309 is 2 plus the sum of the sizes of the entry itself.
311 also verifies that the length field has the correct value (that is,
315 for a valid entry and
317 for an incorrectly formatted entry.
323 are formatting routines, suitable for
330 values into string representations of the directory buffer,
337 has been installed with format letter
347 multiple times, if necessary, to read an entire 9P message into
349 The return value is 0 for end of file, or -1 for error; it does not return
352 .B /sys/src/libc/9sys