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 ModeOtherExec = (1<<0),
11 ModeOtherWrite = (1<<1),
12 ModeOtherRead = (1<<2),
13 ModeGroupExec = (1<<3),
14 ModeGroupWrite = (1<<4),
15 ModeGroupRead = (1<<5),
16 ModeOwnerExec = (1<<6),
17 ModeOwnerWrite = (1<<7),
18 ModeOwnerRead = (1<<8),
19 ModeSticky = (1<<9),
20 ModeSetUid = (1<<10),
21 ModeSetGid = (1<<11),
22 ModeAppend = (1<<12), /* append only file */
23 ModeExclusive = (1<<13), /* lock file - plan 9 */
24 ModeLink = (1<<14), /* sym link */
25 ModeDir = (1<<15), /* duplicate of DirEntry */
26 ModeHidden = (1<<16), /* MS-DOS */
27 ModeSystem = (1<<17), /* MS-DOS */
28 ModeArchive = (1<<18), /* MS-DOS */
29 ModeTemporary = (1<<19), /* MS-DOS */
30 ModeSnapshot = (1<<20), /* read only snapshot */
31 };
33 enum {
34 MetaMagic = 0x5656fc79,
35 MetaHeaderSize = 12,
36 MetaIndexSize = 4,
37 IndexEntrySize = 8,
38 DirMagic = 0x1c4d9072,
39 };
41 enum {
42 DirPlan9Entry = 1, /* not valid in version >= 9 */
43 DirNTEntry, /* not valid in version >= 9 */
44 DirQidSpaceEntry,
45 DirGenEntry, /* not valid in version >= 9 */
46 };
48 struct VacDir {
49 char *elem; /* path element */
50 ulong entry; /* entry in directory for data */
51 ulong gen; /* generation of data entry */
52 ulong mentry; /* entry in directory for meta */
53 ulong mgen; /* generation of meta entry */
54 uvlong size; /* size of file */
55 uvlong qid; /* unique file id */
57 char *uid; /* owner id */
58 char *gid; /* group id */
59 char *mid; /* last modified by */
60 ulong mtime; /* last modified time */
61 ulong mcount; /* number of modifications: can wrap! */
62 ulong ctime; /* directory entry last changed */
63 ulong atime; /* last time accessed */
64 ulong mode; /* various mode bits */
66 /* plan 9 */
67 int plan9;
68 uvlong p9path;
69 ulong p9version;
71 /* sub space of qid */
72 int qidSpace;
73 uvlong qidOffset; /* qid offset */
74 uvlong qidMax; /* qid maximum */
75 };
77 VacFS *vfsOpen(VtSession *z, char *file, int readOnly, long ncache);
78 VacFS *vfsCreate(VtSession *z, int bsize, long ncache);
79 int vfsGetBlockSize(VacFS*);
80 int vfsIsReadOnly(VacFS*);
81 VacFile *vfsGetRoot(VacFS*);
83 long vfsGetCacheSize(VacFS*);
84 int vfsSetCacheSize(VacFS*, long);
85 int vfsSnapshot(VacFS*, char *src, char *dst);
86 int vfsSync(VacFS*);
87 int vfsClose(VacFS*);
88 int vfsGetScore(VacFS*, uchar score[VtScoreSize]);
90 /*
91 * other ideas
92 *
93 * VacFS *vfsSnapshot(VacFS*, char *src);
94 * int vfsGraft(VacFS*, char *name, VacFS*);
95 */
97 VacFile *vfOpen(VacFS*, char *path);
98 VacFile *vfCreate(VacFile*, char *elem, ulong perm, char *user);
99 VacFile *vfWalk(VacFile*, char *elem);
100 int vfRemove(VacFile*, char*);
101 int vfRead(VacFile*, void *, int n, vlong offset);
102 int vfWrite(VacFile*, void *, int n, vlong offset, char *user);
103 int vfReadPacket(VacFile*, Packet**, vlong offset);
104 int vfWritePacket(VacFile*, Packet*, vlong offset, char *user);
105 uvlong vfGetId(VacFile*);
106 ulong vfGetMcount(VacFile*);
107 int vfIsDir(VacFile*);
108 int vfGetBlockScore(VacFile*, ulong bn, uchar score[VtScoreSize]);
109 int vfGetSize(VacFile*, uvlong *size);
110 int vfGetDir(VacFile*, VacDir*);
111 int vfSetDir(VacFile*, VacDir*);
112 int vfGetVtEntry(VacFile*, VtEntry*);
113 VacFile *vfGetParent(VacFile*);
114 int vfSync(VacFile*);
115 VacFile *vfIncRef(VacFile*);
116 void vfDecRef(VacFile*);
117 VacDirEnum *vfDirEnum(VacFile*);
118 int vfIsRoot(VacFile *vf);
120 void vdCleanup(VacDir *dir);
121 void vdCopy(VacDir *dst, VacDir *src);
123 VacDirEnum *vdeOpen(VacFS*, char *path);
124 int vdeRead(VacDirEnum*, VacDir *, int n);
125 void vdeFree(VacDirEnum*);