|
NAMEVtEntry, VtFcall, VtRoot, vtentrypack, vtentryunpack, vtfcallclear, vtfcallfmt, vtfcallpack, vtfcallunpack, vtfromdisktype, vttodisktype, vtgetstring, vtputstring, vtrootpack, vtrootunpack, vtparsescore, vtscorefmt - venti data formatsSYNOPSIS#include <u.h>#include <libc.h> #include <venti.h> enum { VtEntrySize = 40, VtRootSize = 300, VtScoreSize = 20, };
void vtentrypack(VtEntry *e, uchar *buf, int index) Packet* vtfcallpack(VtFcall *f) void vtfcallclear(VtFcall *f) uint vttodisktype(uint type) int vtputstring(Packet *p, char *s) void vtrootpack(VtRoot *r, uchar *buf) int vtparsescore(char *s, char **prefix, uchar score[VtScoreSize]) int vtfcallfmt(Fmt *fmt) int vtscorefmt(Fmt *fmt) DESCRIPTIONThese routines convert between C representations of Venti structures and serialized representations used on disk and on the network.Vtentrypack converts a VtEntry structure describing a Venti file (see into a 40-byte (VtEntrySize) structure at buf+index*40. Vtentryunpack does the reverse conversion. Vtfcallpack converts a VtFcall structure describing a Venti protocol message (see into a packet. Vtfcallunpack does the reverse conversion. The fields in a VtFcall are named after the protocol fields described in except that the type field is renamed blocktype. The msgtype field holds the one-byte message type: VtThello, VtRhello, and so on. Vtfcallclear frees the strings f->error, f->version, f->uid, f->sid, the buffers f->crypto and f->codec, and the packet f->data. The block type enumeration defined in <venti.h> (presented in differs from the one used on disk and in the network protocol. The disk and network representation uses different constants and does not distinguish between VtDataType+n and VtDirType+n blocks. Vttodisktype converts a <venti.h> enumeration value to the disk value; vtfromdisktype converts a disk value to the enumeration value, always using the VtDirType pointers. The VtFcall field blocktype is an enumeration value (vtfcallpack and vtfcallunpack convert to and from the disk values used in packets automatically), so most programs will not need to call these functions. Vtputstring appends the Venti protocol representation of the string s to the packet p. Vtgetstring reads a string from the packet, returning a pointer to a copy of the string in *s. The copy must be freed by the caller. These functions are used by vtfcallpack and vtfcallunpack; most programs will not need to call them directly. Vtrootpack converts a VtRoot structure describing a Venti file tree into the 300-byte (VtRootSize) buffer pointed to by buf. Vtrootunpack does the reverse conversion. Vtparsescore parses the 40-digit hexadecimal string s, writing its value into score. If the hexadecimal string is prefixed with a text label followed by a colon, a copy of that label is returned in *prefix. If prefix is nil, the label is ignored. Vtfcallfmt and vtscorefmt are formatters to print VtFcall structures and scores. Vtfcallfmt assumes that vtscorefmt is installed as %V. SOURCE/src/libventiSEE ALSODIAGNOSTICSVtentrypack, vtfcallpack, vtrootpack, and vtfcallclear cannot fail.Vtentryunpack, vtrootunpack, vtputstring, vtgetstring, and vtparsescore return 0 on success, -1 on error. Vtfcallpack returns a packet on success, nil on error. Vttodisktype and vtfromdisktype return VtCorruptType (255) when presented with invalid input. Visit the GSP FreeBSD Man Page Interface. |