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 external data representation18 .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 VtRootVersion = 2,35 VtScoreSize = 20,36 };37 .PP38 .ft L39 .nf40 typedef struct VtEntry41 {42 ulong gen; /* generation number */43 ushort psize; /* pointer block size */44 ushort dsize; /* data block size */45 uchar type;46 uchar flags;47 uvlong size;48 uchar score[VtScoreSize];49 } VtEntry;50 .PP51 .ft L52 .nf53 typedef struct VtRoot54 {55 char name[128];56 char type[128];57 uchar score[VtScoreSize]; /* to a Dir block */58 ushort blocksize; /* maximum block size */59 uchar prev[VtScoreSize]; /* previous root block */60 } VtRoot;61 .ta +\w'\fLPacket* 'u62 .PP63 .B64 void vtentrypack(VtEntry *e, uchar *buf, int index)65 .br66 .B67 int vtentryunpack(VtEntry *e, uchar *buf, int index)68 .PP69 .B70 Packet* vtfcallpack(VtFcall *f)71 .br72 .B73 int vtfcallunpack(VtFcall *f, Packet *p)74 .PP75 .B76 void vtfcallclear(VtFcall *f)77 .PP78 .B79 uint vttodisktype(uint type)80 .br81 .B82 uint vtfromdisktype(uint type)83 .PP84 .B85 int vtputstring(Packet *p, char *s)86 .br87 .B88 int vtgetstring(Packet *p, char **s)89 .PP90 .B91 void vtrootpack(VtRoot *r, uchar *buf)92 .br93 .B94 int vtrootunpack(VtRoot *r, uchar *buf)95 .PP96 .B97 int vtparsescore(char *s, char **prefix, uchar score[VtScoreSize])98 .PP99 .B100 int vtfcallfmt(Fmt *fmt)101 .B102 int vtscorefmt(Fmt *fmt)103 .SH DESCRIPTION104 These routines convert between C representations of Venti105 structures and serialized representations used on disk and106 on the network.107 .PP108 .I Vtentrypack109 converts a110 .B VtEntry111 structure describing a Venti file112 (see113 .IR venti (1))114 into a 40-byte115 .RB ( VtEntrySize )116 structure at117 .IB buf + index *40 \fR.118 Vtentryunpack119 does the reverse conversion.120 .PP121 .I Vtfcallpack122 converts a123 .B VtFcall124 structure describing a Venti protocol message125 (see126 .IR venti (7))127 into a packet.128 .I Vtfcallunpack129 does the reverse conversion.130 .PP131 The fields in a132 .B VtFcall133 are named after the protocol fields described in134 .IR venti (7),135 except that the136 .B type137 field is renamed138 .BR blocktype .139 The140 .B msgtype141 field holds the one-byte message type:142 .BR VtThello ,143 .BR VtRhello ,144 and so on.145 .PP146 .I Vtfcallclear147 frees the strings148 .IB f ->error \fR,149 .IB f ->version \fR,150 .IB f ->uid \fR,151 .IB f ->sid \fR,152 the buffers153 .I f ->crypto154 and155 .IB f ->codec \fR,156 and the packet157 .IB f ->data \fR.158 .PP159 The block type enumeration defined in160 .B <venti.h>161 (presented in162 .IR venti (1))163 differs from the one used on disk and in the network164 protocol.165 The disk and network representation uses different166 constants does not distinguish between167 .BI VtDataType+ n168 and169 .BI VtDirType+ n170 blocks.171 .I Vttodisktype172 converts a173 .B <venti.h>174 enumeration value to the disk value;175 .I vtfromdisktype176 converts a disk value to the enumeration value.177 The178 .B VtFcall179 field180 .B blocktype181 is an enumeration value182 .RI ( vtfcallpack183 and184 .I vtfcallunpack185 convert to and from the disk values used in packets186 automatically),187 so most programs will not need to call these functions.188 .PP189 .I Vtputstring190 appends the Venti protocol representation of the string191 .I s192 to the packet193 .IR p .194 .I Vtgetstring195 reads a string from the packet, returning a pointer to a copy196 of the string in197 .BI * s \fR.198 The copy must be freed by the caller.199 These functions are used by200 .I vtfcallpack201 and202 .IR vtfcallunpack ;203 most programs will not need to call them directly.204 .PP205 .I Vtrootpack206 converts a207 .B VtRoot208 structure describing a Venti file tree209 into the 300-byte210 .RB ( VtRootSize )211 buffer pointed to by212 .IR buf .213 .I Vtrootunpack does the reverse conversion.214 .PP215 .I Vtparsescore216 parses the 40-digit hexadecimal string217 .IR s ,218 writing its value219 into220 .IR score .221 If the hexadecimal string is prefixed with222 a text label followed by a colon, a copy of that223 label is returned in224 .BI * prefix \fR.225 If226 .I prefix227 is nil, the label is ignored.228 .PP229 .I Vtfcallfmt230 and231 .I vtscorefmt232 are233 .IR print (3)234 formatters to print235 .B VtFcall236 structures and scores.237 .I Vtfcallfmt238 assumes that239 .I vtscorefmt240 is installed as241 .BR %V .242 .SH SOURCE243 .B \*9/src/libventi244 .SH SEE ALSO245 .IR venti (1),246 .IR venti (3),247 .IR venti (7)248 .SH DIAGNOSTICS249 .IR Vtentrypack ,250 .IR vtfcallpack ,251 .IR vtrootpack ,252 and253 .I vtfcallclear254 cannot fail.255 .PP256 .IR Vtentryunpack ,257 .IR vtrootunpack ,258 .IR vtputstring ,259 .IR vtgetstring ,260 and261 .I vtparsescore262 return 0 on success, \-1 on error.263 .PP264 .I Vtfcallpack265 returns a packet on success, nil on error.266 .PP267 .I Vttodisktype268 and269 .I vtfromdisktype270 return271 .B VtCorruptType272 (255)273 when presented with invalid input.