Blob
1 .TH VENTI-FCALL 32 .SH NAME3 VtEntry, VtFcall, VtRoot,4 vtentrypack,5 vtentryunpack,6 vtfcallclear,7 vtfcallfmt,8 vtfcallpack,9 vtfcallunpack,10 vtfromdisktype,11 vttodisktype,12 vtgetstring,13 vtputstring,14 vtrootpack,15 vtrootunpack,16 vtparsescore,17 vtscorefmt \- venti data formats18 .SH SYNOPSIS19 .PP20 .ft L21 #include <u.h>22 .br23 #include <libc.h>24 .br25 #include <venti.h>26 .ta +\w'\fLxxxx'u27 .PP28 .ft L29 .nf30 enum31 {32 VtEntrySize = 40,33 VtRootSize = 300,34 VtScoreSize = 20,35 };36 .PP37 .ft L38 .nf39 typedef struct VtEntry40 {41 ulong gen; /* generation number */42 ushort psize; /* pointer block size */43 ushort dsize; /* data block size */44 uchar type;45 uchar flags;46 uvlong size;47 uchar score[VtScoreSize];48 } VtEntry;49 .PP50 .ft L51 .nf52 typedef struct VtRoot53 {54 char name[128];55 char type[128];56 uchar score[VtScoreSize]; /* to a Dir block */57 ushort blocksize; /* maximum block size */58 uchar prev[VtScoreSize]; /* previous root block */59 } VtRoot;60 .ta +\w'\fLPacket* 'u61 .PP62 .B63 void vtentrypack(VtEntry *e, uchar *buf, int index)64 .br65 .B66 int vtentryunpack(VtEntry *e, uchar *buf, int index)67 .PP68 .B69 Packet* vtfcallpack(VtFcall *f)70 .br71 .B72 int vtfcallunpack(VtFcall *f, Packet *p)73 .PP74 .B75 void vtfcallclear(VtFcall *f)76 .PP77 .B78 uint vttodisktype(uint type)79 .br80 .B81 uint vtfromdisktype(uint type)82 .PP83 .B84 int vtputstring(Packet *p, char *s)85 .br86 .B87 int vtgetstring(Packet *p, char **s)88 .PP89 .B90 void vtrootpack(VtRoot *r, uchar *buf)91 .br92 .B93 int vtrootunpack(VtRoot *r, uchar *buf)94 .PP95 .B96 int vtparsescore(char *s, char **prefix, uchar score[VtScoreSize])97 .PP98 .B99 int vtfcallfmt(Fmt *fmt)100 .B101 int vtscorefmt(Fmt *fmt)102 .SH DESCRIPTION103 These routines convert between C representations of Venti104 structures and serialized representations used on disk and105 on the network.106 .PP107 .I Vtentrypack108 converts a109 .B VtEntry110 structure describing a Venti file111 (see112 .IR venti (7))113 into a 40-byte114 .RB ( VtEntrySize )115 structure at116 .IB buf + index *40 \fR.117 Vtentryunpack118 does the reverse conversion.119 .PP120 .I Vtfcallpack121 converts a122 .B VtFcall123 structure describing a Venti protocol message124 (see125 .IR venti (7))126 into a packet.127 .I Vtfcallunpack128 does the reverse conversion.129 .PP130 The fields in a131 .B VtFcall132 are named after the protocol fields described in133 .IR venti (7),134 except that the135 .B type136 field is renamed137 .BR blocktype .138 The139 .B msgtype140 field holds the one-byte message type:141 .BR VtThello ,142 .BR VtRhello ,143 and so on.144 .PP145 .I Vtfcallclear146 frees the strings147 .IB f ->error \fR,148 .IB f ->version \fR,149 .IB f ->uid \fR,150 .IB f ->sid \fR,151 the buffers152 .IB f ->crypto153 and154 .IB f ->codec \fR,155 and the packet156 .IB f ->data \fR.157 .PP158 The block type enumeration defined in159 .B <venti.h>160 (presented in161 .IR venti (7))162 differs from the one used on disk and in the network163 protocol.164 The disk and network representation uses different165 constants and does not distinguish between166 .BI VtDataType+ n167 and168 .BI VtDirType+ n169 blocks.170 .I Vttodisktype171 converts a172 .B <venti.h>173 enumeration value to the disk value;174 .I vtfromdisktype175 converts a disk value to the enumeration value,176 always using the177 .B VtDirType178 pointers.179 The180 .B VtFcall181 field182 .B blocktype183 is an enumeration value184 .RI ( vtfcallpack185 and186 .I vtfcallunpack187 convert to and from the disk values used in packets188 automatically),189 so most programs will not need to call these functions.190 .PP191 .I Vtputstring192 appends the Venti protocol representation of the string193 .I s194 to the packet195 .IR p .196 .I Vtgetstring197 reads a string from the packet, returning a pointer to a copy198 of the string in199 .BI * s \fR.200 The copy must be freed by the caller.201 These functions are used by202 .I vtfcallpack203 and204 .IR vtfcallunpack ;205 most programs will not need to call them directly.206 .PP207 .I Vtrootpack208 converts a209 .B VtRoot210 structure describing a Venti file tree211 into the 300-byte212 .RB ( VtRootSize )213 buffer pointed to by214 .IR buf .215 .I Vtrootunpack does the reverse conversion.216 .PP217 .I Vtparsescore218 parses the 40-digit hexadecimal string219 .IR s ,220 writing its value221 into222 .IR score .223 If the hexadecimal string is prefixed with224 a text label followed by a colon, a copy of that225 label is returned in226 .BI * prefix \fR.227 If228 .I prefix229 is nil, the label is ignored.230 .PP231 .I Vtfcallfmt232 and233 .I vtscorefmt234 are235 .IR print (3)236 formatters to print237 .B VtFcall238 structures and scores.239 .I Vtfcallfmt240 assumes that241 .I vtscorefmt242 is installed as243 .BR %V .244 .SH SOURCE245 .B \*9/src/libventi246 .SH SEE ALSO247 .IR venti (1),248 .IR venti (3),249 .IR venti (7)250 .SH DIAGNOSTICS251 .IR Vtentrypack ,252 .IR vtfcallpack ,253 .IR vtrootpack ,254 and255 .I vtfcallclear256 cannot fail.257 .PP258 .IR Vtentryunpack ,259 .IR vtrootunpack ,260 .IR vtputstring ,261 .IR vtgetstring ,262 and263 .I vtparsescore264 return 0 on success, \-1 on error.265 .PP266 .I Vtfcallpack267 returns a packet on success, nil on error.268 .PP269 .I Vttodisktype270 and271 .I vtfromdisktype272 return273 .B VtCorruptType274 (255)275 when presented with invalid input.