VENTI-CLIENT(2)VENTI-CLIENT(2)NAME
vtconnect, vthello, vtread, vtwrite, vtreadpacket, vtwritepacket,
vtsync, vtping, vtrpc, ventidoublechecksha1 - Venti client
SYNOPSIS
#include <u.h>
#include <libc.h>
#include <venti.h>
Packet* vtrpc(VtConn *z, Packet *p)
int vthello(VtConn *z)
int vtconnect(VtConn *z)
int vtread(VtConn *z, uchar score[VtScoreSize],
uint type, uchar *buf, int n)
int vtwrite(VtConn *z, uchar score[VtScoreSize],
uint type, uchar *buf, int n)
Packet* vtreadpacket(VtConn *z, uchar score[VtScoreSize],
uint type, int n)
int vtwritepacket(VtConn *z, uchar score[VtScoreSize],
uint type, Packet *p)
int vtsync(VtConn *z)
int vtping(VtConn *z)
extern int ventidoublechecksha1; /* default 1 */
DESCRIPTION
These routines execute the client side of the venti(6) protocol.
Vtrpc executes a single Venti RPC transaction, sending the request
packet p and then waiting for and returning the response packet. Vtrpc
will set the tag in the packet. Vtrpc frees p, even on error. Vtrpc
is typically called only indirectly, via the functions below.
Vthello executes a hello transaction, setting z->sid to the name used
by the server. Vthello is typically called only indirectly, via vtcon‐
nect.
Vtconnect calls vtversion (see venti-conn(2)) and vthello, in that
order, returning success only if both succeed. This sequence (calling
vtversion and then vthello) must be done before the functions below can
be called.
Vtread reads the block with the given score and type from the server,
stores the returned data in memory at buf, and returns the number of
bytes read. If the server's block has size larger than n, vtread does
not modify buf and returns an error.
Vtwrite writes the n bytes in buf as a block of the given type, setting
score.
Vtreadpacket and vtwritepacket are like vtread and vtwrite but return
or accept the block contents in the form of a Packet. They avoid mak‐
ing a copy of the data.
Vtsync causes the server to flush all pending write requests to disk
before returning.
Vtping executes a ping transaction with the server.
By default, vtread and vtreadpacket check that the SHA1 hash of the
returned data matches the requested score, and vtwrite and
vtwritepacket check that the returned score matches the SHA1 hash of
the written data. Setting ventidoublechecksha1 to zero disables these
extra checks, mainly for benchmarking purposes. Doing so in production
code is not recommended.
These functions can be called from multiple threads or procs simultane‐
ously to issue requests in parallel. Programs that issue requests from
multiple threads in the same proc should start separate procs running
vtsendproc and vtrecvproc as described in venti-conn(2).
SOURCE
/sys/src/libventi
SEE ALSOventi(2), venti-conn(2), venti-packet(2), venti(6)DIAGNOSTICS
Vtrpc and vtpacket return nil on error. The other routines return -1
on error.
Vtwrite returns 0 on success: there are no partial writes.
VENTI-CLIENT(2)