VENTI-FCALL(3)
π¦ NAME (aka who's who in this fic)
Bestie, gather round, because this page is the whole cast of venti data formats: VtEntry, VtFcall, VtRoot, vtentrypack, vtentryunpack, vtfcallclear, vtfcallfmt, vtfcallpack, vtfcallunpack, vtfromdisktype, vttodisktype, vtgetstring, vtputstring, vtrootpack, vtrootunpack, vtparsescore, vtscorefmt β literally all of them, under one roof.
This is VENTI-FCALL(3), from the Library Functions Manual, and it's giving "backstage pass to the venti lore." π
β¨ SYNOPSIS β¨
#include <u.h>
#include <libc.h>
#include <venti.h>
enum
{
VtEntrySize = 40,
VtRootSize = 300,
VtScoreSize = 20,
};
typedef struct VtEntry
{
ulong gen; /* generation number */
ushort psize; /* pointer block size */
ushort dsize; /* data block size */
uchar type;
uchar flags;
uvlong size;
uchar score[VtScoreSize];
} VtEntry;
typedef struct VtRoot
{
char name[128];
char type[128];
uchar score[VtScoreSize]; /* to a Dir block */
ushort blocksize; /* maximum block size */
uchar prev[VtScoreSize]; /* previous root block */
} VtRoot;
void vtentrypack(VtEntry *e, uchar *buf, int index)
int vtentryunpack(VtEntry *e, uchar *buf, int index)
Packet* vtfcallpack(VtFcall *f)
int vtfcallunpack(VtFcall *f, Packet *p)
void vtfcallclear(VtFcall *f)
uint vttodisktype(uint type)
uint vtfromdisktype(uint type)
int vtputstring(Packet *p, char *s)
int vtgetstring(Packet *p, char **s)
void vtrootpack(VtRoot *r, uchar *buf)
int vtrootunpack(VtRoot *r, uchar *buf)
int vtparsescore(char *s, char **prefix, uchar score[VtScoreSize])
int vtfcallfmt(Fmt *fmt)
int vtscorefmt(Fmt *fmt)
π DESCRIPTION π
Okay so the whole vibe of these routines: they're the translators between the C version of Venti structures and the serialized version β the one that lives on disk and the one that travels over the network. Glow-up AND passport control, honestly. πβ¨
π Entry packing, the iconique original
vtentrypack takes a VtEntry structure describing a Venti file (peep venti(7)) and converts it into a 40-byte (VtEntrySize) structure written at buf+index*40. vtentryunpack is the reverse conversion β same energy, opposite direction. π«
π§ Fcall packing, protocol edition
vtfcallpack takes a VtFcall structure describing a Venti protocol message (again, venti(7)) and converts it into a packet. vtfcallunpack does the reverse conversion.
The fields in a VtFcall are named after the protocol fields described in venti(7), with one single plot twist: the type field is renamed blocktype. The msgtype field holds the one-byte message type: VtThello, VtRhello, and so on. Not me memorizing the whole cast list π
π vtfcallclear, the cleanup fairy
vtfcallclear frees the strings f->error, f->version, f->uid, f->sid, the buffers f->crypto and f->codec, and the packet f->data. It's the "okay bestie, time to go home" of the group chat. π«Ά
π₯ Block types, the disk-vs-network drama
So the block type enumeration defined in <venti.h> (presented in venti(7)) 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 β lowkey shady of it, but okay.
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. Convenience ate, honestly. π
π Strings, packed and unpacked
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.
Heads up bestie: the copy must be freed by the caller. That's a you problem, not a vtgetstring problem. π«‘
These functions are used by vtfcallpack and vtfcallunpack; most programs will not need to call them directly.
πΈ Root packing, tree edition
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. Main character energy for the whole tree π
β vtparsescore, hex decoder era
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. Slay, flexible queen. π
π Print formatters
vtfcallfmt and vtscorefmt are print(3) formatters to print VtFcall structures and scores. vtfcallfmt assumes that vtscorefmt is installed as %V. It's giving friendship bracelet, they come as a set π
π SOURCE
/src/libventi β that's the home address, no cap.
π¦ SEE ALSO
venti(1), venti(3), venti(7) β the rest of the reading list, iykyk.
π DIAGNOSTICS
vtentrypack,vtfcallpack,vtrootpack, andvtfcallclearcannot fail. Literally built different. β¨vtentryunpack,vtrootunpack,vtputstring,vtgetstring, andvtparsescorereturn0on success,-1on error.vtfcallpackreturns a packet on success,nilon error.vttodisktypeandvtfromdisktypereturnVtCorruptType(255) when presented with invalid input. Garbage in,255out, periodt. π
Okay that's the whole page bestie!! You just read VENTI-FCALL(3) from the Library Functions Manual, living in /src/libventi, and honestly? She ate. ππ«Άβ Remember: pack responsibly, free your strings, and never confuse your block types. Mwah π
π¦ where this page comes from
- alpine 3.24: plan9port-doc 0_git20260208-r0 Β· LPL-1.02
- arch rolling: plan9port 20261021-2 Β· custom
- nixos 26.05: plan9port 0-unstable-2025-11-10
- nixos 26.05: plan9port-wayland 0-unstable-2025-11-26
- nixpkgs unstable: plan9port 0-unstable-2025-11-10
- nixpkgs unstable: plan9port-wayland 0-unstable-2025-11-26
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms