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