Blob


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