Blob


1 typedef struct VacFs VacFs;
2 typedef struct VacDir VacDir;
3 typedef struct VacFile VacFile;
4 typedef struct VacDirEnum VacDirEnum;
6 /*
7 * Mode bits
8 */
9 enum
10 {
11 ModeOtherExec = (1<<0),
12 ModeOtherWrite = (1<<1),
13 ModeOtherRead = (1<<2),
14 ModeGroupExec = (1<<3),
15 ModeGroupWrite = (1<<4),
16 ModeGroupRead = (1<<5),
17 ModeOwnerExec = (1<<6),
18 ModeOwnerWrite = (1<<7),
19 ModeOwnerRead = (1<<8),
20 ModeSticky = (1<<9),
21 ModeSetUid = (1<<10),
22 ModeSetGid = (1<<11),
23 ModeAppend = (1<<12), /* append only file */
24 ModeExclusive = (1<<13), /* lock file - plan 9 */
25 ModeLink = (1<<14), /* sym link */
26 ModeDir = (1<<15), /* duplicate of DirEntry */
27 ModeHidden = (1<<16), /* MS-DOS */
28 ModeSystem = (1<<17), /* MS-DOS */
29 ModeArchive = (1<<18), /* MS-DOS */
30 ModeTemporary = (1<<19), /* MS-DOS */
31 ModeSnapshot = (1<<20), /* read only snapshot */
32 };
34 enum
35 {
36 MetaMagic = 0x5656fc79,
37 MetaHeaderSize = 12,
38 MetaIndexSize = 4,
39 IndexEntrySize = 8,
40 DirMagic = 0x1c4d9072,
41 };
43 enum
44 {
45 DirPlan9Entry = 1, /* not valid in version >= 9 */
46 DirNTEntry, /* not valid in version >= 9 */
47 DirQidSpaceEntry,
48 DirGenEntry, /* not valid in version >= 9 */
49 };
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 */
61 char *uid; /* owner id */
62 char *gid; /* group id */
63 char *mid; /* last modified by */
64 ulong mtime; /* last modified time */
65 ulong mcount; /* number of modifications: can wrap! */
66 ulong ctime; /* directory entry last changed */
67 ulong atime; /* last time accessed */
68 ulong mode; /* various mode bits */
70 /* plan 9 */
71 int plan9;
72 uvlong p9path;
73 ulong p9version;
75 /* sub space of qid */
76 int qidspace;
77 uvlong qidoffset; /* qid offset */
78 uvlong qidmax; /* qid maximum */
79 };
82 struct VacFs
83 {
84 int ref;
85 uchar score[VtScoreSize];
86 VacFile *root;
87 VtConn *z;
88 int mode;
89 int bsize;
90 uvlong qid;
91 VtCache *cache;
92 };
94 VacFs *vacfsopen(VtConn *z, char *file, int mode, int ncache);
95 VacFs *vacfsopenscore(VtConn *z, u8int *score, int mode, int ncache);
96 VacFs *vacfscreate(VtConn *z, int bsize, int ncache);
97 void vacfsclose(VacFs *fs);
98 int vacfssync(VacFs *fs);
99 int vacfssnapshot(VacFs *fs, char *src, char *dst);
100 int vacfsgetscore(VacFs *fs, u8int *score);
102 /*
103 * other ideas
105 * VacFs *vfsSnapshot(VacFs*, char *src);
106 * int vfsGraft(VacFs*, char *name, VacFs*);
107 */
109 VacFile *vacfsgetroot(VacFs *fs);
110 VacFile *vacfileopen(VacFs *fs, char *path);
111 VacFile *vacfilecreate(VacFile *file, char *elem, ulong perm, char *muid);
112 VacFile *vacfilewalk(VacFile *file, char *elem);
113 int vacfileremove(VacFile *file, char *muid);
114 int vacfileread(VacFile *file, void *buf, int n, vlong offset);
115 int vacfileblockscore(VacFile *file, u32int, u8int*);
116 int vacfilewrite(VacFile *file, void *buf, int n, vlong offset, char *muid);
117 int vacfilereadpacket(VacFile *file, Packet **pp, vlong offset);
118 int vacfilewritepacket(VacFile *file, Packet *p, vlong offset, char *muid);
119 uvlong vacfilegetid(VacFile *file);
120 ulong vacfilegetmcount(VacFile *file);
121 int vacfileisdir(VacFile *file);
122 int vacfileisroot(VacFile *file);
123 int vacfilegetblocksize(VacFile *file, u32int bn, u8int *score);
124 int vacfilegetsize(VacFile *file, uvlong *size);
125 int vacfilegetdir(VacFile *file, VacDir *dir);
126 int vacfilesetdir(VacFile *file, VacDir *dir, char *muid);
127 int vacfilegetvtentry(VacFile *file, VtEntry *entry);
128 VacFile *vacfilegetparent(VacFile *file);
129 int vacfilesync(VacFile*);
130 VacFile *vacfileincref(VacFile*);
131 int vacfiledecref(VacFile*);
133 void vdcleanup(VacDir *dir);
134 void vdcopy(VacDir *dst, VacDir *src);
137 VacDirEnum *vdeopen(VacFile*);
138 int vderead(VacDirEnum*, VacDir *);
139 void vdeclose(VacDirEnum*);