dir.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. typedef long long vlong;
  2. typedef unsigned long long uvlong;
  3. typedef unsigned char uchar;
  4. typedef unsigned short ushort;
  5. typedef unsigned int uint;
  6. typedef unsigned long ulong;
  7. #define GBIT8(p) ((p)[0])
  8. #define GBIT16(p) ((p)[0]|((p)[1]<<8))
  9. #define GBIT32(p) ((p)[0]|((p)[1]<<8)|((p)[2]<<16)|((p)[3]<<24))
  10. #define GBIT64(p) ((vlong)((p)[0]|((p)[1]<<8)|((p)[2]<<16)|((p)[3]<<24)) |\
  11. ((vlong)((p)[4]|((p)[5]<<8)|((p)[6]<<16)|((p)[7]<<24)) << 32))
  12. #define PBIT8(p,v) (p)[0]=(v)
  13. #define PBIT16(p,v) (p)[0]=(v);(p)[1]=(v)>>8
  14. #define PBIT32(p,v) (p)[0]=(v);(p)[1]=(v)>>8;(p)[2]=(v)>>16;(p)[3]=(v)>>24
  15. #define PBIT64(p,v) (p)[0]=(v);(p)[1]=(v)>>8;(p)[2]=(v)>>16;(p)[3]=(v)>>24;\
  16. (p)[4]=(v)>>32;(p)[5]=(v)>>40;(p)[6]=(v)>>48;(p)[7]=(v)>>56
  17. #define BIT8SZ 1
  18. #define BIT16SZ 2
  19. #define BIT32SZ 4
  20. #define BIT64SZ 8
  21. #define QIDSZ (BIT8SZ+BIT32SZ+BIT64SZ)
  22. /* STATFIXLEN includes leading 16-bit count */
  23. /* The count, however, excludes itself; total size is BIT16SZ+count */
  24. #define STATFIXLEN (BIT16SZ+QIDSZ+5*BIT16SZ+4*BIT32SZ+1*BIT64SZ) /* amount of fixed length data in a stat buffer */
  25. typedef union
  26. {
  27. char clength[8];
  28. vlong vlength;
  29. struct
  30. {
  31. long hlength;
  32. long length;
  33. };
  34. } Length;
  35. typedef
  36. struct Qid
  37. {
  38. uvlong path;
  39. ulong vers;
  40. uchar type;
  41. } Qid;
  42. typedef
  43. struct Dir {
  44. /* system-modified data */
  45. ushort type; /* server type */
  46. uint dev; /* server subtype */
  47. /* file data */
  48. Qid qid; /* unique id from server */
  49. ulong mode; /* permissions */
  50. ulong atime; /* last read time */
  51. ulong mtime; /* last write time */
  52. vlong length; /* file length: see <u.h> */
  53. char *name; /* last element of path */
  54. char *uid; /* owner name */
  55. char *gid; /* group name */
  56. char *muid; /* last modifier name */
  57. } Dir;
  58. void _dirtostat(struct stat *, Dir*, Fdinfo*);
  59. uint _convM2D(uchar*, uint, Dir*, char*);
  60. uint _convD2M(Dir*, uchar*, uint);
  61. Dir *_dirstat(char*);
  62. int _dirwstat(char*, Dir*);
  63. Dir *_dirfstat(int);
  64. int _dirfwstat(int, Dir*);
  65. long _dirread(int, Dir**);
  66. long _dirreadall(int, Dir**);
  67. void _nulldir(Dir*);
  68. uint _sizeD2M(Dir*);
  69. #ifndef nil
  70. #define nil ((void*)0)
  71. #endif