vac \- read/write venti archives
vac := load Vac Vac->PATH;
Source, Vacdir, Vacfile: import vac;
File, Sink, MSink: import vac;
new: fn(): ref Direntry;
mk: fn(d: Sys->Dir): ref Direntry;
mkdir: fn(de: self ref Direntry): ref Sys->Dir;
pack: fn(de: self ref Direntry): array of byte;
unpack: fn(d: array of byte): ref Direntry;
new: fn(s: ref Venti->Session, e: ref Venti->Entry): ref Source;
get: fn(s: self ref Source, i: big, d: array of byte): int;
oget: fn(s: self ref Source, offset: big): array of byte;
mk: fn(s: ref Source): ref Vacfile;
new: fn(session: ref Venti->Session, e: ref Venti->Entry): ref Vacfile;
read: fn(v: self ref Vacfile, d: array of byte, n: int): int;
seek: fn(v: self ref Vacfile, offset: big): big;
pread: fn(v: self ref Vacfile, d: array of byte, n: int, offset: big): int;
mk: fn(vf: ref Vacfile, ms: ref Source): ref Vacdir;
new: fn(session: ref Venti->Session, e, me: ref Venti->Entry): ref Vacdir;
walk: fn(v: self ref Vacdir, elem: string): ref Direntry;
open: fn(v: self ref Vacdir, de: ref Direntry):
(ref Venti->Entry, ref Venti->Entry);
readdir: fn(v: self ref Vacdir):
rewind: fn(v: self ref Vacdir);
new: fn(s: ref Venti->Session, dtype, dsize, varblocks: int): ref File;
write: fn(f: self ref File, d: array of byte): int;
finish: fn(f: self ref File): ref Venti->Entry;
mkstate: fn(session: ref Venti->Session, e: ref Venti->Entry, varblocks: int): ref File;
new: fn(s: ref Venti->Session, dsize: int): ref Sink;
add: fn(m: self ref Sink, e: ref Venti->Entry): int;
finish: fn(m: self ref Sink): ref Venti->Entry;
new: fn(s: ref Venti->Session, dsize: int): ref MSink;
add: fn(m: self ref MSink, de: ref Direntry): int;
finish: fn(m: self ref MSink): ref Venti->Entry;
blocksread, blockswritten, bytesread, byteswritten: big;
fn(session: ref Venti->Session, score: Venti->Score):
(ref Vacdir, ref Direntry, string);
(string, ref Venti->Score, string);
is a module for reading and writing venti archives.
initialises the module and must be called before any other function.
provide functions for reading venti archives, along with
facilitate writing archives.
is used for both writing and reading and is the vac equivalent of a
.IB Direntry .mk(\fIdir\fP)
.IB Direntry .unpack(\fIdata\fP)
whole blocks of data from the hash tree are read from.
The difference with a plain
.IB s .new(\fIsession\fP,\ \fIentry\fP)
.IB s .get(\fIindex\fP,\ \fIdata\fP)
Read a block from the hash tree into buffer
denotes which data block to read, considering only data blocks (not pointer blocks). The first data block is 0.
This function performs zero-extension and only works on entries that do not have the
.IB s .oget(\fIoffset\fP)
Read a block from the hash tree starting at
The data returned has been zero-extended.
This functions also works on
with with an offset associated with it. It provides the standard functions
.BI Vacfile.new(\fIsession\fP,\ \fIentry\fP) .
These functions always succeed.
represents a directory stored in a venti archive. A venti directory is stored in Venti as two hash trees: one containing Entries representing the (data) contents of files and one containing all meta-information (direntries) for those files. A file in a directory is represented as a
.IB vd .mk(\fIvacfile\fP,\ \fImetasource\fP)
Open a venti directory.
should contain Entries,
should contain Direntries.
.IB vd .new(\fIsession\fP,\ \fIentry\fP,\ \fImetaentry\fP)
Open a venti directory from a
such as those as returned by
.IB vd .walk(\fIelem\fP)
representing the file
is returned when the file does not exist and the system error string set.
.IB vd .open(\fIdirentry\fP)
`Open' the file represented by
The metaentry (second element of the tuple) is
Read files in a directory. The number of direntries returned depends on the block size of the underlying archive.
The first element of the tuple has the number of direntries returned and is < 0 for errors, and 0 when all files have been returned.
Rewind the directory offset to 0. Subsequent reads again return files.
is used for writing files to Venti as hash trees, eventually resulting in an
.IB f .new(\fIsession\fP,\ \fIdtype\fP,\ \fIdsize\fP,\ \fIvarblocks\fP)
Start a new, empty file.
is the type of the data being written, typically
is the data and pointer block size. Constant
is currently defined to 8192.
denotes whether the hash tree should be considered to have a variable block size.
has no meaning for the data block size and is only used for the pointer block size.
.IB f .write(\fIdata\fP)
The data is flushed to venti immediately and considered to be a single data block in the hash tree. Zero-truncation is performed on it.
On failure -1 is returned, on success 0 is returned.
Pointer blocks that have filled up by this write are flushed as well.
Flush all remaining pointer blocks and the top-level
to Venti and return the entry.
.IB f .mkstate(\fIsession\fP,\ \fIentry\fP,\ \fIvarblocks\fP)
This can be used to append data to an already existing file.
is used to write venti directories.
can be added. Note that
Data is only written to the
when a data block has been filled with entries.
.IB s .new(\fIsession\fP,\ \fIdsize\fP)
Make a new, empty directory. The size of the blocks in which entries are stored is
.IB s .add(\fIentry\fP)
Add an entry to the directory.
If a block is filled, it is flushed to Venti.
Flush the underlying file and return the
representing the directory.
of a venti directory. It behaves identical to a
with the difference that function
for the meta-information if the
represents a directory.
are kept up to date during module use.
They contain the total number of blocks and bytes read from and
written to the venti server. Venti protocol overhead is ignored,
only the message payloads are accounted for.
parses a score from the file represented by
The returned tuple contains the type of the score (e.g.
if the score references a
block), the second element is the parsed score itself. The third element describes an error if it is not
opens the top-level directory of a vac archive by the
The tuple returned contains the
containing information about the root directory. The third element describes an error if it is not
The functions unpacking data structures return nil for badly formed data, and set the system error string.