vac.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. typedef struct VacFs VacFs;
  2. typedef struct VacDir VacDir;
  3. typedef struct VacFile VacFile;
  4. typedef struct VacDirEnum VacDirEnum;
  5. #pragma incomplete VacFile
  6. #pragma incomplete VacDirEnum
  7. /*
  8. * Mode bits
  9. */
  10. enum
  11. {
  12. ModeOtherExec = (1<<0),
  13. ModeOtherWrite = (1<<1),
  14. ModeOtherRead = (1<<2),
  15. ModeGroupExec = (1<<3),
  16. ModeGroupWrite = (1<<4),
  17. ModeGroupRead = (1<<5),
  18. ModeOwnerExec = (1<<6),
  19. ModeOwnerWrite = (1<<7),
  20. ModeOwnerRead = (1<<8),
  21. ModeSticky = (1<<9),
  22. ModeSetUid = (1<<10),
  23. ModeSetGid = (1<<11),
  24. ModeAppend = (1<<12), /* append only file */
  25. ModeExclusive = (1<<13), /* lock file - plan 9 */
  26. ModeLink = (1<<14), /* sym link */
  27. ModeDir = (1<<15), /* duplicate of DirEntry */
  28. ModeHidden = (1<<16), /* MS-DOS */
  29. ModeSystem = (1<<17), /* MS-DOS */
  30. ModeArchive = (1<<18), /* MS-DOS */
  31. ModeTemporary = (1<<19), /* MS-DOS */
  32. ModeSnapshot = (1<<20), /* read only snapshot */
  33. ModeDevice = (1<<21), /* Unix device */
  34. ModeNamedPipe = (1<<22) /* Unix named pipe */
  35. };
  36. enum
  37. {
  38. MetaMagic = 0x5656fc79,
  39. MetaHeaderSize = 12,
  40. MetaIndexSize = 4,
  41. IndexEntrySize = 8,
  42. DirMagic = 0x1c4d9072
  43. };
  44. enum
  45. {
  46. DirPlan9Entry = 1, /* not valid in version >= 9 */
  47. DirNTEntry, /* not valid in version >= 9 */
  48. DirQidSpaceEntry,
  49. DirGenEntry /* not valid in version >= 9 */
  50. };
  51. struct VacDir
  52. {
  53. char *elem; /* path element */
  54. ulong entry; /* entry in directory for data */
  55. ulong gen; /* generation of data entry */
  56. ulong mentry; /* entry in directory for meta */
  57. ulong mgen; /* generation of meta entry */
  58. uvlong size; /* size of file */
  59. uvlong qid; /* unique file id */
  60. char *uid; /* owner id */
  61. char *gid; /* group id */
  62. char *mid; /* last modified by */
  63. ulong mtime; /* last modified time */
  64. ulong mcount; /* number of modifications: can wrap! */
  65. ulong ctime; /* directory entry last changed */
  66. ulong atime; /* last time accessed */
  67. ulong mode; /* various mode bits */
  68. /* plan 9 */
  69. int plan9;
  70. uvlong p9path;
  71. ulong p9version;
  72. /* sub space of qid */
  73. int qidspace;
  74. uvlong qidoffset; /* qid offset */
  75. uvlong qidmax; /* qid maximum */
  76. };
  77. struct VacFs
  78. {
  79. char name[128];
  80. uchar score[VtScoreSize];
  81. VacFile *root;
  82. VtConn *z;
  83. int mode;
  84. int bsize;
  85. uvlong qid;
  86. VtCache *cache;
  87. };
  88. VacFs *vacfsopen(VtConn *z, char *file, int mode, int ncache);
  89. VacFs *vacfsopenscore(VtConn *z, u8int *score, int mode, int ncache);
  90. VacFs *vacfscreate(VtConn *z, int bsize, int ncache);
  91. void vacfsclose(VacFs *fs);
  92. int vacfssync(VacFs *fs);
  93. int vacfssnapshot(VacFs *fs, char *src, char *dst);
  94. int vacfsgetscore(VacFs *fs, u8int *score);
  95. int vacfsgetmaxqid(VacFs*, uvlong*);
  96. void vacfsjumpqid(VacFs*, uvlong);
  97. VacFile *vacfsgetroot(VacFs *fs);
  98. VacFile *vacfileopen(VacFs *fs, char *path);
  99. VacFile *vacfilecreate(VacFile *file, char *elem, ulong perm);
  100. VacFile *vacfilewalk(VacFile *file, char *elem);
  101. int vacfileremove(VacFile *file);
  102. int vacfileread(VacFile *file, void *buf, int n, vlong offset);
  103. int vacfileblockscore(VacFile *file, u32int, u8int*);
  104. int vacfilewrite(VacFile *file, void *buf, int n, vlong offset);
  105. uvlong vacfilegetid(VacFile *file);
  106. ulong vacfilegetmcount(VacFile *file);
  107. int vacfileisdir(VacFile *file);
  108. int vacfileisroot(VacFile *file);
  109. ulong vacfilegetmode(VacFile *file);
  110. int vacfilegetsize(VacFile *file, uvlong *size);
  111. int vacfilegetdir(VacFile *file, VacDir *dir);
  112. int vacfilesetdir(VacFile *file, VacDir *dir);
  113. VacFile *vacfilegetparent(VacFile *file);
  114. int vacfileflush(VacFile*, int);
  115. VacFile *vacfileincref(VacFile*);
  116. int vacfiledecref(VacFile*);
  117. int vacfilesetsize(VacFile *f, uvlong size);
  118. int vacfilegetentries(VacFile *f, VtEntry *e, VtEntry *me);
  119. int vacfilesetentries(VacFile *f, VtEntry *e, VtEntry *me);
  120. void vdcleanup(VacDir *dir);
  121. void vdcopy(VacDir *dst, VacDir *src);
  122. int vacfilesetqidspace(VacFile*, u64int, u64int);
  123. uvlong vacfilegetqidoffset(VacFile*);
  124. VacDirEnum *vdeopen(VacFile*);
  125. int vderead(VacDirEnum*, VacDir *);
  126. void vdeclose(VacDirEnum*);
  127. int vdeunread(VacDirEnum*);