changelog shortlog tags branches changeset files revisions annotate raw help

Mercurial > hg > ventivac / module/venti.m

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