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 ModeDevice = (1<<21), /* Unix device */
33 ModeNamedPipe = (1<<22) /* Unix named pipe */
34 };
36 enum
37 {
38 MetaMagic = 0x5656fc79,
39 MetaHeaderSize = 12,
40 MetaIndexSize = 4,
41 IndexEntrySize = 8,
42 DirMagic = 0x1c4d9072
43 };
45 enum
46 {
47 DirPlan9Entry = 1, /* not valid in version >= 9 */
48 DirNTEntry, /* not valid in version >= 9 */
49 DirQidSpaceEntry,
50 DirGenEntry /* not valid in version >= 9 */
51 };
53 struct VacDir
54 {
55 char *elem; /* path element */
56 ulong entry; /* entry in directory for data */
57 ulong gen; /* generation of data entry */
58 ulong mentry; /* entry in directory for meta */
59 ulong mgen; /* generation of meta entry */
60 uvlong size; /* size of file */
61 uvlong qid; /* unique file id */
63 char *uid; /* owner id */
64 char *gid; /* group id */
65 char *mid; /* last modified by */
66 ulong mtime; /* last modified time */
67 ulong mcount; /* number of modifications: can wrap! */
68 ulong ctime; /* directory entry last changed */
69 ulong atime; /* last time accessed */
70 ulong mode; /* various mode bits */
72 /* plan 9 */
73 int plan9;
74 uvlong p9path;
75 ulong p9version;
77 /* sub space of qid */
78 int qidspace;
79 uvlong qidoffset; /* qid offset */
80 uvlong qidmax; /* qid maximum */
81 };
84 struct VacFs
85 {
86 int ref;
87 uchar score[VtScoreSize];
88 VacFile *root;
89 VtConn *z;
90 int mode;
91 int bsize;
92 uvlong qid;
93 VtCache *cache;
94 };
96 VacFs *vacfsopen(VtConn *z, char *file, int mode, int ncache);
97 VacFs *vacfsopenscore(VtConn *z, u8int *score, int mode, int ncache);
98 VacFs *vacfscreate(VtConn *z, int bsize, int ncache);
99 void vacfsclose(VacFs *fs);
100 int vacfssync(VacFs *fs);
101 int vacfssnapshot(VacFs *fs, char *src, char *dst);
102 int vacfsgetscore(VacFs *fs, u8int *score);
104 /*
105 * other ideas
107 * VacFs *vfsSnapshot(VacFs*, char *src);
108 * int vfsGraft(VacFs*, char *name, VacFs*);
109 */
111 VacFile *vacfsgetroot(VacFs *fs);
112 VacFile *vacfileopen(VacFs *fs, char *path);
113 VacFile *vacfilecreate(VacFile *file, char *elem, ulong perm, char *muid);
114 VacFile *vacfilewalk(VacFile *file, char *elem);
115 int vacfileremove(VacFile *file, char *muid);
116 int vacfileread(VacFile *file, void *buf, int n, vlong offset);
117 int vacfileblockscore(VacFile *file, u32int, u8int*);
118 int vacfilewrite(VacFile *file, void *buf, int n, vlong offset, char *muid);
119 int vacfilereadpacket(VacFile *file, Packet **pp, vlong offset);
120 int vacfilewritepacket(VacFile *file, Packet *p, vlong offset, char *muid);
121 uvlong vacfilegetid(VacFile *file);
122 ulong vacfilegetmcount(VacFile *file);
123 int vacfileisdir(VacFile *file);
124 int vacfileisroot(VacFile *file);
125 ulong vacfilegetmode(VacFile *file);
126 int vacfilegetblocksize(VacFile *file, u32int bn, u8int *score);
127 int vacfilegetsize(VacFile *file, uvlong *size);
128 int vacfilegetdir(VacFile *file, VacDir *dir);
129 int vacfilesetdir(VacFile *file, VacDir *dir, char *muid);
130 int vacfilegetvtentry(VacFile *file, VtEntry *entry);
131 VacFile *vacfilegetparent(VacFile *file);
132 int vacfilesync(VacFile*);
133 VacFile *vacfileincref(VacFile*);
134 int vacfiledecref(VacFile*);
136 void vdcleanup(VacDir *dir);
137 void vdcopy(VacDir *dst, VacDir *src);
140 VacDirEnum *vdeopen(VacFile*);
141 int vderead(VacDirEnum*, VacDir *);
142 void vdeclose(VacDirEnum*);