26 vtfileremove \- Venti files
28 .ta +\w'\fLVtBlock* 'u
31 VtFile* vtfilecreateroot(VtCache *c, int psize, int dsize, int type);
34 VtFile* vtfileopenroot(VtCache *c, VtEntry *e);
37 VtFile* vtfileopen(VtFile *f, u32int n, int mode);
40 VtFile* vtfilecreate(VtFile *f, int psize, int dsize, int dir);
43 void vtfileincref(VtFile *f);
46 void vtfileclose(VtFile *f);
49 int vtfileremove(VtFile *f);
52 VtBlock* vtfileblock(VtFile *f, u32int n, int mode);
55 long vtfileread(VtFile *f, void *buf, long n, vlong offset);
58 long vtfilewrite(VtFile *f, void *buf, long n, vlong offset);
61 int vtfileflush(VtFile *f);
64 int vtfileflushbefore(VtFile *f, vlong offset);
67 int vtfiletruncate(VtFile *f);
70 uvlong vtfilegetsize(VtFile *f);
73 int vtfilesetsize(VtFile *f, vlong size);
76 u32int vtfilegetdirsize(VtFile *f);
79 int vtfilesetdirsize(VtFile *f, u32int size);
82 int vtfilegetentry(VtFile *f, VtEntry *e);
85 int vtfilesetentry(VtFile *f, VtEntry *e);
88 int vtfileblockscore(VtFile *f, u32int n, uchar score[VtScoreSize]);
91 int vtfilelock(VtFile *f, int mode);
94 int vtfilelock2(VtFile *f, VtFile *f, int mode);
97 void vtfileunlock(VtFile *f);
99 These routines provide a simple interface to create and
100 manipulate Venti file trees (see
104 creates a new Venti file.
110 specifying a data or directory file.
112 is the block size to use for leaf (data or directory) blocks in the hash tree;
114 is the block size to use for intermediate (pointer) blocks.
117 opens an existing Venti file described by
121 opens the Venti file described by the
123 entry in the directory
131 indicating how the returned file is to be used.
136 modes can only be used if
142 creates a new file in the directory
154 Each file has an associated reference count
155 and holds a reference to its parent in the file tree.
157 increments this reference count.
159 decrements the reference count.
160 If there are no other references,
162 releases the reference to
164 parent and then frees the in-memory structure
168 is still accessible by reopening it.
173 from its parent directory.
176 releasing the reference to
178 and potentially freeing the structure.
187 blocks in the file and
198 grows the file as needed and then returns the block.
209 It returns the number of bytes read.
220 It returns the number of bytes written,
222 Writing fewer bytes than requested will only happen
223 if an error is encountered.
226 writes to an in-memory copy of the data blocks
229 instead of writing directly to Venti.
231 writes all copied blocks associated with
235 flushes only those blocks corresponding to data in the file before
242 regularly to avoid filling the block cache with dirty blocks.
250 returns the length (in bytes) of file
254 sets the length (in bytes) of file
258 returns the length (in directory entries)
263 sets the length (in directory entries)
270 with an entry that can be passed to
277 sets the entry associated with
290 Venti files are locked and unlocked
295 to moderate concurrent access.
296 Only one thread at a time\(emthe one that has the file locked\(emcan
297 read or modify the file.
298 The functions that return files
299 .RI ( vtfilecreateroot ,
304 return them unlocked.
305 When files are passed to any of the functions documented in
306 this manual page, it is the caller's responsibility to ensure that
307 they are already locked.
309 Internally, a file is locked by locking the
310 block that contains its directory entry.
311 When two files in the same
312 directory both need to be locked,
315 It locks both its arguments, taking special care
316 not to deadlock if their entries are stored
317 in the same directory block.
319 .B \*9/src/libventi/file.c