1Venti: 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: ref Venti->Score; # last root block 128 129 pack: fn(r: self ref Root): array of byte; 130 unpack: fn(d: array of byte): ref Root; 131 }; 132 133 Entry: adt { 134 gen: int; # generation number (XXX should be unsigned) 135 psize: int; # pointer block size 136 dsize: int; # data block size 137 depth: int; # unpacked from flags 138 flags: int; 139 size: big; # (XXX should be unsigned) 140 score: Venti->Score; 141 142 pack: fn(e: self ref Entry): array of byte; 143 unpack: fn(d: array of byte): ref Entry; 144 }; 145 Score: adt { 146 a: array of byte; 147 eq: fn(a: self Score, b: Score): int; 148 text: fn(a: self Score): string; 149 parse: fn(s: string): (int, Score); 150 zero: fn(): Score; 151 }; 152 Session: adt { 153 fd: ref Sys->FD; 154 version: string; 155 156 new: fn(fd: ref Sys->FD): ref Session; 157 read: fn(s: self ref Session, score: Venti->Score, etype: int, maxn: int): array of byte; 158 write: fn(s: self ref Session, etype: int, buf: array of byte): (int, Venti->Score); 159 sync: fn(s: self ref Session): int; 160 rpc: fn(s: self ref Session, m: ref Vmsg): (ref Vmsg, string); 161 }; 162 init: fn(); 163}; 164