Browse Source

Plan 9 from Bell Labs 2007-10-31

David du Colombier 16 years ago
parent
commit
3a252d6747

+ 2 - 1
adm/timezone/Australia_West

@@ -1,2 +1,3 @@
-WST 28800 WST 32400
+WST 28800 WDT 32400
  152071200  162957600  436327200  447213600  690343200  699415200
+1193536800 1206842400 1224986400 1238292000

+ 29 - 40
dist/replica/_plan9.db

@@ -265,7 +265,7 @@
 386/bin/games/sudoku - 775 sys sys 1179372090 171015
 386/bin/getmap - 775 sys sys 1168402311 65423
 386/bin/gif - 775 sys sys 1179372091 158603
-386/bin/grap - 775 sys sys 1193686113 282795
+386/bin/grap - 775 sys sys 1193771861 282792
 386/bin/graph - 775 sys sys 1168402312 129250
 386/bin/grep - 775 sys sys 1168402312 79569
 386/bin/gs - 775 sys sys 1188447224 13278980
@@ -358,8 +358,6 @@
 386/bin/nm - 775 sys sys 1188530182 130190
 386/bin/nntpfs - 775 sys sys 1179372100 165285
 386/bin/ns - 775 sys sys 1168402343 65492
-386/bin/oventi - 20000000775 sys sys 1189138522 0
-386/bin/oventi/copy - 775 sys sys 1189196486 107409
 386/bin/p - 775 sys sys 1168402343 65220
 386/bin/page - 775 sys sys 1191208765 236255
 386/bin/paqfs - 775 sys sys 1188447270 109707
@@ -756,7 +754,7 @@ adm/timezone/Australia_South - 664 adm adm 1020313576 1483
 adm/timezone/Australia_Sturt - 664 adm adm 1020369287 1483
 adm/timezone/Australia_Tasmania - 664 adm adm 1020369287 1516
 adm/timezone/Australia_Victoria - 664 adm adm 1020313576 1483
-adm/timezone/Australia_West - 664 adm adm 1020313576 86
+adm/timezone/Australia_West - 664 adm adm 1193791016 130
 adm/timezone/Australia_Yancowinna - 664 adm adm 1020313576 1483
 adm/timezone/Brazil_Acre - 664 adm adm 1020369287 1133
 adm/timezone/Brazil_DeNoronha - 664 adm adm 1020369287 1131
@@ -6081,6 +6079,7 @@ sys/include/ape/utime.h - 664 sys sys 944948760 259
 sys/include/ar.h - 664 sys sys 1014929061 244
 sys/include/auth.h - 664 sys sys 1091904428 3439
 sys/include/authsrv.h - 664 sys sys 1171690216 4853
+sys/include/avl.h - 664 sys sys 1193775454 606
 sys/include/bin.h - 664 sys sys 1091904425 239
 sys/include/bio.h - 664 sys sys 1014929062 1854
 sys/include/bootexec.h - 664 sys sys 1089314125 2610
@@ -7439,7 +7438,7 @@ sys/man/1/ns - 664 sys sys 1163208505 895
 sys/man/1/p - 664 sys sys 944959673 504
 sys/man/1/page - 664 sys sys 1087829646 5839
 sys/man/1/passwd - 664 sys sys 1191473503 1543
-sys/man/1/patch - 664 sys sys 1190830651 2566
+sys/man/1/patch - 664 sys sys 1193789230 2588
 sys/man/1/pcc - 664 sys sys 1015024740 3478
 sys/man/1/pic - 664 sys sys 1022625353 8229
 sys/man/1/pipefile - 664 sys sys 984709628 1861
@@ -7493,7 +7492,7 @@ sys/man/1/uniq - 664 sys sys 944959674 995
 sys/man/1/units - 664 sys sys 1113743326 2046
 sys/man/1/uptime - 664 sys sys 1074733782 380
 sys/man/1/vac - 664 sys sys 1162102172 3244
-sys/man/1/venti - 664 sys sys 1190066650 2655
+sys/man/1/venti - 664 sys sys 1193773456 2355
 sys/man/1/vi - 664 sys sys 1101668051 2904
 sys/man/1/vnc - 664 sys sys 1158063994 4313
 sys/man/1/vt - 664 sys sys 1186695303 2424
@@ -7523,9 +7522,10 @@ sys/man/2/assert - 664 sys sys 1102868467 377
 sys/man/2/atof - 664 sys sys 1171668702 2778
 sys/man/2/auth - 664 sys sys 1190243345 7537
 sys/man/2/authsrv - 664 sys sys 1192737581 4583
+sys/man/2/avl - 664 sys sys 1193785216 1936
 sys/man/2/bin - 664 sys sys 985023077 1880
 sys/man/2/bind - 664 sys sys 1015091518 4685
-sys/man/2/bio - 664 sys sys 1192742374 6648
+sys/man/2/bio - 664 sys sys 1193790665 6707
 sys/man/2/blowfish - 664 sys sys 1032058672 1280
 sys/man/2/brk - 664 sys sys 944959694 1179
 sys/man/2/cachechars - 664 sys sys 1082222350 7061
@@ -7818,7 +7818,7 @@ sys/man/8/apm - 664 sys sys 1017679308 1811
 sys/man/8/auth - 664 sys sys 1191472798 4996
 sys/man/8/boot - 664 sys sys 1188515985 8331
 sys/man/8/booting - 664 sys sys 1015024984 4136
-sys/man/8/cec - 644 sys sys 1193683685 1929
+sys/man/8/cec - 664 sys sys 1193683685 1929
 sys/man/8/cpurc - 664 sys sys 1187227584 1522
 sys/man/8/cron - 664 sys sys 1063858596 1867
 sys/man/8/dhcpd - 664 sys sys 1191306105 5575
@@ -10001,14 +10001,14 @@ sys/src/cmd/cdfs/main.c - 664 sys sys 1017679316 11040
 sys/src/cmd/cdfs/mkfile - 664 sys sys 959922196 182
 sys/src/cmd/cdfs/mmc.c - 664 sys sys 1146318348 17198
 sys/src/cmd/cec - 20000000775 sys sys 1193683647 0
-sys/src/cmd/cec/LICENSE - 644 sys sys 1186248056 1554
+sys/src/cmd/cec/LICENSE - 664 sys sys 1186248056 1554
 sys/src/cmd/cec/Protocol - 664 sys sys 1186248056 2881
-sys/src/cmd/cec/cec.c - 644 sys sys 1193683596 6829
-sys/src/cmd/cec/cec.h - 644 sys sys 1193681095 537
-sys/src/cmd/cec/mkfile - 644 sys sys 1193683556 131
+sys/src/cmd/cec/cec.c - 664 sys sys 1193683596 6829
+sys/src/cmd/cec/cec.h - 664 sys sys 1193681095 537
+sys/src/cmd/cec/mkfile - 664 sys sys 1193683556 131
 sys/src/cmd/cec/mux.c - 664 sys sys 1193683306 1641
-sys/src/cmd/cec/plan9.c - 644 sys sys 1193683385 1408
-sys/src/cmd/cec/utils.c - 644 sys sys 1193681177 676
+sys/src/cmd/cec/plan9.c - 664 sys sys 1193683385 1408
+sys/src/cmd/cec/utils.c - 664 sys sys 1193681177 676
 sys/src/cmd/cfs - 20000000775 sys sys 1045505024 0
 sys/src/cmd/cfs/bcache.c - 664 sys sys 1172123361 2964
 sys/src/cmd/cfs/bcache.h - 664 sys sys 1014925220 797
@@ -10130,7 +10130,7 @@ sys/src/cmd/cwfs/portdat.h - 664 sys sys 1174716952 15241
 sys/src/cmd/cwfs/portfns.h - 664 sys sys 1174798778 6701
 sys/src/cmd/cwfs/portmkfile - 664 sys sys 1174798711 791
 sys/src/cmd/cwfs/scsi.c - 664 sys sys 1174282908 8865
-sys/src/cmd/cwfs/sub.c - 664 sys sys 1176500092 24371
+sys/src/cmd/cwfs/sub.c - 664 sys sys 1193717342 24472
 sys/src/cmd/cwfs/time.c - 664 sys sys 1171500176 1696
 sys/src/cmd/cwfs/uidgid.c - 664 sys sys 1174717700 9421
 sys/src/cmd/cwfs/wren.c - 664 sys sys 1174458303 2737
@@ -10441,7 +10441,7 @@ sys/src/cmd/grap/frame.c - 664 sys sys 944960999 1572
 sys/src/cmd/grap/grap.h - 664 sys sys 944960999 6090
 sys/src/cmd/grap/grap.y - 664 sys sys 944960999 9292
 sys/src/cmd/grap/grapl.lx - 664 sys sys 944960999 4871
-sys/src/cmd/grap/input.c - 664 sys sys 1193674137 11417
+sys/src/cmd/grap/input.c - 664 sys sys 1193763283 11398
 sys/src/cmd/grap/label.c - 664 sys sys 944960999 3043
 sys/src/cmd/grap/main.c - 664 sys sys 944960999 3399
 sys/src/cmd/grap/misc.c - 664 sys sys 944960999 5081
@@ -12830,19 +12830,6 @@ sys/src/cmd/nfs.c - 664 sys sys 1050068720 31096
 sys/src/cmd/nm.c - 664 sys sys 1148106943 5322
 sys/src/cmd/nntpfs.c - 664 sys sys 1143695271 18860
 sys/src/cmd/ns.c - 664 sys sys 984717934 3558
-sys/src/cmd/oventi - 20000000775 sys sys 1189019154 0
-sys/src/cmd/oventi/README - 664 sys sys 1189018077 63
-sys/src/cmd/oventi/backup.example - 775 sys sys 1045503662 521
-sys/src/cmd/oventi/conf.rc - 775 sys sys 1055707446 1416
-sys/src/cmd/oventi/copy.c - 664 sys sys 1158618728 3713
-sys/src/cmd/oventi/dat.h - 664 sys sys 1128337707 15346
-sys/src/cmd/oventi/dumpvacroots - 775 sys sys 1163468045 571
-sys/src/cmd/oventi/fns.h - 664 sys sys 1055707422 6793
-sys/src/cmd/oventi/mkfile - 664 sys sys 1189182581 255
-sys/src/cmd/oventi/notes - 664 sys sys 1068500911 4032
-sys/src/cmd/oventi/stdinc.h - 664 sys sys 1188621931 140
-sys/src/cmd/oventi/venti.conf - 664 sys sys 1019867537 397
-sys/src/cmd/oventi/wrtape - 775 sys sys 1019678881 555
 sys/src/cmd/p.c - 664 sys sys 1121977162 1504
 sys/src/cmd/page - 20000000775 sys sys 1045606937 0
 sys/src/cmd/page/cache.c - 664 sys sys 1191178341 3160
@@ -14330,9 +14317,9 @@ sys/src/cmd/vc/swt.c - 664 sys sys 1143384791 10367
 sys/src/cmd/vc/txt.c - 664 sys sys 1168702346 22737
 sys/src/cmd/vc/v.out.h - 664 sys sys 1089299165 2630
 sys/src/cmd/venti - 20000000775 sys sys 1068500904 0
-sys/src/cmd/venti/copy.c - 664 sys sys 1189017556 5275
+sys/src/cmd/venti/copy.c - 664 sys sys 1193773646 5198
 sys/src/cmd/venti/devnull.c - 664 sys sys 1177189434 1225
-sys/src/cmd/venti/mkfile - 664 sys sys 1191258765 439
+sys/src/cmd/venti/mkfile - 664 sys sys 1193773294 432
 sys/src/cmd/venti/mkroot.c - 664 sys sys 1177189435 1178
 sys/src/cmd/venti/randtest.c - 664 sys sys 1177189435 5656
 sys/src/cmd/venti/read.c - 664 sys sys 1177189435 1289
@@ -14342,7 +14329,7 @@ sys/src/cmd/venti/root.c - 664 sys sys 1177189435 1329
 sys/src/cmd/venti/srv - 20000000775 sys sys 1189020012 0
 sys/src/cmd/venti/srv/arena.c - 664 sys sys 1191257299 20137
 sys/src/cmd/venti/srv/arenas.c - 664 sys sys 1178160303 8039
-sys/src/cmd/venti/srv/bloom.c - 664 sys sys 1178160303 4529
+sys/src/cmd/venti/srv/bloom.c - 664 sys sys 1193789584 4514
 sys/src/cmd/venti/srv/buildbuck.c - 664 sys sys 1177189435 2837
 sys/src/cmd/venti/srv/buildindex.c - 664 sys sys 1191257306 21645
 sys/src/cmd/venti/srv/checkarenas.c - 664 sys sys 1191257304 2310
@@ -14354,8 +14341,8 @@ sys/src/cmd/venti/srv/conf.rc - 775 sys sys 1189304120 1416
 sys/src/cmd/venti/srv/config.c - 664 sys sys 1191257289 5659
 sys/src/cmd/venti/srv/conv.c - 664 sys sys 1191257291 14072
 sys/src/cmd/venti/srv/dat.h - 664 sys sys 1191257301 19110
-sys/src/cmd/venti/srv/dcache.c - 664 sys sys 1191257300 15583
-sys/src/cmd/venti/srv/disksched.c - 664 sys sys 1142736352 2125
+sys/src/cmd/venti/srv/dcache.c - 664 sys sys 1193791082 15587
+sys/src/cmd/venti/srv/disksched.c - 664 sys sys 1193791117 2127
 sys/src/cmd/venti/srv/dump.c - 664 sys sys 1142736352 1642
 sys/src/cmd/venti/srv/findscore.c - 664 sys sys 1179863768 2195
 sys/src/cmd/venti/srv/fixarenas.c - 664 sys sys 1190076775 40524
@@ -14368,8 +14355,8 @@ sys/src/cmd/venti/srv/graph.c - 664 sys sys 1177189436 4190
 sys/src/cmd/venti/srv/hdisk.c - 664 sys sys 1191257294 16482
 sys/src/cmd/venti/srv/hproc.c - 664 sys sys 1191430754 10333
 sys/src/cmd/venti/srv/httpd.c - 664 sys sys 1191430753 22897
-sys/src/cmd/venti/srv/icache.c - 664 sys sys 1191257303 10676
-sys/src/cmd/venti/srv/icachewrite.c - 664 sys sys 1191257310 7528
+sys/src/cmd/venti/srv/icache.c - 664 sys sys 1193791133 10679
+sys/src/cmd/venti/srv/icachewrite.c - 664 sys sys 1193791073 7532
 sys/src/cmd/venti/srv/ifile.c - 664 sys sys 1189307036 2592
 sys/src/cmd/venti/srv/index.c - 664 sys sys 1191257302 17933
 sys/src/cmd/venti/srv/lump.c - 664 sys sys 1191257295 4947
@@ -14398,12 +14385,12 @@ sys/src/cmd/venti/srv/syncindex0.c - 664 sys sys 1191257309 1951
 sys/src/cmd/venti/srv/trace.c - 664 sys sys 1142736356 709
 sys/src/cmd/venti/srv/unittoull.c - 664 sys sys 1142736356 471
 sys/src/cmd/venti/srv/unwhack.c - 664 sys sys 1142736356 3191
-sys/src/cmd/venti/srv/utils.c - 664 sys sys 1178160305 3755
+sys/src/cmd/venti/srv/utils.c - 664 sys sys 1193791159 3751
 sys/src/cmd/venti/srv/venti.c - 664 sys sys 1191257307 5584
 sys/src/cmd/venti/srv/verifyarena.c - 664 sys sys 1191257292 5776
 sys/src/cmd/venti/srv/whack.c - 664 sys sys 1142736357 6419
 sys/src/cmd/venti/srv/whack.h - 664 sys sys 1142736357 966
-sys/src/cmd/venti/srv/wrarena.c - 664 sys sys 1183678902 4647
+sys/src/cmd/venti/srv/wrarena.c - 664 sys sys 1193789638 4563
 sys/src/cmd/venti/srv/www - 20000000775 sys sys 1189019173 0
 sys/src/cmd/venti/srv/www/stats.html - 664 sys sys 1177190826 869
 sys/src/cmd/venti/srv/www/stats.js - 664 sys sys 1177190826 9427
@@ -14682,6 +14669,9 @@ sys/src/libauthsrv/nvcsum.c - 664 sys sys 1015091654 192
 sys/src/libauthsrv/opasstokey.c - 664 sys sys 1015091654 448
 sys/src/libauthsrv/passtokey.c - 664 sys sys 1143695654 488
 sys/src/libauthsrv/readnvram.c - 664 sys sys 1188416573 10295
+sys/src/libavl - 20000000775 sys sys 1193775561 0
+sys/src/libavl/avl.c - 664 sys sys 1181339688 6448
+sys/src/libavl/mkfile - 664 sys sys 1130789697 193
 sys/src/libbin - 20000000775 sys sys 1045502972 0
 sys/src/libbin/bin.c - 664 sys sys 1135487932 1829
 sys/src/libbin/mkfile - 664 sys sys 1035389776 197
@@ -15736,7 +15726,7 @@ sys/src/libventi/time.c - 664 sys sys 1177189442 497
 sys/src/libventi/version.c - 664 sys sys 1177189442 2174
 sys/src/libventi/zero.c - 664 sys sys 1177189442 899
 sys/src/libventi/zeroscore.c - 664 sys sys 1177189442 248
-sys/src/mkfile - 664 sys sys 1189049203 1017
+sys/src/mkfile - 664 sys sys 1193784248 1026
 sys/src/mkfile.proto - 664 sys sys 1105121349 265
 tmp - 20000000555 sys sys 1020896384 0
 usr - 20000000775 sys sys 953406542 0
@@ -15758,4 +15748,3 @@ usr/glenda/lib/profile - 664 glenda glenda 1105128663 890
 usr/glenda/readme.acme - 664 glenda glenda 1019860628 4753
 usr/glenda/readme.rio - 664 glenda glenda 1019860628 6370
 usr/glenda/tmp - 20000000775 glenda glenda 1018802620 0
-sys/src/cmd/cwfs/sub.c - 664 sys sys 1193717342 24472

+ 28 - 38
dist/replica/plan9.db

@@ -265,7 +265,7 @@
 386/bin/games/sudoku - 775 sys sys 1179372090 171015
 386/bin/getmap - 775 sys sys 1168402311 65423
 386/bin/gif - 775 sys sys 1179372091 158603
-386/bin/grap - 775 sys sys 1193686113 282795
+386/bin/grap - 775 sys sys 1193771861 282792
 386/bin/graph - 775 sys sys 1168402312 129250
 386/bin/grep - 775 sys sys 1168402312 79569
 386/bin/gs - 775 sys sys 1188447224 13278980
@@ -358,8 +358,6 @@
 386/bin/nm - 775 sys sys 1188530182 130190
 386/bin/nntpfs - 775 sys sys 1179372100 165285
 386/bin/ns - 775 sys sys 1168402343 65492
-386/bin/oventi - 20000000775 sys sys 1189138522 0
-386/bin/oventi/copy - 775 sys sys 1189196486 107409
 386/bin/p - 775 sys sys 1168402343 65220
 386/bin/page - 775 sys sys 1191208765 236255
 386/bin/paqfs - 775 sys sys 1188447270 109707
@@ -756,7 +754,7 @@ adm/timezone/Australia_South - 664 adm adm 1020313576 1483
 adm/timezone/Australia_Sturt - 664 adm adm 1020369287 1483
 adm/timezone/Australia_Tasmania - 664 adm adm 1020369287 1516
 adm/timezone/Australia_Victoria - 664 adm adm 1020313576 1483
-adm/timezone/Australia_West - 664 adm adm 1020313576 86
+adm/timezone/Australia_West - 664 adm adm 1193791016 130
 adm/timezone/Australia_Yancowinna - 664 adm adm 1020313576 1483
 adm/timezone/Brazil_Acre - 664 adm adm 1020369287 1133
 adm/timezone/Brazil_DeNoronha - 664 adm adm 1020369287 1131
@@ -6081,6 +6079,7 @@ sys/include/ape/utime.h - 664 sys sys 944948760 259
 sys/include/ar.h - 664 sys sys 1014929061 244
 sys/include/auth.h - 664 sys sys 1091904428 3439
 sys/include/authsrv.h - 664 sys sys 1171690216 4853
+sys/include/avl.h - 664 sys sys 1193775454 606
 sys/include/bin.h - 664 sys sys 1091904425 239
 sys/include/bio.h - 664 sys sys 1014929062 1854
 sys/include/bootexec.h - 664 sys sys 1089314125 2610
@@ -7439,7 +7438,7 @@ sys/man/1/ns - 664 sys sys 1163208505 895
 sys/man/1/p - 664 sys sys 944959673 504
 sys/man/1/page - 664 sys sys 1087829646 5839
 sys/man/1/passwd - 664 sys sys 1191473503 1543
-sys/man/1/patch - 664 sys sys 1190830651 2566
+sys/man/1/patch - 664 sys sys 1193789230 2588
 sys/man/1/pcc - 664 sys sys 1015024740 3478
 sys/man/1/pic - 664 sys sys 1022625353 8229
 sys/man/1/pipefile - 664 sys sys 984709628 1861
@@ -7493,7 +7492,7 @@ sys/man/1/uniq - 664 sys sys 944959674 995
 sys/man/1/units - 664 sys sys 1113743326 2046
 sys/man/1/uptime - 664 sys sys 1074733782 380
 sys/man/1/vac - 664 sys sys 1162102172 3244
-sys/man/1/venti - 664 sys sys 1190066650 2655
+sys/man/1/venti - 664 sys sys 1193773456 2355
 sys/man/1/vi - 664 sys sys 1101668051 2904
 sys/man/1/vnc - 664 sys sys 1158063994 4313
 sys/man/1/vt - 664 sys sys 1186695303 2424
@@ -7523,9 +7522,10 @@ sys/man/2/assert - 664 sys sys 1102868467 377
 sys/man/2/atof - 664 sys sys 1171668702 2778
 sys/man/2/auth - 664 sys sys 1190243345 7537
 sys/man/2/authsrv - 664 sys sys 1192737581 4583
+sys/man/2/avl - 664 sys sys 1193785216 1936
 sys/man/2/bin - 664 sys sys 985023077 1880
 sys/man/2/bind - 664 sys sys 1015091518 4685
-sys/man/2/bio - 664 sys sys 1192742374 6648
+sys/man/2/bio - 664 sys sys 1193790665 6707
 sys/man/2/blowfish - 664 sys sys 1032058672 1280
 sys/man/2/brk - 664 sys sys 944959694 1179
 sys/man/2/cachechars - 664 sys sys 1082222350 7061
@@ -7818,7 +7818,7 @@ sys/man/8/apm - 664 sys sys 1017679308 1811
 sys/man/8/auth - 664 sys sys 1191472798 4996
 sys/man/8/boot - 664 sys sys 1188515985 8331
 sys/man/8/booting - 664 sys sys 1015024984 4136
-sys/man/8/cec - 644 sys sys 1193683685 1929
+sys/man/8/cec - 664 sys sys 1193683685 1929
 sys/man/8/cpurc - 664 sys sys 1187227584 1522
 sys/man/8/cron - 664 sys sys 1063858596 1867
 sys/man/8/dhcpd - 664 sys sys 1191306105 5575
@@ -10001,14 +10001,14 @@ sys/src/cmd/cdfs/main.c - 664 sys sys 1017679316 11040
 sys/src/cmd/cdfs/mkfile - 664 sys sys 959922196 182
 sys/src/cmd/cdfs/mmc.c - 664 sys sys 1146318348 17198
 sys/src/cmd/cec - 20000000775 sys sys 1193683647 0
-sys/src/cmd/cec/LICENSE - 644 sys sys 1186248056 1554
+sys/src/cmd/cec/LICENSE - 664 sys sys 1186248056 1554
 sys/src/cmd/cec/Protocol - 664 sys sys 1186248056 2881
-sys/src/cmd/cec/cec.c - 644 sys sys 1193683596 6829
-sys/src/cmd/cec/cec.h - 644 sys sys 1193681095 537
-sys/src/cmd/cec/mkfile - 644 sys sys 1193683556 131
+sys/src/cmd/cec/cec.c - 664 sys sys 1193683596 6829
+sys/src/cmd/cec/cec.h - 664 sys sys 1193681095 537
+sys/src/cmd/cec/mkfile - 664 sys sys 1193683556 131
 sys/src/cmd/cec/mux.c - 664 sys sys 1193683306 1641
-sys/src/cmd/cec/plan9.c - 644 sys sys 1193683385 1408
-sys/src/cmd/cec/utils.c - 644 sys sys 1193681177 676
+sys/src/cmd/cec/plan9.c - 664 sys sys 1193683385 1408
+sys/src/cmd/cec/utils.c - 664 sys sys 1193681177 676
 sys/src/cmd/cfs - 20000000775 sys sys 1045505024 0
 sys/src/cmd/cfs/bcache.c - 664 sys sys 1172123361 2964
 sys/src/cmd/cfs/bcache.h - 664 sys sys 1014925220 797
@@ -10441,7 +10441,7 @@ sys/src/cmd/grap/frame.c - 664 sys sys 944960999 1572
 sys/src/cmd/grap/grap.h - 664 sys sys 944960999 6090
 sys/src/cmd/grap/grap.y - 664 sys sys 944960999 9292
 sys/src/cmd/grap/grapl.lx - 664 sys sys 944960999 4871
-sys/src/cmd/grap/input.c - 664 sys sys 1193674137 11417
+sys/src/cmd/grap/input.c - 664 sys sys 1193763283 11398
 sys/src/cmd/grap/label.c - 664 sys sys 944960999 3043
 sys/src/cmd/grap/main.c - 664 sys sys 944960999 3399
 sys/src/cmd/grap/misc.c - 664 sys sys 944960999 5081
@@ -12830,19 +12830,6 @@ sys/src/cmd/nfs.c - 664 sys sys 1050068720 31096
 sys/src/cmd/nm.c - 664 sys sys 1148106943 5322
 sys/src/cmd/nntpfs.c - 664 sys sys 1143695271 18860
 sys/src/cmd/ns.c - 664 sys sys 984717934 3558
-sys/src/cmd/oventi - 20000000775 sys sys 1189019154 0
-sys/src/cmd/oventi/README - 664 sys sys 1189018077 63
-sys/src/cmd/oventi/backup.example - 775 sys sys 1045503662 521
-sys/src/cmd/oventi/conf.rc - 775 sys sys 1055707446 1416
-sys/src/cmd/oventi/copy.c - 664 sys sys 1158618728 3713
-sys/src/cmd/oventi/dat.h - 664 sys sys 1128337707 15346
-sys/src/cmd/oventi/dumpvacroots - 775 sys sys 1163468045 571
-sys/src/cmd/oventi/fns.h - 664 sys sys 1055707422 6793
-sys/src/cmd/oventi/mkfile - 664 sys sys 1189182581 255
-sys/src/cmd/oventi/notes - 664 sys sys 1068500911 4032
-sys/src/cmd/oventi/stdinc.h - 664 sys sys 1188621931 140
-sys/src/cmd/oventi/venti.conf - 664 sys sys 1019867537 397
-sys/src/cmd/oventi/wrtape - 775 sys sys 1019678881 555
 sys/src/cmd/p.c - 664 sys sys 1121977162 1504
 sys/src/cmd/page - 20000000775 sys sys 1045606937 0
 sys/src/cmd/page/cache.c - 664 sys sys 1191178341 3160
@@ -14330,9 +14317,9 @@ sys/src/cmd/vc/swt.c - 664 sys sys 1143384791 10367
 sys/src/cmd/vc/txt.c - 664 sys sys 1168702346 22737
 sys/src/cmd/vc/v.out.h - 664 sys sys 1089299165 2630
 sys/src/cmd/venti - 20000000775 sys sys 1068500904 0
-sys/src/cmd/venti/copy.c - 664 sys sys 1189017556 5275
+sys/src/cmd/venti/copy.c - 664 sys sys 1193773646 5198
 sys/src/cmd/venti/devnull.c - 664 sys sys 1177189434 1225
-sys/src/cmd/venti/mkfile - 664 sys sys 1191258765 439
+sys/src/cmd/venti/mkfile - 664 sys sys 1193773294 432
 sys/src/cmd/venti/mkroot.c - 664 sys sys 1177189435 1178
 sys/src/cmd/venti/randtest.c - 664 sys sys 1177189435 5656
 sys/src/cmd/venti/read.c - 664 sys sys 1177189435 1289
@@ -14342,7 +14329,7 @@ sys/src/cmd/venti/root.c - 664 sys sys 1177189435 1329
 sys/src/cmd/venti/srv - 20000000775 sys sys 1189020012 0
 sys/src/cmd/venti/srv/arena.c - 664 sys sys 1191257299 20137
 sys/src/cmd/venti/srv/arenas.c - 664 sys sys 1178160303 8039
-sys/src/cmd/venti/srv/bloom.c - 664 sys sys 1178160303 4529
+sys/src/cmd/venti/srv/bloom.c - 664 sys sys 1193789584 4514
 sys/src/cmd/venti/srv/buildbuck.c - 664 sys sys 1177189435 2837
 sys/src/cmd/venti/srv/buildindex.c - 664 sys sys 1191257306 21645
 sys/src/cmd/venti/srv/checkarenas.c - 664 sys sys 1191257304 2310
@@ -14354,8 +14341,8 @@ sys/src/cmd/venti/srv/conf.rc - 775 sys sys 1189304120 1416
 sys/src/cmd/venti/srv/config.c - 664 sys sys 1191257289 5659
 sys/src/cmd/venti/srv/conv.c - 664 sys sys 1191257291 14072
 sys/src/cmd/venti/srv/dat.h - 664 sys sys 1191257301 19110
-sys/src/cmd/venti/srv/dcache.c - 664 sys sys 1191257300 15583
-sys/src/cmd/venti/srv/disksched.c - 664 sys sys 1142736352 2125
+sys/src/cmd/venti/srv/dcache.c - 664 sys sys 1193791082 15587
+sys/src/cmd/venti/srv/disksched.c - 664 sys sys 1193791117 2127
 sys/src/cmd/venti/srv/dump.c - 664 sys sys 1142736352 1642
 sys/src/cmd/venti/srv/findscore.c - 664 sys sys 1179863768 2195
 sys/src/cmd/venti/srv/fixarenas.c - 664 sys sys 1190076775 40524
@@ -14368,8 +14355,8 @@ sys/src/cmd/venti/srv/graph.c - 664 sys sys 1177189436 4190
 sys/src/cmd/venti/srv/hdisk.c - 664 sys sys 1191257294 16482
 sys/src/cmd/venti/srv/hproc.c - 664 sys sys 1191430754 10333
 sys/src/cmd/venti/srv/httpd.c - 664 sys sys 1191430753 22897
-sys/src/cmd/venti/srv/icache.c - 664 sys sys 1191257303 10676
-sys/src/cmd/venti/srv/icachewrite.c - 664 sys sys 1191257310 7528
+sys/src/cmd/venti/srv/icache.c - 664 sys sys 1193791133 10679
+sys/src/cmd/venti/srv/icachewrite.c - 664 sys sys 1193791073 7532
 sys/src/cmd/venti/srv/ifile.c - 664 sys sys 1189307036 2592
 sys/src/cmd/venti/srv/index.c - 664 sys sys 1191257302 17933
 sys/src/cmd/venti/srv/lump.c - 664 sys sys 1191257295 4947
@@ -14398,12 +14385,12 @@ sys/src/cmd/venti/srv/syncindex0.c - 664 sys sys 1191257309 1951
 sys/src/cmd/venti/srv/trace.c - 664 sys sys 1142736356 709
 sys/src/cmd/venti/srv/unittoull.c - 664 sys sys 1142736356 471
 sys/src/cmd/venti/srv/unwhack.c - 664 sys sys 1142736356 3191
-sys/src/cmd/venti/srv/utils.c - 664 sys sys 1178160305 3755
+sys/src/cmd/venti/srv/utils.c - 664 sys sys 1193791159 3751
 sys/src/cmd/venti/srv/venti.c - 664 sys sys 1191257307 5584
 sys/src/cmd/venti/srv/verifyarena.c - 664 sys sys 1191257292 5776
 sys/src/cmd/venti/srv/whack.c - 664 sys sys 1142736357 6419
 sys/src/cmd/venti/srv/whack.h - 664 sys sys 1142736357 966
-sys/src/cmd/venti/srv/wrarena.c - 664 sys sys 1183678902 4647
+sys/src/cmd/venti/srv/wrarena.c - 664 sys sys 1193789638 4563
 sys/src/cmd/venti/srv/www - 20000000775 sys sys 1189019173 0
 sys/src/cmd/venti/srv/www/stats.html - 664 sys sys 1177190826 869
 sys/src/cmd/venti/srv/www/stats.js - 664 sys sys 1177190826 9427
@@ -14682,6 +14669,9 @@ sys/src/libauthsrv/nvcsum.c - 664 sys sys 1015091654 192
 sys/src/libauthsrv/opasstokey.c - 664 sys sys 1015091654 448
 sys/src/libauthsrv/passtokey.c - 664 sys sys 1143695654 488
 sys/src/libauthsrv/readnvram.c - 664 sys sys 1188416573 10295
+sys/src/libavl - 20000000775 sys sys 1193775561 0
+sys/src/libavl/avl.c - 664 sys sys 1181339688 6448
+sys/src/libavl/mkfile - 664 sys sys 1130789697 193
 sys/src/libbin - 20000000775 sys sys 1045502972 0
 sys/src/libbin/bin.c - 664 sys sys 1135487932 1829
 sys/src/libbin/mkfile - 664 sys sys 1035389776 197
@@ -15736,7 +15726,7 @@ sys/src/libventi/time.c - 664 sys sys 1177189442 497
 sys/src/libventi/version.c - 664 sys sys 1177189442 2174
 sys/src/libventi/zero.c - 664 sys sys 1177189442 899
 sys/src/libventi/zeroscore.c - 664 sys sys 1177189442 248
-sys/src/mkfile - 664 sys sys 1189049203 1017
+sys/src/mkfile - 664 sys sys 1193784248 1026
 sys/src/mkfile.proto - 664 sys sys 1105121349 265
 tmp - 20000000555 sys sys 1020896384 0
 usr - 20000000775 sys sys 953406542 0

+ 43 - 0
dist/replica/plan9.log

@@ -53199,3 +53199,46 @@
 1193715004 1 c 386/bin/disk/fdisk - 775 sys sys 1193714268 104619
 1193715004 2 c 386/bin/disk/prep - 775 sys sys 1193714270 96195
 1193718604 0 c sys/src/cmd/cwfs/sub.c - 664 sys sys 1193717342 24472
+1193754604 0 m sys/man/8/cec - 664 sys sys 1193683685 1929
+1193754604 1 m sys/src/cmd/cec/LICENSE - 664 sys sys 1186248056 1554
+1193754604 2 m sys/src/cmd/cec/cec.c - 664 sys sys 1193683596 6829
+1193754604 3 m sys/src/cmd/cec/cec.h - 664 sys sys 1193681095 537
+1193754604 4 m sys/src/cmd/cec/mkfile - 664 sys sys 1193683556 131
+1193754604 5 m sys/src/cmd/cec/plan9.c - 664 sys sys 1193683385 1408
+1193754604 6 m sys/src/cmd/cec/utils.c - 664 sys sys 1193681177 676
+1193767204 0 c sys/src/cmd/grap/input.c - 664 sys sys 1193763283 11398
+1193772604 0 c 386/bin/grap - 775 sys sys 1193771861 282792
+1193774405 0 c sys/man/1/venti - 664 sys sys 1193773456 2355
+1193774405 1 c sys/src/cmd/venti/copy.c - 664 sys sys 1193773646 5198
+1193774405 2 c sys/src/cmd/venti/mkfile - 664 sys sys 1193773294 432
+1193774405 3 d sys/src/cmd/oventi/wrtape - 775 sys sys 1019678881 0
+1193774405 4 d sys/src/cmd/oventi/venti.conf - 664 sys sys 1019867537 0
+1193774405 5 d sys/src/cmd/oventi/stdinc.h - 664 sys sys 1188621931 0
+1193774405 6 d sys/src/cmd/oventi/notes - 664 sys sys 1068500911 0
+1193774405 7 d sys/src/cmd/oventi/mkfile - 664 sys sys 1189182581 0
+1193774405 8 d sys/src/cmd/oventi/fns.h - 664 sys sys 1055707422 0
+1193774405 9 d sys/src/cmd/oventi/dumpvacroots - 775 sys sys 1163468045 0
+1193774405 10 d sys/src/cmd/oventi/dat.h - 664 sys sys 1128337707 0
+1193774405 11 d sys/src/cmd/oventi/copy.c - 664 sys sys 1158618728 0
+1193774405 12 d sys/src/cmd/oventi/conf.rc - 775 sys sys 1055707446 0
+1193774405 13 d sys/src/cmd/oventi/backup.example - 775 sys sys 1045503662 0
+1193774405 14 d sys/src/cmd/oventi/README - 664 sys sys 1189018077 0
+1193774405 15 d sys/src/cmd/oventi - 20000000775 sys sys 1189019154 0
+1193774405 16 d 386/bin/oventi/copy - 775 sys sys 1189196486 0
+1193774405 17 d 386/bin/oventi - 20000000775 sys sys 1189138522 0
+1193776205 0 a sys/include/avl.h - 664 sys sys 1193775454 606
+1193776205 1 a sys/src/libavl - 20000000775 sys sys 1193775561 0
+1193776205 2 a sys/src/libavl/avl.c - 664 sys sys 1181339688 6448
+1193776205 3 a sys/src/libavl/mkfile - 664 sys sys 1130789697 193
+1193785204 0 a sys/man/2/avl - 664 sys sys 1193785216 1936
+1193785204 1 c sys/src/mkfile - 664 sys sys 1193784248 1026
+1193790605 0 c sys/man/1/patch - 664 sys sys 1193789230 2588
+1193790605 1 c sys/man/2/bio - 664 sys sys 1193790665 6707
+1193790605 2 c sys/src/cmd/venti/srv/bloom.c - 664 sys sys 1193789584 4514
+1193790605 3 c sys/src/cmd/venti/srv/dcache.c - 664 sys sys 1193791082 15587
+1193790605 4 c sys/src/cmd/venti/srv/disksched.c - 664 sys sys 1193791117 2127
+1193790605 5 c sys/src/cmd/venti/srv/icache.c - 664 sys sys 1193791133 10679
+1193790605 6 c sys/src/cmd/venti/srv/icachewrite.c - 664 sys sys 1193791073 7532
+1193790605 7 c sys/src/cmd/venti/srv/utils.c - 664 sys sys 1193791159 3751
+1193790605 8 c sys/src/cmd/venti/srv/wrarena.c - 664 sys sys 1193789638 4563
+1193792404 0 c adm/timezone/Australia_West - 664 adm adm 1193791016 130

+ 25 - 0
sys/include/avl.h

@@ -0,0 +1,25 @@
+#pragma	lib	"libavl.a"
+#pragma src "/sys/src/libavl"
+
+typedef struct Avl	Avl;
+typedef struct Avltree	Avltree;
+typedef struct Avlwalk	Avlwalk;
+
+#pragma incomplete Avltree
+#pragma incomplete Avlwalk
+
+struct Avl
+{
+	Avl	*p;		/* parent */
+	Avl	*n[2];		/* children */
+	int	bal;		/* balance bits */
+};
+
+Avl	*avlnext(Avlwalk *walk);
+Avl	*avlprev(Avlwalk *walk);
+Avlwalk	*avlwalk(Avltree *tree);
+void	deleteavl(Avltree *tree, Avl *key, Avl **oldp);
+void	endwalk(Avlwalk *walk);
+void	insertavl(Avltree *tree, Avl *new, Avl **oldp);
+Avl	*lookupavl(Avltree *tree, Avl *key);
+Avltree	*mkavltree(int(*cmp)(Avl*, Avl*));

+ 3 - 3
sys/man/1/patch

@@ -42,9 +42,9 @@ and is stored in
 .PP
 .I Patch/create
 creates a new patch consisting of the changes to
-the listed files, reading
-a description of the patch from standard input.
-Please provide an explanation of what the change is supposed to do,
+the listed files from the distribution, reading
+a description of the patch from standard input:
+please provide an explanation of what the change is supposed to do,
 some context, and a rationale for the change.
 Test data or pointers to same to verify that the fix works are also welcome.
 The

+ 6 - 23
sys/man/1/venti

@@ -28,13 +28,12 @@ read, write, copy \- simple Venti clients
 .br
 .B venti/copy
 [
-.\" .B -fir
-.B -fq
+.B -fir
+]
+[
+.B -t
+.I type
 ]
-.\" [
-.\" .B -t
-.\" .I type
-.\" ]
 .I srchost
 .I dsthost
 .I score
@@ -111,17 +110,12 @@ to run in `fast' mode,
 assuming that if a block already exists on the
 destination Venti server, all its children also
 exist and need not be checked.
-The
-.B -q
-option suppresses complaints about blocks already on the destination server.
-.
-.ig
 .PP
 The
 .B -i
 and
 .B -r
-option control
+options control
 .IR copy 's
 reaction to errors reading
 from
@@ -144,7 +138,6 @@ option is given,
 replaces pointers to unreadable blocks with
 pointers to the zero block.
 It writes the new root score to standard output.
-..
 .SH SOURCE
 .B /sys/src/cmd/venti
 .br
@@ -158,15 +151,5 @@ It writes the new root score to standard output.
 .IR venti-backup (8),
 .IR venti-fmt (8)
 .SH BUGS
-Currently
-.IR nventi 's
-.I copy
-doesn't seem to copy the block corresponding to
-.IR score
-and possibly others, so the
-.I copy
-described here is from the original
-.IR venti .
-.PP
 There should be programs to read and write
 venti files and directories.

+ 92 - 0
sys/man/2/avl

@@ -0,0 +1,92 @@
+.TH AVL 2
+.SH NAME
+mkavltree, insertavl, lookupavl, deleteavl, avlwalk, avlnext, avlprev, endwalk - AVL tree routines
+.SH SYNOPSIS
+.EX
+#include <u.h>
+#include <libc.h>
+#include <bio.h>
+#include <avl.h>
+
+typedef struct Avl	Avl;
+struct Avl
+{
+	Avl	*p;		/* parent */
+	Avl	*n[2];		/* children */
+	int	bal;		/* balance bits */
+};
+
+Avl	*avlnext(Avlwalk *walk);
+Avl	*avlprev(Avlwalk *walk);
+Avlwalk	*avlwalk(Avltree *tree);
+void	deleteavl(Avltree *tree, Avl *key, Avl **oldp);
+void	endwalk(Avlwalk *walk);
+void	insertavl(Avltree *tree, Avl *new, Avl **oldp);
+Avl	*lookupavl(Avltree *tree, Avl *key);
+Avltree	*mkavltree(int(*cmp)(Avl*, Avl*));
+.EE
+.SH DESCRIPTION
+An AVL tree is a self-balancing binary search tree.
+These routines allow creation and maintenance of in-memory AVL trees.
+.PP
+An empty AVL tree is created by calling
+.I mkavltree
+with a comparison function as argument.
+This function should take two pointers to
+.B Avl
+objects and return -1, 0 or 1 as the first is
+respectively less than,
+equal to, or greater than,
+the second.
+.I Insertavl
+adds a
+.I new
+tree node into
+.IR tree .
+If
+.I oldp
+is non-nil upon return,
+it points to storage for an old node
+with the same key that may now be freed.
+.I Lookupavl
+returns the
+.I tree
+node with
+.IR key .
+.I Deleteavl
+removes the node with
+.I key
+from
+.IR tree .
+.I oldp
+is handled as per
+.IR insertavl .
+.PP
+.I Avlwalk
+returns a pointer to a newly-allocated
+.B Avlwalk
+object.
+.I Endwalk
+frees such an object.
+.I Avlnext
+and
+.I avlprev
+walk the tree associated with
+.IR walk ,
+returning the next
+(respectively, previous)
+tree node in the comparison order
+defined by the comparison function
+associated with the tree associated with
+.IR walk .
+.SH SOURCE
+.B /sys/src/libavl
+.SH SEE ALSO
+G. M. Adelson-Velsky,
+E. M. Landis,
+``An algorithm for the organization of information'',
+Soviet Mathematics, Vol. 3, pp. 1256—1263.
+.SH DIAGNOSTICS
+Functions returning pointers return
+.B nil
+on error.

+ 1 - 1
sys/man/2/bio

@@ -147,7 +147,7 @@ up to and including the first
 .I delim
 character.
 The delimiter character at the end of the line is
-not altered.
+not altered, thus the returned string probably won't be NUL-terminated.
 .I Brdline
 returns a pointer to the start of the line or
 .L 0

+ 1 - 1
sys/src/cmd/grap/input.c

@@ -23,7 +23,7 @@ void pushsrc(int type, char *ptr)	/* new input source */
 		printf("\n%3d ", srcp - src);
 		switch (srcp->type) {
 		case File:
-			printf("push file %s\n", ((Infile *)ptr)->fname);
+			printf("push file %s\n", ptr);
 			break;
 		case Macro:
 			printf("push macro <%s>\n", ptr);

+ 0 - 1
sys/src/cmd/oventi/README

@@ -1 +0,0 @@
-This is the original venti, stripped down to just oventi/copy.

+ 0 - 26
sys/src/cmd/oventi/backup.example

@@ -1,26 +0,0 @@
-#!/bin/rc
-
-rfork e
-cd /usr/rsc
-. bkup.info
-fn x {
-	echo x $*
-	y=$1
-	if(~ $#$y 0){
-		$y=0
-	}
-	echo venti/wrarena -o $2 $3 $$y
-	end=`{venti/wrarena -o $2 $3 $$y | grep '^end offset ' | sed 's/^end offset //'}
-	if(~ $#end 1 && ! ~ $$y $end){
-		$y=$end
-		echo '#' `{date} >>bkup.info
-		whatis $y >>bkup.info
-	}
-}
-hget http://127.1:8000/index | 
-awk '
-/^index=/ { blockSize=0+substr($3, 11); }
-/^arena=/ { arena=substr($1, 7); }
-/^	arena=/ { start=0+substr($5, 2)-blockSize; printf("x %s %d %s\n", arena, start, $3); }
-' |rc
-

+ 0 - 68
sys/src/cmd/oventi/conf.rc

@@ -1,68 +0,0 @@
-#!/bin/rc
-
-# the venti configuration is stored at the 248kB offset in the first index
-# partition and extends for at most 8 kB.
-
-rfork e
-fn usage {
-	echo 'usage: venti/conf [-w] /dev/sdC0/v.arenas' >[1=2]
-	exit usage
-}
-
-wflag=no
-while(! ~ $#* 0 && ~ $1 -* && ! ~ $1 --){
-	switch($1){
-	case -w
-		wflag=yes
-	case *
-		usage
-	}
-	shift
-}
-if(~ $1 --)
-	shift
-
-if(~ $wflag no && ! ~ $#* 1)
-	usage
-if(~ $wflag yes && ! ~ $#* 1 2)
-	usage
-
-disk=$1
-if(! test -f $disk){
-	echo 'unknown disk' $1 >[1=2]
-	exit nodisk
-}
-
-fn sigexit {
-	#rm -f /tmp/venticonf.$pid
-}
-
-if(~ $wflag yes){
-	{echo venti config; cat $2} >/tmp/venticonf.$pid || exit oops
-	if(! test -s /tmp/venticonf.$pid){
-		echo 'config is empty; will not install' >[1=2]
-		exit emptyconfig
-	}
-	if(test `{ls -l /tmp/venticonf.$pid | awk '{print $6}'} -gt 8192){
-		echo 'config is too long; max is a little less than eight kilobytes' >[1=2]
-		exit toolong
-	}
-	dd -quiet 1 -bs 1024 -count 8 -if $disk -iseek 248 \
-		>/tmp/_venticonf.old || exit backup
-	dd -quiet 1 -count 2 </dev/zero >> /tmp/venticonf.$pid || exit dd
-	dd -quiet 1 -bs 1024 -count 8 -if /tmp/venticonf.$pid \
-		-of $disk -trunc 0 -oseek 248 || exit dd2
-	exit 0
-}
-
-dd -quiet 1 -bs 1024 -count 8 -if $disk -iseek 248 |
-	aux/zerotrunc >/tmp/venticonf.$pid
-
-if(! cmp <{sed 1q /tmp/venticonf.$pid} <{echo venti config}){
-	echo 'config has bad header' >[1=2]
-	exit badconfig
-}
-
-sed 1d /tmp/venticonf.$pid
-exit 0
-

+ 0 - 193
sys/src/cmd/oventi/copy.c

@@ -1,193 +0,0 @@
-#include "stdinc.h"
-#include "dat.h"
-#include "fns.h"
-
-static int fast;
-static int quiet;
-
-VtSession *zsrc, *zdst;
-
-void
-usage(void)
-{
-	fprint(2, "usage: copy [-fq] src-host dst-host score [type]\n");
-	exits("usage");
-}
-
-int
-parseScore(uchar *score, char *buf, int n)
-{
-	int i, c;
-
-	memset(score, 0, VtScoreSize);
-
-	if(n < VtScoreSize*2)
-		return 0;
-	for(i=0; i<VtScoreSize*2; i++) {
-		if(buf[i] >= '0' && buf[i] <= '9')
-			c = buf[i] - '0';
-		else if(buf[i] >= 'a' && buf[i] <= 'f')
-			c = buf[i] - 'a' + 10;
-		else if(buf[i] >= 'A' && buf[i] <= 'F')
-			c = buf[i] - 'A' + 10;
-		else {
-			return 0;
-		}
-
-		if((i & 1) == 0)
-			c <<= 4;
-
-		score[i>>1] |= c;
-	}
-	return 1;
-}
-
-void
-walk(uchar score[VtScoreSize], uint type, int base)
-{
-	int i, n, sub;
-	uchar *buf;
-	VtEntry e;
-	VtRoot root;
-
-	if(memcmp(score, vtZeroScore, VtScoreSize) == 0)
-		return;
-
-	buf = vtMemAllocZ(VtMaxLumpSize);
-	if(fast && vtRead(zdst, score, type, buf, VtMaxLumpSize) >= 0){
-		if(!quiet)
-			fprint(2, "%V already exists on dst server; skipping.\n", score);
-		free(buf);
-		return;
-	}
-
-	n = vtRead(zsrc, score, type, buf, VtMaxLumpSize);
-	/*
-	 * we usually see this at the end of a venti/copy of a vac tree:
-	 * warning: could not read block \
-	 * 0000000000000000000000000000000000000000 1: \
-	 * no block with that score exists
-	 * maybe it's harmless.
-	 */
-	if(n < 0){
-		fprint(2, "warning: could not read block %V %d: %R\n",
-			score, type);
-		return;
-	}
-
-	switch(type){
-	case VtRootType:
-		if(!vtRootUnpack(&root, buf)){
-			fprint(2, "warning: could not unpack root in %V %d\n", score, type);
-			break;
-		}
-		walk(root.score, VtDirType, 0);
-		walk(root.prev, VtRootType, 0);
-		break;
-
-	case VtDirType:
-		for(i=0; i<n/VtEntrySize; i++){
-			if(!vtEntryUnpack(&e, buf, i)){
-				fprint(2, "warning: could not unpack entry #%d in %V %d\n", i, score, type);
-				continue;
-			}
-			if(!(e.flags & VtEntryActive))
-				continue;
-			if(e.flags&VtEntryDir)
-				base = VtDirType;
-			else
-				base = VtDataType;
-			if(e.depth == 0)
-				sub = base;
-			else
-				sub = VtPointerType0+e.depth-1;
-			walk(e.score, sub, base);
-		}
-		break;
-
-	case VtDataType:
-		break;
-
-	default:	/* pointers */
-		if(type == VtPointerType0)
-			sub = base;
-		else
-			sub = type-1;
-		for(i=0; i<n; i+=VtScoreSize)
-			if(memcmp(buf+i, vtZeroScore, VtScoreSize) != 0)
-				walk(buf+i, sub, base);
-		break;
-	}
-
-	if(!vtWrite(zdst, score, type, buf, n))
-		fprint(2, "warning: could not write block %V %d: %R\n", score, type);
-	free(buf);
-}
-
-void
-main(int argc, char *argv[])
-{
-	int type, n;
-	uchar score[VtScoreSize];
-	uchar *buf;
-
-	ARGBEGIN{
-	case 'f':
-		fast = 1;
-		break;
-	case 'q':
-		quiet = 1;
-		break;
-	default:
-		usage();
-		break;
-	}ARGEND
-
-	if(argc != 3 && argc != 4)
-		usage();
-
-	vtAttach();
-
-	fmtinstall('V', vtScoreFmt);
-	fmtinstall('R', vtErrFmt);
-
-	if(!parseScore(score, argv[2], strlen(argv[2])))
-		vtFatal("could not parse score: %s", vtGetError());
-
-	buf = vtMemAllocZ(VtMaxLumpSize);
-
-	zsrc = vtDial(argv[0], 0);
-	if(zsrc == nil)
-		vtFatal("could not dial src server: %R");
-	if(!vtConnect(zsrc, 0))
-		sysfatal("vtConnect src: %r");
-
-	zdst = vtDial(argv[1], 0);
-	if(zdst == nil)
-		vtFatal("could not dial dst server: %R");
-	if(!vtConnect(zdst, 0))
-		sysfatal("vtConnect dst: %r");
-
-	if(argc == 4){
-		type = atoi(argv[3]);
-		n = vtRead(zsrc, score, type, buf, VtMaxLumpSize);
-		if(n < 0)
-			vtFatal("could not read block: %R");
-	}else{
-		for(type=0; type<VtMaxType; type++){
-			n = vtRead(zsrc, score, type, buf, VtMaxLumpSize);
-			if(n >= 0)
-				break;
-		}
-		if(type == VtMaxType)
-			vtFatal("could not find block %V of any type", score);
-	}
-
-	walk(score, type, VtDirType);
-
-	if(!vtSync(zdst))
-		vtFatal("could not sync dst server: %R");
-
-	vtDetach();
-	exits(0);
-}

+ 0 - 506
sys/src/cmd/oventi/dat.h

@@ -1,506 +0,0 @@
-typedef struct Config		Config;
-typedef struct AMap		AMap;
-typedef struct AMapN		AMapN;
-typedef struct Arena		Arena;
-typedef struct ArenaHead	ArenaHead;
-typedef struct ArenaPart	ArenaPart;
-typedef struct CIBlock		CIBlock;
-typedef struct Clump		Clump;
-typedef struct ClumpInfo	ClumpInfo;
-typedef struct IAddr		IAddr;
-typedef struct IBucket		IBucket;
-typedef struct IEStream		IEStream;
-typedef struct IEntry		IEntry;
-typedef struct IFile		IFile;
-typedef struct ISect		ISect;
-typedef struct Index		Index;
-typedef struct Lump		Lump;
-typedef struct DBlock		DBlock;
-typedef struct Part		Part;
-typedef struct Stats		Stats;
-typedef struct ZBlock		ZBlock;
-
-#pragma incomplete IEStream
-
-#define TWID32	((u32int)~(u32int)0)
-#define TWID64	((u64int)~(u64int)0)
-#define	TWID8	((u8int)~(u8int)0)
-
-enum
-{
-	ABlockLog		= 9,		/* log2(512), the quantum for reading arenas */
-	ANameSize		= 64,
-	MaxDiskBlock		= 64*1024,	/* max. allowed size for a disk block */
-	MaxIoSize		= 64*1024,	/* max. allowed size for a disk io operation */
-	PartBlank		= 256*1024,	/* untouched section at beginning of partition */
-	HeadSize		= 512,		/* size of a header after PartBlank */
-	MinArenaSize		= 1*1024*1024,	/* smallest reasonable arena size */
-	IndexBase		= 1024*1024,	/* initial address to use in an index */
-	MaxIo			= 64*1024,	/* max size of a single read or write operation */
-	ICacheBits		= 16,		/* default bits for indexing icache */
-	ICacheDepth		= 4,		/* default depth of an icache hash chain */
-	MaxAMap			= 2*1024,	/* max. allowed arenas in an address mapping; must be < 32*1024 */
-
-	/*
-	 * return codes from syncArena
-	 */
-	SyncDataErr	= 1 << 0,		/* problem reading the clump data */
-	SyncCIErr	= 1 << 1,		/* found erroneous clump directory entries */
-	SyncCIZero	= 1 << 2,		/* found unwritten clump directory entries */
-	SyncFixErr	= 1 << 3,		/* error writing fixed data */
-	SyncHeader	= 1 << 4,		/* altered header fields */
-
-	/*
-	 * error severity
-	 */
-	EOk			= 0,		/* error expected in normal operation */
-	EStrange,				/* strange error that should be logged */
-	ECorrupt,				/* corrupted data found in arenas */
-	EICorrupt,				/* corrupted data found in index */
-	EAdmin,					/* should be brought to administrators' attention */
-	ECrash,					/* really bad internal error */
-	EBug,					/* a limitation which should be fixed */
-	EInconsist,				/* inconsistencies between index and arena */
-	EMax,
-
-	/*
-	 * internal disk formats for the venti archival storage system
-	 */
-	/*
-	 * magic numbers on disk
-	 */
-	ClumpMagic		= 0xd15cb10c,	/* clump header */
-	ClumpFreeMagic		= 0,		/* free clump; terminates active clump log */
-
-	ArenaPartMagic		= 0xa9e4a5e7,	/* arena partition header */
-	ArenaMagic		= 0xf2a14ead,	/* arena trailer */
-	ArenaHeadMagic		= 0xd15c4ead,	/* arena header */
-
-	ISectMagic		= 0xd15c5ec7,	/* index header */
-
-	ArenaPartVersion	= 3,
-	ArenaVersion		= 4,
-	IndexVersion		= 1,
-	ISectVersion		= 1,
-
-	/*
-	 * encodings of clumps on disk
-	 */
-	ClumpEErr		= 0,		/* can't happen */
-	ClumpENone,				/* plain */
-	ClumpECompress,				/* compressed */
-	ClumpEMax,
-
-	/*
-	 * marker for corrupted data on disk
-	 */
-	VtTypeCorrupt		= VtMaxType,
-
-	/*
-	 * sizes in bytes on disk
-	 */
-	U8Size			= 1,
-	U16Size			= 2,
-	U32Size			= 4,
-	U64Size			= 8,
-
-	ArenaPartSize		= 4 * U32Size,
-	ArenaSize		= 2 * U64Size + 6 * U32Size + ANameSize + U8Size,
-	ArenaHeadSize		= U64Size + 3 * U32Size + ANameSize,
-	ISectSize		= 7 * U32Size + 2 * ANameSize,
-	ClumpInfoSize		= U8Size + 2 * U16Size + VtScoreSize,
-	ClumpSize		= ClumpInfoSize + U8Size + 3 * U32Size,
-	IBucketSize		= U32Size + U16Size,
-	IEntrySize		= U64Size + U32Size + 2*U16Size + 2*U8Size + VtScoreSize,
-	IEntryTypeOff		= VtScoreSize + U64Size + U32Size + 2 * U16Size,
-
-	MaxClumpBlocks		=  (VtMaxLumpSize + ClumpSize + (1 << ABlockLog) - 1) >> ABlockLog,
-
-	VentiZZZZZZZZ
-};
-
-/*
- * results of parsing and initializing a config file
- */
-struct Config
-{
-	char		*index;			/* name of the index to initialize */
-	int		naparts;		/* arena partitions initialized */
-	ArenaPart	**aparts;
-	int		nsects;			/* index sections initialized */
-	ISect		**sects;
-	u32int		bcmem;
-	u32int		mem;
-	u32int		icmem;
-	int		queueWrites;
-	char		*haddr;
-	char		*vaddr;
-};
-
-/*
- * a Part is the low level interface to files or disks.
- * there are two main types of partitions
- *	arena partitions, which some number of arenas, each in a sub-partition.
- *	index partition, which only have one subpartition.
- */
-struct Part
-{
-	int		fd;			/* rock for accessing the disk */
-	u64int		size;			/* size of the partiton */
-	u32int		blockSize;		/* block size for reads and writes */
-	char		*name;
-};
-
-/*
- * a cached block from the partition
- * yuck -- most of this is internal structure for the cache
- * all other routines should only use data
- */
-struct DBlock
-{
-	u8int	*data;
-
-	Part	*part;			/* partition in which cached */
-	u64int	addr;			/* base address on the partition */
-	u16int	size;			/* amount of data available, not amount allocated; should go away */
-	DBlock	*next;			/* doubly linked hash chains */
-	DBlock	*prev;
-	u32int	heap;			/* index in heap table */
-	u32int	used;			/* last reference times */
-	u32int	used2;
-	u32int	ref;			/* reference count */
-	VtLock	*lock;			/* for access to data only */
-};
-
-/*
- * a cached block from the partition
- * yuck -- most of this is internal structure for the cache
- * all other routines should only use data
- * double yuck -- this is mostly the same as a DBlock
- */
-struct Lump
-{
-	Packet	*data;
-
-	Part	*part;			/* partition in which cached */
-	u8int	score[VtScoreSize];	/* score of packet */
-	u8int	type;			/* type of packet */
-	u16int	size;			/* amount of data allocated to hold packet */
-	Lump	*next;			/* doubly linked hash chains */
-	Lump	*prev;
-	u32int	heap;			/* index in heap table */
-	u32int	used;			/* last reference times */
-	u32int	used2;
-	u32int	ref;			/* reference count */
-	VtLock	*lock;			/* for access to data only */
-};
-
-/*
- * mapping between names and address ranges
- */
-struct AMap
-{
-	u64int		start;
-	u64int		stop;
-	char		name[ANameSize];
-};
-
-/*
- * an AMap along with a length
- */
-struct AMapN
-{
-	int		n;
-	AMap		*map;
-};
-
-/*
- * an ArenaPart is a partition made up of Arenas
- * it exists because most os's don't support many partitions,
- * and we want to have many different Arenas
- */
-struct ArenaPart
-{
-	Part		*part;
-	u64int		size;			/* size of underlying partition, rounded down to blocks */
-	Arena		**arenas;
-	u32int		tabBase;		/* base address of arena table on disk */
-	u32int		tabSize;		/* max. bytes in arena table */
-
-	/*
-	 * fields stored on disk
-	 */
-	u32int		version;
-	u32int		blockSize;		/* "optimal" block size for reads and writes */
-	u32int		arenaBase;		/* base address of first arena */
-
-	/*
-	 * stored in the arena mapping table on disk
-	 */
-	AMap		*map;
-	int		narenas;
-};
-
-/*
- * info about one block in the clump info cache
- */
-struct CIBlock
-{
-	u32int		block;			/* blocks in the directory */
-	int		offset;			/* offsets of one clump in the data */
-	DBlock		*data;
-};
-
-/*
- * an Arena is a log of Clumps, preceeded by an ArenaHeader,
- * and followed by a Arena, each in one disk block.
- * struct on disk is not always up to date, but should be self-consistent.
- * to sync after reboot, follow clumps starting at used until ClumpFreeMagic if found.
- * <struct name="Arena" type="Arena *">
- *	<field name="name" val="s->name" type="AName"/>
- *	<field name="version" val="s->version" type="U32int"/>
- *	<field name="partition" val="s->part->name" type="AName"/>
- *	<field name="blockSize" val="s->blockSize" type="U32int"/>
- *	<field name="start" val="s->base" type="U64int"/>
- *	<field name="stop" val="s->base+2*s->blockSize" type="U64int"/>
- *	<field name="created" val="s->ctime" type="U32int"/>
- *	<field name="modified" val="s->wtime" type="U32int"/>
- *	<field name="sealed" val="s->sealed" type="Sealed"/>
- *	<field name="score" val="s->score" type="Score"/>
- *	<field name="clumps" val="s->clumps" type="U32int"/>
- *	<field name="compressedClumps" val="s->cclumps" type="U32int"/>
- *	<field name="data" val="s->uncsize" type="U64int"/>
- *	<field name="compressedData" val="s->used - s->clumps * ClumpSize" type="U64int"/>
- *	<field name="storage" val="s->used + s->clumps * ClumpInfoSize" type="U64int"/>
- * </struct>
- */
-struct Arena
-{
-	VtLock		*lock;			/* lock for arena fields, writing to disk */
-	Part		*part;			/* partition in which arena lives */
-	int		blockSize;		/* size of block to read or write */
-	u64int		base;			/* base address on disk */
-	u64int		size;			/* total space in the arena */
-	u64int		limit;			/* storage limit for clumps */
-	u8int		score[VtScoreSize];	/* score of the entire sealed & summed arena */
-
-	int		clumpMax;		/* ClumpInfos per block */
-	CIBlock		cib;			/* dirty clump directory block */
-
-	/*
-	 * fields stored on disk
-	 */
-	u32int		version;
-	char		name[ANameSize];	/* text label */
-	u32int		clumps;			/* number of allocated clumps */
-	u32int		cclumps;		/* clumps which are compressed; informational only */
-	u32int		ctime;			/* first time a block was written */
-	u32int		wtime;			/* last time a block was written */
-	u64int		used;			/* number of bytes currently used */
-	u64int		uncsize;		/* total of all clumps's uncsize; informational only */
-	u8int		sealed;			/* arena all filled up? */
-};
-
-/*
- * redundant storage of some fields at the beginning of each arena
- */
-struct ArenaHead
-{
-	u32int		version;
-	char		name[ANameSize];
-	u32int		blockSize;
-	u64int		size;
-};
-
-/*
- * most interesting meta information for a clump.
- * stored in each clump's header and in the Arena's directory,
- * stored in reverse order just prior to the arena trailer
- */
-struct ClumpInfo
-{
-	u8int		type;
-	u16int		size;			/* size of disk data, not including header */
-	u16int		uncsize;		/* size of uncompressed data */
-	u8int		score[VtScoreSize];	/* score of the uncompressed data only */
-};
-
-/*
- * header for an immutable clump of data
- */
-struct Clump
-{
-	ClumpInfo	info;
-	u8int		encoding;
-	u32int		creator;		/* initial client which wrote the block */
-	u32int		time;			/* creation at gmt seconds since 1/1/1970 */
-};
-
-/*
- * index of all clumps according to their score
- * this is just a wrapper to tie together the index sections
- * <struct name="Index" type="Index *">
- *	<field name="name" val="s->name" type="AName"/>
- *	<field name="version" val="s->version" type="U32int"/>
- *	<field name="blockSize" val="s->blockSize" type="U32int"/>
- *	<field name="tabSize" val="s->tabSize" type="U32int"/>
- *	<field name="buckets" val="s->buckets" type="U32int"/>
- *	<field name="buckDiv" val="s->div" type="U32int"/>
- *	<array name="sect" val="&s->smap[i]" elems="s->nsects" type="Amap"/>
- *	<array name="amap" val="&s->amap[i]" elems="s->narenas" type="Amap"/>
- *	<array name="arena" val="s->arenas[i]" elems="s->narenas" type="Arena"/>
- * </struct>
- * <struct name="Amap" type="AMap *">
- *	<field name="name" val="s->name" type="AName"/>
- *	<field name="start" val="s->start" type="U64int"/>
- *	<field name="stop" val="s->stop" type="U64int"/>
- * </struct>
- */
-struct Index
-{
-	u32int		div;			/* divisor for mapping score to bucket */
-	u32int		buckets;		/* last bucket used in disk hash table */
-	u32int		blockSize;
-	u32int		tabSize;		/* max. bytes in index config */
-	int		mapAlloc;		/* first arena to check when adding a lump */
-	Arena		**arenas;		/* arenas in the mapping */
-	ISect		**sects;		/* sections which hold the buckets */
-
-	/*
-	 * fields stored in config file 
-	 */
-	u32int		version;
-	char		name[ANameSize];	/* text label */
-	int		nsects;
-	AMap		*smap;			/* mapping of buckets to index sections */
-	int		narenas;
-	AMap		*amap;			/* mapping from index addesses to arenas */
-};
-
-/*
- * one part of the bucket storage for an index.
- * the index blocks are sequentially allocated
- * across all of the sections.
- */
-struct ISect
-{
-	Part		*part;
-	int		blockLog;		/* log2(blockSize) */
-	int		buckMax;		/* max. entries in a index bucket */
-	u32int		tabBase;		/* base address of index config table on disk */
-	u32int		tabSize;		/* max. bytes in index config */
-
-	/*
-	 * fields stored on disk
-	 */
-	u32int		version;
-	char		name[ANameSize];	/* text label */
-	char		index[ANameSize];	/* index owning the section */
-	u32int		blockSize;		/* size of hash buckets in index */
-	u32int		blockBase;		/* address of start of on disk index table */
-	u32int		blocks;			/* total blocks on disk; some may be unused */
-	u32int		start;			/* first bucket in this section */
-	u32int		stop;			/* limit of buckets in this section */
-};
-
-/*
- * externally interesting part of an IEntry
- */
-struct IAddr
-{
-	u64int		addr;
-	u16int		size;			/* uncompressed size */
-	u8int		type;			/* type of block */
-	u8int		blocks;			/* arena io quanta for Clump + data */
-};
-
-/*
- * entries in the index
- * kept in IBuckets in the disk index table,
- * cached in the memory ICache.
- */
-struct IEntry
-{
-	u8int		score[VtScoreSize];
-	IEntry		*next;			/* next in hash chain */
-	u32int		wtime;			/* last write time */
-	u16int		train;			/* relative train containing the most recent ref; 0 if no ref, 1 if in same car */
-	u8int		rac;			/* read ahead count */
-	IAddr		ia;
-};
-
-/*
- * buckets in the on disk index table
- */
-struct IBucket
-{
-	u16int		n;			/* number of active indices */
-	u32int		next;			/* overflow bucket */
-	u8int		*data;
-};
-
-/*
- * temporary buffers used by individual threads
- */
-struct ZBlock
-{
-	u32int		len;
-	u8int		*data;
-};
-
-/*
- * simple input buffer for a '\0' terminated text file
- */
-struct IFile
-{
-	char		*name;				/* name of the file */
-	ZBlock		*b;				/* entire contents of file */
-	u32int		pos;				/* current position in the file */
-};
-
-/*
- * statistics about the operation of the server
- * mainly for performance monitoring and profiling.
- */
-struct Stats
-{
-	VtLock		*lock;
-	long		lumpWrites;		/* protocol block writes */
-	long		lumpReads;		/* protocol block reads */
-	long		lumpHit;		/* lump cache hit */
-	long		lumpMiss;		/* lump cache miss */
-	long		clumpWrites;		/* clumps to disk */
-	vlong		clumpBWrites;		/* clump data bytes to disk */
-	vlong		clumpBComp;		/* clump bytes compressed */
-	long		clumpReads;		/* clumps from disk */
-	vlong		clumpBReads;		/* clump data bytes from disk */
-	vlong		clumpBUncomp;		/* clump bytes uncompressed */
-	long		ciWrites;		/* clump directory to disk */
-	long		ciReads;		/* clump directory from disk */
-	long		indexWrites;		/* index to disk */
-	long		indexReads;		/* index from disk */
-	long		indexWReads;		/* for writing a new entry */
-	long		indexAReads;		/* for allocating an overflow block */
-	long		diskWrites;		/* total disk writes */
-	long		diskReads;		/* total disk reads */
-	vlong		diskBWrites;		/* total disk bytes written */
-	vlong		diskBReads;		/* total disk bytes read */
-	long		pcHit;			/* partition cache hit */
-	long		pcMiss;			/* partition cache miss */
-	long		pcReads;		/* partition cache reads from disk */
-	vlong		pcBReads;		/* partition cache bytes read */
-	long		icInserts;		/* stores into index cache */
-	long		icLookups;		/* index cache lookups */
-	long		icHits;			/* hits in the cache */
-	long		icFills;		/* successful fills from index */
-};
-
-extern	Index		*mainIndex;
-extern	u32int		maxBlockSize;		/* max. block size used by any partition */
-extern	int		paranoid;		/* should verify hashes on disk read */
-extern	int		queueWrites;		/* put all lump writes on a queue and finish later */
-extern	int		readonly;		/* only allowed to read the disk data */
-extern	Stats		stats;
-extern	u8int		zeroScore[VtScoreSize];
-
-extern	int		chattyzero;

+ 0 - 19
sys/src/cmd/oventi/dumpvacroots

@@ -1,19 +0,0 @@
-#!/bin/rc
-# dumpvacroots - dumps all the vac scores ever stored to the venti server
-# if nothing else, this illustrates that you have to control access
-# to the physical disks storing the archive!
-
-ventihttp=`{echo $venti | sed 's/^[a-z]+!([0-9\.]+)![a-z0-9]+$/\1/
-		s/^[a-z]+!([0-9\.]+)/\1/; s/$/:80/'
-}
-
-hget http://$ventihttp/index | 
-	awk '
- /^index=/ { blockSize=0+substr($3, 11) }
- /^arena=/ { arena=substr($1, 7) }
- /^	arena=/ {
-		start = (0+substr($5, 2))-blockSize
-		printf("venti/printarena -o %.0f %s\n", start, $3 "")
-}' |
-	rc |
-	sed -n 's/^(.*) 1$/vac:\1/p'

+ 0 - 159
sys/src/cmd/oventi/fns.h

@@ -1,159 +0,0 @@
-/*
- * sorted by 4,/^$/|sort -bd +1
- */
-int		addArena(Arena *name);
-ZBlock		*allocZBlock(u32int size, int zeroed);
-Arena		*amapItoA(Index *index, u64int a, u64int *aa);
-u64int		arenaDirSize(Arena *arena, u32int clumps);
-void		arenaUpdate(Arena *arena, u32int size, u8int *score);
-void		backSumArena(Arena *arena);
-u32int		buildBucket(Index *ix, IEStream *ies, IBucket *ib);
-void		checkDCache(void);
-void		checkLumpCache(void);
-int		clumpInfoEq(ClumpInfo *c, ClumpInfo *d);
-int		clumpInfoEq(ClumpInfo *c, ClumpInfo *d);
-u32int		clumpMagic(Arena *arena, u64int aa);
-int		delArena(Arena *arena);
-void		*emalloc(ulong);
-void		*erealloc(void *, ulong);
-char		*estrdup(char*);
-void		*ezmalloc(ulong);
-void		fatal(char *fmt, ...);
-Arena		*findArena(char *name);
-ISect		*findISect(Index *ix, u32int buck);
-int		flushCIBlocks(Arena *arena);
-void		fmtZBInit(Fmt *f, ZBlock *b);
-void		freeArena(Arena *arena);
-void		freeArenaPart(ArenaPart *ap, int freeArenas);
-void		freeIEStream(IEStream *ies);
-void		freeIFile(IFile *f);
-void		freeISect(ISect *is);
-void		freeIndex(Index *index);
-void		freePart(Part *part);
-void		freeZBlock(ZBlock *b);
-DBlock		*getDBlock(Part *part, u64int addr, int read);
-u32int		hashBits(u8int *score, int nbits);
-int		httpdInit(char *address);
-int		iAddrEq(IAddr *ia1, IAddr *ia2);
-int		ientryCmp(void *vie1, void *vie2);
-char		*ifileLine(IFile *f);
-int		ifileName(IFile *f, char *dst);
-int		ifileU32Int(IFile *f, u32int *r);
-int		indexSect(Index *ix, u8int *score);
-Arena		*initArena(Part *part, u64int base, u64int size, u32int blockSize);
-ArenaPart	*initArenaPart(Part *part);
-int		initArenaSum(void);
-void		initDCache(u32int mem);
-void		initICache(int bits, int depth);
-IEStream	*initIEStream(Part *part, u64int off, u64int clumps, u32int size);
-ISect		*initISect(Part *part);
-Index		*initIndex(char *name, ISect **sects, int n);
-void		initLumpCache(u32int size, u32int nblocks);
-int		initLumpQueues(int nq);
-Part*		initPart(char *name, int writable);
-int		initVenti(char *file, Config *conf);
-void		insertLump(Lump *lump, Packet *p);
-int		insertScore(u8int *score, IAddr *ia, int write);
-ZBlock		*loadClump(Arena *arena, u64int aa, int blocks, Clump *cl, u8int *score, int verify);
-int		loadIEntry(Index *index, u8int *score, int type, IEntry *ie);
-void		logErr(int severity, char *fmt, ...);
-Lump		*lookupLump(u8int *score, int type);
-int		lookupScore(u8int *score, int type, IAddr *ia, int *rac);
-int		mapArenas(AMap *am, Arena **arenas, int n, char *what);
-void		nameCp(char *dst, char *src);
-int		nameEq(char *s, char *t);
-int		nameOk(char *name);
-Arena		*newArena(Part *part, char *name, u64int base, u64int size, u32int blockSize);
-ArenaPart	*newArenaPart(Part *part, u32int blockSize, u32int tabSize);
-ISect		*newISect(Part *part, char *name, u32int blockSize, u32int tabSize);
-Index		*newIndex(char *name, ISect **sects, int n);
-u32int		now(void);
-int		okAMap(AMap *am, int n, u64int start, u64int stop, char *what);
-int		outputAMap(Fmt *f, AMap *am, int n);
-int		outputIndex(Fmt *f, Index *ix);
-int		packArena(Arena *arena, u8int *buf);
-int		packArenaHead(ArenaHead *head, u8int *buf);
-int		packArenaPart(ArenaPart *as, u8int *buf);
-int		packClump(Clump *c, u8int *buf);
-void		packClumpInfo(ClumpInfo *ci, u8int *buf);
-void		packIBucket(IBucket *b, u8int *buf);
-void		packIEntry(IEntry *i, u8int *buf);
-int		packISect(ISect *is, u8int *buf);
-void		packMagic(u32int magic, u8int *buf);
-ZBlock		*packet2ZBlock(Packet *p, u32int size);
-int		parseAMap(IFile *f, AMapN *amn);
-int		parseIndex(IFile *f, Index *ix);
-void		partBlockSize(Part *part, u32int blockSize);
-int		partIFile(IFile *f, Part *part, u64int start, u32int size);
-void		printArenaPart(int fd, ArenaPart *ap);
-void		printArena(int fd, Arena *arena);
-void		printIndex(int fd, Index *ix);
-void		printStats(void);
-void		putDBlock(DBlock *b);
-void		putLump(Lump *b);
-void		queueFlush(void);
-int		queueWrite(Lump *b, Packet *p, int creator);
-u32int		readArena(Arena *arena, u64int aa, u8int *buf, long n);
-int		readArenaMap(AMapN *amn, Part *part, u64int base, u32int size);
-int		readClumpInfo(Arena *arena, int clump, ClumpInfo *ci);
-int		readClumpInfos(Arena *arena, int clump, ClumpInfo *cis, int n);
-ZBlock		*readFile(char *name);
-int		readIFile(IFile *f, char *name);
-Packet		*readLump(u8int *score, int type, u32int size);
-int		readPart(Part *part, u64int addr, u8int *buf, u32int n);
-int		runConfig(char *config, Config*);
-int		scoreEq(u8int *, u8int *);
-void		scoreMem(u8int *score, u8int *buf, int size);
-void		setErr(int severity, char *fmt, ...);
-u64int		sortRawIEntries(Index *ix, Part *tmp, u64int *tmpOff);
-void		statsInit(void);
-int		storeClump(Index *index, ZBlock *b, u8int *score, int type, u32int creator, IAddr *ia);
-int		storeIEntry(Index *index, IEntry *m);
-int		strScore(char *s, u8int *score);
-int		strU32Int(char *s, u32int *r);
-int		strU64Int(char *s, u64int *r);
-void		sumArena(Arena *arena);
-int		syncArena(Arena *arena, u32int n, int zok, int fix);
-int		syncArenaIndex(Index *ix, Arena *arena, u32int clump, u64int a, int fix);
-int		syncIndex(Index *ix, int fix);
-int		u64log2(u64int v);
-u64int		unittoull(char *s);
-int		unpackArena(Arena *arena, u8int *buf);
-int		unpackArenaHead(ArenaHead *head, u8int *buf);
-int		unpackArenaPart(ArenaPart *as, u8int *buf);
-int		unpackClump(Clump *c, u8int *buf);
-void		unpackClumpInfo(ClumpInfo *ci, u8int *buf);
-void		unpackIBucket(IBucket *b, u8int *buf);
-void		unpackIEntry(IEntry *i, u8int *buf);
-int		unpackISect(ISect *is, u8int *buf);
-u32int		unpackMagic(u8int *buf);
-int		vtTypeValid(int type);
-int		wbArena(Arena *arena);
-int		wbArenaHead(Arena *arena);
-int		wbArenaMap(AMap *am, int n, Part *part, u64int base, u64int size);
-int		wbArenaPart(ArenaPart *ap);
-int		wbISect(ISect *is);
-int		wbIndex(Index *ix);
-int		whackblock(u8int *dst, u8int *src, int ssize);
-u64int		writeAClump(Arena *a, Clump *c, u8int *clbuf);
-u32int		writeArena(Arena *arena, u64int aa, u8int *clbuf, u32int n);
-int		writeClumpInfo(Arena *arean, int clump, ClumpInfo *ci);
-u64int		writeIClump(Index *ix, Clump *c, u8int *clbuf);
-int		writeLump(Packet *p, u8int *score, int type, u32int creator);
-int		writePart(Part *part, u64int addr, u8int *buf, u32int n);
-int		writeQLump(Lump *u, Packet *p, int creator);
-Packet		*zblock2Packet(ZBlock *zb, u32int size);
-void		zeroPart(Part *part, int blockSize);
-
-#pragma	varargck	argpos	fatal		1
-#pragma	varargck	argpos	logErr		2
-#pragma	varargck	argpos	SetErr		2
-
-#define scoreEq(h1,h2)		(memcmp((h1),(h2),VtScoreSize)==0)
-#define scoreCp(h1,h2)		memmove((h1),(h2),VtScoreSize)
-
-#define MK(t)			((t*)emalloc(sizeof(t)))
-#define MKZ(t)			((t*)ezmalloc(sizeof(t)))
-#define MKN(t,n)		((t*)emalloc((n)*sizeof(t)))
-#define MKNZ(t,n)		((t*)ezmalloc((n)*sizeof(t)))
-#define MKNA(t,at,n)		((t*)emalloc(sizeof(t) + (n)*sizeof(at)))

+ 0 - 20
sys/src/cmd/oventi/mkfile

@@ -1,20 +0,0 @@
-</$objtype/mkfile
-
-TARG=copy
-HFILES=	dat.h\
-	fns.h\
-	stdinc.h\
-
-CFILES=${TARG:%=%.c}
-OFILES=${TARG:%=%.$O}
-
-UPDATE=mkfile\
-	$HFILES\
-	$CFILES\
-
-BIN=/$objtype/bin/venti
-
-</sys/src/cmd/mkone
-
-acid:D:	$HFILES icache.c
-	$CC -a icache.c >$target || rm $target

+ 0 - 149
sys/src/cmd/oventi/notes

@@ -1,149 +0,0 @@
-all data is big-endian on disk.
-
-arena layout:
-
-ArenaPart (first at offset PartBlank = 256kB in the disk file)
-	magic[4] 0xA9E4A5E7
-	version[4] 3
-	blockSize[4]
-	arenaBase[4] offset of first ArenaHead structure in the disk file
-
-the ArenaMap starts at the first block at offset >= PartBlank+512 bytes.
-it is a sequence of text lines
-/*
- * amap: n '\n' amapelem * n
- * n: u32int
- * amapelem: name '\t' astart '\t' asize '\n'
- * astart, asize: u64int
- */
-
-the astart and astop are byte offsets in the disk file.
-they are the offsets to the ArenaHead and the end of the Arena block.
-
-ArenaHead 
-[base points here in the C code]
-size bytes
-	Clumps
-	ClumpInfo blocks
-Arena
-
-Arena
-	magic[4] 0xF2A14EAD
-	version[4] 4
-	name[64]
-	clumps[4]
-	cclumps[4]
-	ctime[4]
-	wtime[4]
-	used[8]
-	uncsize[8]
-	sealed[1]
-	optional score[20]
-
-once sealed, the sha1 hash of every block from the
-ArenaHead to the Arena is checksummed, as though
-the final score in Arena were the zeroScore.  strangely,
-the tail of the Arena block (the last one) is not included in the checksum
-(i.e., the unused data after the score).
-
-clumpMax = blocksize/ClumpInfoSize = blocksize/25
-dirsize = ((clumps/clumpMax)+1) * blocksize
-want used+dirsize <= size
-want cclumps <= clumps
-want uncsize+clumps*ClumpSize+blocksize < used
-want ctime <= wtime
-
-clump info is stored packed into blocks in order.
-clump info moves forward through a block but the
-blocks themselves move backwards.  so if cm=clumpMax
-and there are two blocks worth of clumpinfo, the blocks
-look like;
-
-	[cm..2*cm-1] [0..cm-1] [Arena]
-
-with the blocks pushed right up against the Arena trailer.
-
-ArenaHead
-	magic[4] 0xD15C4EAD
-	version[4] = Arena.version
-	name[64]
-	blockSize[4]
-	size[8]
-
-Clump
-	magic[4] 0xD15CB10C (0 for an unused clump)
-	type[1]
-	size[2]
-	uncsize[2]
-	score[20]
-	encoding[1] raw=1, compress=2
-	creator[4]
-	time[4]
-
-ClumpInfo
-	type[1]
-	size[2]
-	uncsize[2]
-	score[20]
-
-the arenas are mapped into a single address space corresponding
-to the index that brings them together.  if each arena has 100M bytes
-excluding the headers and there are 4 arenas, then there's 400M of
-index address space between them.  index address space starts at 1M
-instead of 0, so the index addresses assigned to the first arena are
-1M up to 101M, then 101M to 201M, etc.
-
-of course, the assignment of addresses has nothing to do with the index,
-but that's what they're called.
-
-
-the index is split into index sections, which are put on different disks
-to get parallelism of disk heads.  each index section holds some number
-of hash buckets, each in its own disk block.  collectively the index sections
-hold ix->buckets between them. 
-
-the top 32-bits of the score is used to assign scores to buckets.
-div = ceil(2³² / ix->buckets) is the amount of 32-bit score space per bucket.
-
-to look up a block, take the top 32 bits of score and divide by div
-to get the bucket number.  then look through the index section headers
-to figure out which index section has that bucket.
-
-then load that block from the index section.  it's an IBucket.
-
-the IBucket has ib.n IEntry structures in it, sorted by score and then by type.
-do the lookup and get an IEntry.  the ia.addr will be a logical address
-that you then use to get the 
-
-ISect
-	magic[4] 0xD15C5EC7
-	version[4]
-	name[64]
-	index[64]
-	blockSize[4]
-	blockBase[4]	address in partition where bucket blocks start
-	blocks[4]
-	start[4]
-	stop[4]	stop - start <= blocks, but not necessarily ==
-
-IEntry
-	score[20]
-	wtime[4]
-	train[2]
-	ia.addr[8]		index address (see note above)
-	ia.size[2]		size of uncompressed block data
-	ia.type[1]
-	ia.blocks[1]	number of blocks of clump on disk
-
-IBucket
-	n[2]
-	next[4]	not sure; either 0 or inside [start,stop) for the ISect
-	data[n*IEntrySize]
-
-final piece: all the disk partitions start with PartBlank=256kB of unused disk
-(presumably to avoid problems with boot sectors and layout tables
-and the like).
-
-actually the last 8k of the 256k (that is, at offset 248kB) can hold
-a venti config file to help during bootstrap of the venti file server.
-

+ 0 - 8
sys/src/cmd/oventi/stdinc.h

@@ -1,8 +0,0 @@
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
-#include <oventi.h>
-
-typedef uvlong	u64int;
-typedef	uchar	u8int;
-typedef ushort	u16int;

+ 0 - 20
sys/src/cmd/oventi/venti.conf

@@ -1,20 +0,0 @@
-# a sample venti configuration file
-#
-# formated with
-#	venti/fmtarenas arena. /tmp/disks/arenas
-# 	venti/fmtisect isect0 /tmp/disks/isect0
-# 	venti/fmtisect isect1 /tmp/disks/isect1
-#	venti/fmtindex venti.conf
-#
-# server is started with
-#	venti/venti
-
-# the name of the index
-index main
-
-# the index sections
-isect /tmp/disks/isect0
-isect /tmp/disks/isect1
-
-# the arenas
-arenas /tmp/disks/arenas

+ 0 - 21
sys/src/cmd/oventi/wrtape

@@ -1,21 +0,0 @@
-#!/bin/rc
-
-tape=$1
-
-start=`{echo $tape'*32+1' | hoc}
-end=`{echo  $start'+31' | hoc}
-
-echo rewind | scuzz /dev/sd03
-
-arenas=`{hget http://iolaire/index | grep '^arena' | sed  -n $start,$end^p | sed 's/^.*=//' | sed 's/ .*//'}
-for(i in $arenas) {
-	dev=`{hget http://iolaire/index | grep ''''$i'''' | sed 's/.* on //' | sed 's/ .*//'}
-	echo `{date} $tape $i
-	echo `{date} $tape $i >> /sys/log/ventibackup
-	echo $dev
-	echo write '''|venti/rdarena $dev $i''' | scuzz -m 8192 /dev/sd03
-	echo filemark | scuzz -m 6144 /dev/sd03
-}
-
-echo rewind | scuzz /dev/sd03
-

+ 0 - 1
sys/src/cmd/venti/copy.c

@@ -1,4 +1,3 @@
-/* venti copy.  this doesn't work very well; see ../oventi/copy.c instead */
 #include <u.h>
 #include <libc.h>
 #include <venti.h>

+ 2 - 2
sys/src/cmd/venti/mkfile

@@ -1,12 +1,12 @@
 </$objtype/mkfile
 
 TARG=\
+	copy\
 	read\
 	ro\
 	sync\
 	write\
 
-#	copy\
 
 BIN=/$objtype/bin/venti
 
@@ -14,7 +14,7 @@ BIN=/$objtype/bin/venti
 
 CFLAGS=$CFLAGS -I.
 
-extra:V: $O.devnull $O.mkroot $O.randtest $O.readlist $O.ro $O.root
+extra:V: $O.devnull $O.mkroot $O.randtest $O.readlist $O.root
 
 all:V:		srv.all.dir
 install:V:	srv.install.dir

+ 0 - 1
sys/src/cmd/venti/srv/bloom.c

@@ -53,7 +53,6 @@ readbloom(Part *p)
 	 */
 	if(bloominit(b, 0, buf) < 0){
 		vtfree(b);
-		freepart(p);
 		return nil;
 	}else{
 		/*

+ 1 - 1
sys/src/cmd/venti/srv/dcache.c

@@ -101,7 +101,7 @@ initdcache(u32int mem)
 	dcache.mem = MKNZ(u8int, (nblocks+1+128) * blocksize);
 
 	last = nil;
-	p = (u8int*)(((ulong)dcache.mem+blocksize-1)&~(ulong)(blocksize-1));
+	p = (u8int*)(((uintptr)dcache.mem+blocksize-1)&~(uintptr)(blocksize-1));
 	for(i = 0; i < nblocks; i++){
 		b = &dcache.blocks[i];
 		b->data = &p[i * blocksize];

+ 2 - 1
sys/src/cmd/venti/srv/disksched.c

@@ -80,7 +80,8 @@ void
 diskaccess(int level)
 {
 	if(level < 0 || level >= nelem(lasttime)){
-		fprint(2, "bad level in diskaccess; caller=%lux\n", getcallerpc(&level));
+		fprint(2, "bad level in diskaccess; caller=%#p\n",
+			getcallerpc(&level));
 		return;
 	}
 	lasttime[level] = time(0);

+ 2 - 1
sys/src/cmd/venti/srv/icache.c

@@ -411,7 +411,8 @@ insertscore(u8int score[VtScoreSize], IAddr *ia, int state, AState *as)
 		assert(state == IEDirty);
 		toload = nil;
 		if(as == nil)
-			fprint(2, "%T insertscore IEDirty without as; called from %lux\n", getcallerpc(&score));
+			fprint(2, "%T insertscore IEDirty without as; called from %#p\n",
+				getcallerpc(&score));
 		else{
 			if(icache.as.aa > as->aa)
 				fprint(2, "%T insertscore: aa moving backward: %#llux -> %#llux\n", icache.as.aa, as->aa);

+ 1 - 1
sys/src/cmd/venti/srv/icachewrite.c

@@ -217,7 +217,7 @@ icachewriteproc(void *v)
 
 	bsize = 1<<is->blocklog;
 	buf = emalloc(Bufsize+bsize);
-	buf = (u8int*)(((ulong)buf+bsize-1)&~(ulong)(bsize-1));
+	buf = (u8int*)(((uintptr)buf+bsize-1)&~(uintptr)(bsize-1));
 
 	for(;;){
 		trace(TraceProc, "icachewriteproc recv");

+ 4 - 4
sys/src/cmd/venti/srv/utils.c

@@ -151,7 +151,7 @@ emalloc(ulong n)
 	}
 	memset(p, 0xa5, n);
 	setmalloctag(p, getcallerpc(&n));
-if(0)print("emalloc %p-%p by %lux\n", p, (char*)p+n, getcallerpc(&n));
+if(0)print("emalloc %p-%p by %#p\n", p, (char*)p+n, getcallerpc(&n));
 	return p;
 }
 
@@ -168,7 +168,7 @@ ezmalloc(ulong n)
 	}
 	memset(p, 0, n);
 	setmalloctag(p, getcallerpc(&n));
-if(0)print("ezmalloc %p-%p by %lux\n", p, (char*)p+n, getcallerpc(&n));
+if(0)print("ezmalloc %p-%p by %#p\n", p, (char*)p+n, getcallerpc(&n));
 	return p;
 }
 
@@ -182,7 +182,7 @@ erealloc(void *p, ulong n)
 		sysfatal("out of memory allocating %lud", n);
 	}
 	setrealloctag(p, getcallerpc(&p));
-if(0)print("erealloc %p-%p by %lux\n", p, (char*)p+n, getcallerpc(&p));
+if(0)print("erealloc %p-%p by %#p\n", p, (char*)p+n, getcallerpc(&p));
 	return p;
 }
 
@@ -196,7 +196,7 @@ estrdup(char *s)
 	t = emalloc(n);
 	memmove(t, s, n);
 	setmalloctag(t, getcallerpc(&s));
-if(0)print("estrdup %p-%p by %lux\n", t, (char*)t+n, getcallerpc(&s));
+if(0)print("estrdup %p-%p by %#p\n", t, (char*)t+n, getcallerpc(&s));
 	return t;
 }
 

+ 2 - 6
sys/src/cmd/venti/srv/wrarena.c

@@ -133,7 +133,6 @@ threadmain(int argc, char *argv[])
 	Arena *arena;
 	u64int offset, aoffset;
 	Part *part;
-	Dir *d;
 	uchar buf[8192];
 	ArenaHead head;
 	ZClump zerocl;
@@ -178,9 +177,6 @@ threadmain(int argc, char *argv[])
 
 	statsinit();
 
-	if((d = dirstat(file)) == nil)
-		sysfatal("can't stat file %s: %r", file);
-
 	part = initpart(file, OREAD);
 	if(part == nil)
 		sysfatal("can't open file %s: %r", file);
@@ -190,9 +186,9 @@ threadmain(int argc, char *argv[])
 	if(unpackarenahead(&head, buf) < 0)
 		sysfatal("corrupted arena header: %r");
 
-	if(aoffset+head.size > d->length)
+	if(aoffset+head.size > part->size)
 		sysfatal("arena is truncated: want %llud bytes have %llud\n",
-			head.size, d->length);
+			head.size, part->size);
 
 	partblocksize(part, head.blocksize);
 	initdcache(8 * MaxDiskBlock);

+ 414 - 0
sys/src/libavl/avl.c

@@ -0,0 +1,414 @@
+#include <u.h>
+#include <libc.h>
+#include <bio.h>
+#include <avl.h>
+
+/*
+ * In-memory database stored as self-balancing AVL tree.
+ * See Lewis & Denenberg, Data Structures and Their Algorithms.
+ */
+
+static void
+singleleft(Avl **tp, Avl *p)
+{
+	int l, r2;
+	Avl *a, *c;
+
+	a = *tp;
+	c = a->n[1];
+
+	r2 = c->bal;
+	l = (r2 > 0? r2: 0)+1 - a->bal;
+
+	if((a->n[1] = c->n[0]) != nil)
+		a->n[1]->p = a;
+
+	if((c->n[0] = a) != nil)
+		c->n[0]->p = c;
+
+	if((*tp = c) != nil)
+		(*tp)->p = p;
+
+	a->bal = -l;
+	c->bal = r2 - ((l > 0? l: 0)+1);
+
+}
+
+static void
+singleright(Avl **tp, Avl *p)
+{
+	int l2, r;
+	Avl *a, *c;
+
+	a = *tp;
+	c = a->n[0];
+	l2 = - c->bal;
+	r = a->bal + ((l2 > 0? l2: 0)+1);
+
+	if((a->n[0] = c->n[1]) != nil)
+		a->n[0]->p = a;
+
+	if((c->n[1] = a) != nil)
+		c->n[1]->p = c;
+
+	if((*tp = c) != nil)
+		(*tp)->p = p;
+
+	a->bal = r;
+	c->bal = ((r > 0? r: 0)+1) - l2;
+}
+
+static void
+doublerightleft(Avl **tp, Avl *p)
+{
+	singleright(&(*tp)->n[1], *tp);
+	singleleft(tp, p);
+}
+
+static void
+doubleleftright(Avl **tp, Avl *p)
+{
+	singleleft(&(*tp)->n[0], *tp);
+	singleright(tp, p);
+}
+
+static void
+balance(Avl **tp, Avl *p)
+{
+	switch((*tp)->bal){
+	case -2:
+		if((*tp)->n[0]->bal <= 0)
+			singleright(tp, p);
+		else if((*tp)->n[0]->bal == 1)
+			doubleleftright(tp, p);
+		else
+			assert(0);
+		break;
+
+	case 2:
+		if((*tp)->n[1]->bal >= 0)
+			singleleft(tp, p);
+		else if((*tp)->n[1]->bal == -1)
+			doublerightleft(tp, p);
+		else
+			assert(0);
+		break;
+	}
+}
+
+static int
+_insertavl(Avl **tp, Avl *p, Avl *r, int (*cmp)(Avl*,Avl*), Avl **rfree)
+{
+	int i, ob;
+
+	if(*tp == nil){
+		r->bal = 0;
+		r->n[0] = nil;
+		r->n[1] = nil;
+		r->p = p;
+		*tp = r;
+		return 1;
+	}
+	ob = (*tp)->bal;
+	if((i = cmp(r, *tp)) != 0){
+		(*tp)->bal += i * _insertavl(&(*tp)->n[(i+1)/2], *tp, r, cmp,
+			rfree);
+		balance(tp, p);
+		return ob == 0 && (*tp)->bal != 0;
+	}
+
+	/* install new entry */
+	*rfree = *tp;		/* save old node for freeing */
+	*tp = r;		/* insert new node */
+	**tp = **rfree;		/* copy old node's Avl contents */
+	if(r->n[0])		/* fix node's children's parent pointers */
+		r->n[0]->p = r;
+	if(r->n[1])
+		r->n[1]->p = r;
+
+	return 0;
+}
+
+static Avl*
+_lookupavl(Avl *t, Avl *r, int (*cmp)(Avl*,Avl*))
+{
+	int i;
+	Avl *p;
+
+	p = nil;
+	while(t != nil){
+		assert(t->p == p);
+		if((i = cmp(r, t)) == 0)
+			return t;
+		p = t;
+		t = t->n[(i+1)/2];
+	}
+	return nil;
+}
+
+static int
+successor(Avl **tp, Avl *p, Avl **r)
+{
+	int ob;
+
+	if((*tp)->n[0] == nil){
+		*r = *tp;
+		*tp = (*r)->n[1];
+		if(*tp)
+			(*tp)->p = p;
+		return -1;
+	}
+	ob = (*tp)->bal;
+	(*tp)->bal -= successor(&(*tp)->n[0], *tp, r);
+	balance(tp, p);
+	return -(ob != 0 && (*tp)->bal == 0);
+}
+
+static int
+_deleteavl(Avl **tp, Avl *p, Avl *rx, int(*cmp)(Avl*,Avl*), Avl **del,
+	void (*predel)(Avl*, void*), void *arg)
+{
+	int i, ob;
+	Avl *r, *or;
+
+	if(*tp == nil)
+		return 0;
+
+	ob = (*tp)->bal;
+	if((i=cmp(rx, *tp)) != 0){
+		(*tp)->bal += i * _deleteavl(&(*tp)->n[(i+1)/2], *tp, rx, cmp,
+			del, predel, arg);
+		balance(tp, p);
+		return -(ob != 0 && (*tp)->bal == 0);
+	}
+
+	if(predel)
+		(*predel)(*tp, arg);
+
+	or = *tp;
+	if(or->n[i=0] == nil || or->n[i=1] == nil){
+		*tp = or->n[1-i];
+		if(*tp)
+			(*tp)->p = p;
+		*del = or;
+		return -1;
+	}
+
+	/* deleting node with two kids, find successor */
+	or->bal += successor(&or->n[1], or, &r);
+	r->bal = or->bal;
+	r->n[0] = or->n[0];
+	r->n[1] = or->n[1];
+	*tp = r;
+	(*tp)->p = p;
+	/* node has changed; fix children's parent pointers */
+	if(r->n[0])
+		r->n[0]->p = r;
+	if(r->n[1])
+		r->n[1]->p = r;
+	*del = or;
+	balance(tp, p);
+	return -(ob != 0 && (*tp)->bal == 0);
+}
+
+static void
+checkparents(Avl *a, Avl *p)
+{
+	if(a == nil)
+		return;
+	if(a->p != p)
+		print("bad parent\n");
+	checkparents(a->n[0], a);
+	checkparents(a->n[1], a);
+}
+
+struct Avltree
+{
+	Avl	*root;
+	int	(*cmp)(Avl*, Avl*);
+	Avlwalk	*walks;
+};
+struct Avlwalk
+{
+	int	started;
+	int	moved;
+	Avlwalk	*next;
+	Avltree	*tree;
+	Avl	*node;
+};
+
+Avltree*
+mkavltree(int (*cmp)(Avl*, Avl*))
+{
+	Avltree *t;
+
+	t = malloc(sizeof *t);
+	if(t == nil)
+		return nil;
+	memset(t, 0, sizeof *t);
+	t->cmp = cmp;
+	return t;
+}
+
+void
+insertavl(Avltree *t, Avl *new, Avl **oldp)
+{
+	*oldp = nil;
+	_insertavl(&t->root, nil, new, t->cmp, oldp);
+}
+
+Avl*
+lookupavl(Avltree *t, Avl *key)
+{
+	return _lookupavl(t->root, key, t->cmp);
+}
+
+static Avl*
+findpredecessor(Avl *a)
+{
+	if(a == nil)
+		return nil;
+
+	if(a->n[0] != nil){
+		/* predecessor is rightmost descendant of left child */
+		for(a = a->n[0]; a->n[1]; a = a->n[1])
+			;
+		return a;
+	}else{
+		/* we're at a leaf, successor is a parent we enter from the right */
+		while(a->p && a->p->n[0] == a)
+			a = a->p;
+		return a->p;
+	}
+}
+
+static Avl*
+findsuccessor(Avl *a)
+{
+	if(a == nil)
+		return nil;
+
+	if(a->n[1] != nil){
+		/* successor is leftmost descendant of right child */
+		for(a = a->n[1]; a->n[0]; a = a->n[0])
+			;
+		return a;
+	}else{
+		/* we're at a leaf, successor is a parent we enter from the left going up */
+		while(a->p && a->p->n[1] == a)
+			a = a->p;
+		return a->p;
+	}
+}
+
+static void
+walkdel(Avl *a, void *v)
+{
+	Avl *p;
+	Avlwalk *w;
+	Avltree *t;
+
+	if(a == nil)
+		return;
+
+	p = findpredecessor(a);
+	t = v;
+	for(w = t->walks; w; w = w->next){
+		if(w->node == a){
+			/* back pointer to predecessor; not perfect but adequate */
+			w->moved = 1;
+			w->node = p;
+			if(p == nil)
+				w->started = 0;
+		}
+	}
+}
+
+void
+deleteavl(Avltree *t, Avl *key, Avl **oldp)
+{
+	*oldp = nil;
+	_deleteavl(&t->root, nil, key, t->cmp, oldp, walkdel, t);
+}
+
+Avlwalk*
+avlwalk(Avltree *t)
+{
+	Avlwalk *w;
+
+	w = malloc(sizeof *w);
+	if(w == nil)
+		return nil;
+	memset(w, 0, sizeof *w);
+	w->tree = t;
+	w->next = t->walks;
+	t->walks = w;
+	return w;
+}
+
+Avl*
+avlnext(Avlwalk *w)
+{
+	Avl *a;
+
+	if(w->started==0){
+		for(a = w->tree->root; a && a->n[0]; a = a->n[0])
+			;
+		w->node = a;
+		w->started = 1;
+	}else{
+		a = findsuccessor(w->node);
+		if(a == w->node)
+			abort();
+		w->node = a;
+	}
+	return w->node;
+}
+
+Avl*
+avlprev(Avlwalk *w)
+{
+	Avl *a;
+
+	if(w->started == 0){
+		for(a = w->tree->root; a && a->n[1]; a = a->n[1])
+			;
+		w->node = a;
+		w->started = 1;
+	}else if(w->moved){
+		w->moved = 0;
+		return w->node;
+	}else{
+		a = findpredecessor(w->node);
+		if(a == w->node)
+			abort();
+		w->node = a;
+	}
+	return w->node;
+}
+
+void
+endwalk(Avlwalk *w)
+{
+	Avltree *t;
+	Avlwalk **l;
+
+	t = w->tree;
+	for(l = &t->walks; *l; l = &(*l)->next){
+		if(*l == w){
+			*l = w->next;
+			break;
+		}
+	}
+	free(w);
+}
+
+static void
+walkavl(Avl *t, void (*f)(Avl*, void*), void *v)
+{
+	if(t == nil)
+		return;
+	walkavl(t->n[0], f, v);
+	f(t, v);
+	walkavl(t->n[1], f, v);
+}

+ 15 - 0
sys/src/libavl/mkfile

@@ -0,0 +1,15 @@
+</$objtype/mkfile
+
+LIB=/$objtype/lib/libavl.a
+OFILES=\
+	avl.$O\
+
+HFILES=/sys/include/avl.h
+
+UPDATE=\
+	mkfile\
+	$HFILES\
+	${OFILES:%.$O=%.c}\
+	${LIB:/$objtype/%=/386/%}\
+
+</sys/src/cmd/mksyslib

+ 1 - 0
sys/src/mkfile

@@ -5,6 +5,7 @@ LIBS=\
 	libString\
 	libauth\
 	libauthsrv\
+	libavl\
 	libbin\
 	libbio\
 	libc\