VENTI(2)                                                 VENTI(2)

     NAME
          Venti - access to Venti content-addressed filestore.

     SYNOPSIS
          include "venti.m";
          venti := load Venti Venti->PATH;
          Session: import venti;

          init:               fn();
          unpackentry:   fn(d: array of byte): ref Entry;
          unpackroot:    fn(d: array of byte): ref Root;

          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;
          };

     DESCRIPTION
          Venti is a block storage server intended for archival appli-
          cations.  The Venti module provides low-level access to a
          Venti server.  The module assumes that the physical connec-
          tion to the server has already been established (for exam-
          ple, 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 addition-
          ally tagged with a type, facilitating recovery in the event
          of corruption.  A Session represents an 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

     Page 1                       Plan 9             (printed 11/1/24)

     VENTI(2)                                                 VENTI(2)

               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.

     SOURCE
          /appl/lib/venti.b

     BUGS
          to do: Score adt entry packing/unpacking other Vmsgs,
          Session.rpc()?

     Page 2                       Plan 9             (printed 11/1/24)