fcall.h 2.7 KB

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