changelog shortlog tags branches files raw gz bz2 help

Mercurial > hg > ventivac / changeset: support for copying rabin blocks, now that they have a different block type

changeset 81: 041fb8789dcf
parent 80: fb2e789fd6bd
child 82: 2acd82cdeef6
author: Mechiel Lukkien <mechiel@ueber.net>
date: Wed, 18 Jul 2007 15:09:41 +0200
files: appl/cmd/venti/copy.b
description: support for copying rabin blocks, now that they have a different block type
     1.1--- a/appl/cmd/venti/copy.b	Wed Jul 18 14:54:48 2007 +0200
     1.2+++ b/appl/cmd/venti/copy.b	Wed Jul 18 15:09:41 2007 +0200
     1.3@@ -16,8 +16,8 @@
     1.4 vac: Vac;
     1.5 
     1.6 print, sprint, fprint, fildes: import sys;
     1.7-Score, Session, Roottype, Dirtype, Datatype, Scoresize: import venti;
     1.8-Root, Rootsize, Entry, Entrysize, Entryactive, Entrydir: import vac;
     1.9+Pointertype0, Pointertype6, Score, Session, Roottype, Dirtype, Datatype, Scoresize: import venti;
    1.10+Pointervarmask, Root, Rootsize, Entry, Entrysize, Entryactive, Entrydir: import vac;
    1.11 
    1.12 Venticopy: module {
    1.13 	init:	fn(nil: ref Draw->Context, args: list of string);
    1.14@@ -114,28 +114,45 @@
    1.15 				error(sprint("bad entry: %r"));
    1.16 			if(!(e.flags&Entryactive))
    1.17 				continue;
    1.18+			tvar := 0;
    1.19+			if(e.flags & Vac->Entryvarblocks)
    1.20+				tvar = Pointervarmask;
    1.21 			nt := Datatype;
    1.22 			if(e.flags&Entrydir)
    1.23 				nt = Dirtype;
    1.24 			if(e.depth == 0)
    1.25 				walk(e.score, nt, 0);
    1.26 			else
    1.27-				walk(e.score, Venti->Pointertype0-1+e.depth, nt);
    1.28+				walk(e.score, tvar|Pointertype0-1+e.depth, nt);
    1.29 		}
    1.30 		
    1.31+	Pointertype0 to Pointertype6 =>
    1.32+		nt := t-1;
    1.33+		for(o := 0; o+Scoresize <= len d; o += Scoresize) {
    1.34+			ns := Score(d[o:o+Scoresize]);
    1.35+			if(ns.eq(Score.zero()))
    1.36+				continue;
    1.37+			if(t == Pointertype0)
    1.38+				nt = dt;
    1.39+			walk(ns, nt, dt);
    1.40+		}
    1.41+
    1.42+	Pointertype0+Pointervarmask to Pointertype6+Pointervarmask =>
    1.43+		nt := t-1;
    1.44+		for(o := 0; o+Scoresize+8 <= len d; o += Scoresize+8) {
    1.45+			ns := Score(d[o:o+Scoresize]);
    1.46+			if(ns.eq(Score.zero()))
    1.47+				continue;
    1.48+			if(t == Pointertype0|Pointervarmask)
    1.49+				nt = dt;
    1.50+			walk(ns, nt, dt);
    1.51+		}
    1.52+
    1.53 	Datatype =>
    1.54 		;
    1.55 
    1.56 	* =>
    1.57-		for(o := 0; o+Scoresize <= len d; o += Scoresize) {
    1.58-			ns := Score(d[o:o+Scoresize]);
    1.59-			if(ns.eq(Score.zero()))
    1.60-				continue;
    1.61-			nt := t-1;
    1.62-			if(t == Venti->Pointertype0)
    1.63-				nt = dt;
    1.64-			walk(ns, nt, dt);
    1.65-		}
    1.66+		error(sprint("unknown block type, %s/%d", s.text(), t));
    1.67 	}
    1.68 	
    1.69 	(ok, ns) := dsts.write(t, d);