vx32

Local 9vx git repository for patches.
git clone git://r-36.net/vx32
Log | Files | Refs

fcall.h (2913B)


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