26 vtfilewrite \- 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 type);
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,
89 uchar score[VtScoreSize]);
92 int vtfilelock(VtFile *f, int mode);
95 int vtfilelock2(VtFile *f, VtFile *f, int mode);
98 void vtfileunlock(VtFile *f);
100 These routines provide a simple interface to create and
101 manipulate Venti file trees (see
105 creates a new Venti file.
111 specifying a data or directory file.
113 is the block size to use for leaf (data or directory) blocks in the hash tree;
115 is the block size to use for internal (pointer) blocks.
118 opens an existing Venti file described by
122 opens the Venti file described by the
124 entry in the directory
132 indicating how the returned file is to be used.
137 modes can only be used if
143 creates a new file in the directory
155 Each file has an associated reference count
156 and holds a reference to its parent in the file tree.
158 increments this reference count.
160 decrements the reference count.
161 If there are no other references,
163 releases the reference to
165 parent and then frees the in-memory structure
169 is still accessible by reopening it.
174 from its parent directory.
177 releasing the reference to
179 and potentially freeing the structure.
188 blocks in the file and
199 grows the file as needed and then returns the block.
210 It returns the number of bytes read.
221 It returns the number of bytes written,
223 Writing fewer bytes than requested will only happen
224 if an error is encountered.
227 writes to an in-memory copy of the data blocks
230 instead of writing directly to Venti.
232 writes all copied blocks associated with
236 flushes only those blocks corresponding to data in the file before
243 regularly to avoid filling the block cache with unwritten blocks.
251 returns the length (in bytes) of file
255 sets the length (in bytes) of file
259 returns the length (in directory entries)
264 sets the length (in directory entries)
271 with an entry that can be passed to
278 sets the entry associated with
291 Venti files are locked and unlocked
296 to moderate concurrent access.
297 Only one thread at a time\(emthe one that has the file locked\(emcan
298 read or modify the file.
299 The functions that return files
300 .RI ( vtfilecreateroot ,
305 return them unlocked.
306 When files are passed to any of the functions documented in
307 this manual page, it is the caller's responsibility to ensure that
308 they are already locked.
310 Internally, a file is locked by locking the
311 block that contains its directory entry.
312 When two files in the same
313 directory both need to be locked,
316 It locks both its arguments, taking special care
317 not to deadlock if their entries are stored
318 in the same directory block.
320 .B /sys/src/libventi/file.c
324 .IR venti-client (2),