[manual index][section index]

NAME

Venti - access to Venti content-addressed filestore.

SYNOPSIS

include "venti.m";
venti := load Venti Venti->PATH;
Session, Entry, Root: import venti;

init:			fn();

Session: adt {
	new:		fn(fd: ref Sys->FD): ref Session;
	read:		fn(s: self ref Session, score: Venti->Score, etype: int, maxn: int): array of byte;
	write:	fn(s: self ref Session, etype: int, buf: array of byte): (int, Venti->Score);
	sync:	fn(s: self ref Session): int;
};

Score: adt {
	a: array of byte;
	eq:		fn(a: self Score, b: Score): int;
	text:		fn(a: self Score): string;
	parse:	fn(s: string): (int, Score);
	zero:		fn(): Score;
};

Entry: adt {
	new:	fn(psize, dsize, flags: int, size: big, score: Venti->Score): ref Entry;
	pack:	fn(e: self ref Entry): array of byte;
	unpack:	fn(d: array of byte): ref Entry;
};

Root: adt {
	new:	fn(name, rtype: string, score: Venti->Score, blocksize: int, prev: ref Venti->Score): ref Root;
	unpack:	fn(d: array of byte): ref Root;
	pack:	fn(r: self ref Root): array of byte;
};

DESCRIPTION

Venti is a block storage server intended for archival applications. The Venti module provides low-level access to a Venti server. The module assumes that the physical connection to the server has already been established (for example, by dial(2)). On a Venti server, a block is addressed by the SHA1 hash of the contents of that block, known as a score, and represented as a Score adt. Blocks are additionally tagged with a type, facilitating recovery in the event of corruption. A Session represents a session with a Venti server.

s.new(fd)
New performs the initial handshake with the Venti server, returning established Session.
s.read(score,etype,maxn)
Read tries to retrieve the block corresponding to score, and of type etype. The block must be no longer than maxn bytes. Etype is conventionally one of the constants Roottype, Dirtype, Datatype or Pointertype[0-9], where the different Pointertypes represent different depth levels within a Venti tree.
s.write(etype,buf)
Write writes the data in buf to the Venti server. The block will be tagged with type etype. It returns a tuple, say (ok,score); on error, ok is -1, otherwise ok is 0 and score contains the Venti score for the block that has been written.
s.sync()
Sync tells the Venti server to make sure that all data is committed to active storage.

An Entry represents a hash tree stored in Venti.


e.new(psize,dsize,flags,size,score)
Creates a new Entry data structure. Psize and dsize are the sizes of pointer and data blocks. Flags holds bits representing the type of the Entry.

Entryactive tells the entry is valid. If this bit is absent, the Entry should be ignored when it occurs in a Venti directory.

Entrydir means it represents a Venti directory.

Entrydepthmask shifted by Entrydepthshift denotes the depth of the hash tree.

Entryvarblocks denotes the block size is variable, overriding dsize.
e.pack()
Packs an Entry into bytes, ready for being stored to Venti. The result is always Entrysize bytes longs.
e.unpack(d)
Unpacks the Entry represented by d, which should be Entrysize bytes long.

Root represents the root of a file hierarchy stored in Venti.


r.new(name,rtype,score,blocksize,prev)
Creates a new Root data structure. Name is a descriptive name for the file tree. Rtype denotes the type of the archive, currently only vac is known. The maximum size in bytes of these two parameters is 128 bytes. Score is the score of the root directory Blocksize is the block block size used when writing the archive. Prev is the score of the previous version of the archive and may be nil.
r.pack()
Packs a Root into bytes, ready for being stored to Venti. The result is always Rootsize bytes longs.
r.unpack(d)
Unpacks the Root represented by d, which should be Rootsize bytes long.

SOURCE

/appl/lib/venti.b

SEE ALSO

vac(2)

DIAGNOSTICS

Entry.unpack and Root.unpack return nil and set the system error string when encountering badly formed data.

BUGS

Root belongs in vac(2).

VENTI(2) Rev:  Sat May 03 22:49:09 GMT 2008