1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
Venti: module {
PATH: con "/dis/lib/venti.dis";
Scoresize: con 20;
Maxstringsize: con 1000;
Authsize: con 1024; # size of auth group - in bits - must be multiple of 8
Maxfragsize: con 9*1024;
Cryptostrengthnone,
Cryptostrengthauth,
Cryptostrengthweak,
Cryptostrengthstrong: con iota;
Cryptonone,
CryptoSSL3,
CryptoTLS1,
Cryptomax: con iota;
Codecnone,
Codecdeflate,
CodecThwack,
Codecmax: con iota;
Terror, # not used
Rerror,
Tping,
Rping,
Thello,
Rhello,
Tgoodbye,
Rgoodbye, # not used
Tauth0,
Rauth0,
Tauth1,
Rauth1,
Tread,
Rread,
Twrite,
Rwrite,
Tsync,
Rsync,
Tmax: con iota;
# versions
Version01,
Version02: con iota + 1;
# Lump Types
Errtype, # illegal
Roottype,
Dirtype,
Pointertype0,
Pointertype1,
Pointertype2,
Pointertype3,
Pointertype4,
Pointertype5,
Pointertype6,
Pointertype7, # not used
Pointertype8, # not used
Pointertype9, # not used
Datatype,
Maxtype: con iota;
# Dir Entry flags
Entryactive: con (1<<0); # entry is in use
Entrydir: con (1<<1); # a directory
Entrydepthshift: con 2; # shift for pointer depth
Entrydepthmask: con (16r7<<2); # mask for pointer depth
Entrylocal: con (1<<5); # used for local storage: should not be set for venti blocks
Maxlumpsize: con 56 * 1024;
Pointerdepth: con 7;
Entrysize: con 40;
Rootsize: con 300;
Rootversion: con 2;
Maxfilesize: con (big 1 << 48) - big 1;
Vmsg: adt {
istmsg: int;
tid: int;
pick {
Thello =>
version: string;
uid: string;
cryptostrength: int;
cryptos: array of byte;
codecs: array of byte;
Rhello =>
sid: string;
crypto: int;
codec: int;
Tping =>
Rping =>
Tread =>
score: Score;
etype: int;
n: int;
Rread =>
data: array of byte;
Twrite =>
etype: int;
data: array of byte;
Rwrite =>
score: Score;
Tsync =>
Rsync =>
Tgoodbye =>
Rerror =>
e: string;
}
read: fn(fd: ref Sys->FD): (ref Vmsg, string);
unpack: fn(a: array of byte): (int, ref Vmsg);
pack: fn(nil: self ref Vmsg): array of byte;
packedsize: fn(nil: self ref Vmsg): int;
text: fn(nil: self ref Vmsg): string;
};
Root: adt {
version: int;
name: string;
rtype: string;
score: Venti->Score; # to a Dir block
blocksize: int; # maximum block size
prev: Venti->Score; # last root block
};
Entry: adt {
gen: int; # generation number (XXX should be unsigned)
psize: int; # pointer block size
dsize: int; # data block size
depth: int; # unpacked from flags
flags: int;
size: big; # (XXX should be unsigned)
score: Venti->Score;
};
Score: adt {
a: array of byte;
eq: fn(a: self Score, b: Score): int;
text: fn(a: self Score): string;
parse: fn(s: string): (int, Score);
zero: fn(): Score;
};
Session: adt {
fd: ref Sys->FD;
version: string;
new: fn(fd: ref Sys->FD): ref Session;
read: fn(s: self ref Session, score: Venti->Score, etype: int, maxn: int): array of byte;
write: fn(s: self ref Session, etype: int, buf: array of byte): (int, Venti->Score);
sync: fn(s: self ref Session): int;
rpc: fn(s: self ref Session, m: ref Vmsg): (ref Vmsg, string);
};
unpackentry: fn(d: array of byte): ref Entry;
unpackroot: fn(d: array of byte): ref Root;
init: fn();
};
|