changelog shortlog tags branches files raw gz bz2 help

Mercurial > hg > ventivac / changeset: this commit removes some needless lines of code.

changeset 103: c6c061169cb7
parent 102: 2415b13613b1
child 104: bd9330e95ebb
author: Mechiel Lukkien <mechiel@ueber.net>
date: Wed, 15 Aug 2007 16:02:22 +0200
files: appl/cmd/vacfs.b appl/cmd/vacget.b appl/cmd/vacput.b appl/cmd/venti/copy.b appl/cmd/venti/get.b appl/cmd/venti/parse.b appl/cmd/venti/ping.b appl/cmd/venti/put.b appl/cmd/venti/read.b appl/cmd/venti/sync.b appl/cmd/venti/write.b appl/cmd/ventry.b appl/cmd/vtest.b
description: this commit removes some needless lines of code.

do not print "bad option" before printing usage; more in line with inferno style
remove a few debug messages
for vacfs, set owner of virtual root dir to "vacfs", not username. no one cares for username there.
remove "warn(sprint())" calls by more direct "fprint(fildes(2), )"; clearer
remove error messages in case venti/vac/rabin module cannot be loaded. they are installed in the right place, they should be there. if not, it'll crash and you can fix it.
     1.1--- a/appl/cmd/vacfs.b	Tue Aug 07 00:14:14 2007 +0200
     1.2+++ b/appl/cmd/vacfs.b	Wed Aug 15 16:02:22 2007 +0200
     1.3@@ -226,8 +226,7 @@
     1.4 	styx = load Styx Styx->PATH;
     1.5 	styxservers = load Styxservers Styxservers->PATH;
     1.6 	vac = load Vac Vac->PATH;
     1.7-	if(venti == nil || vac == nil)
     1.8-		error("loading venti,vac");
     1.9+
    1.10 	sys->pctl(sys->NEWPGRP, nil);
    1.11 	venti->init();
    1.12 	vac->init();
    1.13@@ -243,8 +242,7 @@
    1.14 		'd' =>	dflag++;
    1.15 			vac->dflag++;
    1.16 		'p' =>	pflag++;
    1.17-		* =>	warn(sprint("bad option: -%c", ch));
    1.18-			arg->usage();
    1.19+		* =>	arg->usage();
    1.20 		}
    1.21 	args = arg->argv();
    1.22 	if(len args > 1)
    1.23@@ -263,8 +261,7 @@
    1.24 		error(sprint("dialing %s: %r", addr));
    1.25 	say("have connection");
    1.26 
    1.27-	fd := conn.dfd;
    1.28-	session = Session.new(fd);
    1.29+	session = Session.new(conn.dfd);
    1.30 	if(session == nil)
    1.31 		error(sprint("handshake: %r"));
    1.32 	say("have handshake");
    1.33@@ -273,10 +270,10 @@
    1.34 	red: ref Elem;
    1.35 	if(args == nil) {
    1.36 		de := Direntry.new();
    1.37-		de.uid = de.gid = de.mid = user();
    1.38+		de.uid = de.gid = de.mid = "vacfs";
    1.39 		de.ctime = de.atime = de.mtime = daytime->now();
    1.40-		de.mode = Vac->Modedir|8r755;
    1.41-		de.emode = Sys->DMDIR|8r755;
    1.42+		de.mode = Vac->Modedir|8r555;
    1.43+		de.emode = Sys->DMDIR|8r555;
    1.44 		red = Elem.mkdir(rqid, de, big 0, nil, rqid);
    1.45 	} else {
    1.46 		(vd, de, err) := vac->vdroot(session, *score);
    1.47@@ -378,14 +375,11 @@
    1.48 loop:
    1.49 	for(;;) {
    1.50 		navop := <- c;
    1.51-		say(sprint("have navop, path=%bd", navop.path));
    1.52 		pick n := navop {
    1.53 		Stat =>
    1.54-			say(sprint("have stat path=%bd", n.path));
    1.55 			n.reply <-= (get(int n.path).stat(), nil);
    1.56 
    1.57 		Walk =>
    1.58-			say(sprint("have walk, name=%q", n.name));
    1.59 			ed := getdir(int n.path);
    1.60 			(ne, err) := walk(ed, n.name);
    1.61 			if(err != nil) {
    1.62@@ -397,7 +391,7 @@
    1.63 			n.reply <-= (ne.stat(), nil);
    1.64 
    1.65 		Readdir =>
    1.66-			say(sprint("have readdir path=%bd offset=%d count=%d", n.path, n.offset, n.count));
    1.67+			if(dflag) say(sprint("have readdir path=%bd offset=%d count=%d", n.path, n.offset, n.count));
    1.68 			if(n.path == big 0) {
    1.69 				n.reply <-= (nil, nil);
    1.70 				break;
    1.71@@ -423,7 +417,7 @@
    1.72 					ne := get(cqid);
    1.73 					if(ne == nil)
    1.74 						ne = Elem.new(cqid, ed.vd, de, ed.qid);
    1.75-					say(sprint("readdir, childget(%d, %bd) = %d", ed.qid, de.qid, ne.qid));
    1.76+					if(dflag) say(sprint("readdir, childget(%d, %bd) = %d", ed.qid, de.qid, ne.qid));
    1.77 					ed.prev = (n.offset, ne.stat());
    1.78 				} else {
    1.79 					ed.prev = (n.offset, nil);
    1.80@@ -437,14 +431,6 @@
    1.81 	}
    1.82 }
    1.83 
    1.84-user(): string
    1.85-{
    1.86-	if((fd := sys->open("/dev/user", Sys->OREAD)) != nil
    1.87-		&& (n := sys->read(fd, d := array[128] of byte, len d)) > 0)
    1.88-		return string d[:n];
    1.89-	return "nobody";
    1.90-}
    1.91-
    1.92 error(s: string)
    1.93 {
    1.94 	killgrp();
    1.95@@ -452,15 +438,10 @@
    1.96 	raise "fail:"+s;
    1.97 }
    1.98 
    1.99-warn(s: string)
   1.100-{
   1.101-	fprint(fildes(2), "%s\n", s);
   1.102-}
   1.103-
   1.104 say(s: string)
   1.105 {
   1.106 	if(dflag)
   1.107-		warn(s);
   1.108+		fprint(fildes(2), "%s\n", s);
   1.109 }
   1.110 
   1.111 killgrp()
     2.1--- a/appl/cmd/vacget.b	Tue Aug 07 00:14:14 2007 +0200
     2.2+++ b/appl/cmd/vacget.b	Wed Aug 15 16:02:22 2007 +0200
     2.3@@ -35,8 +35,7 @@
     2.4 	str = load String String->PATH;
     2.5 	venti = load Venti Venti->PATH;
     2.6 	vac = load Vac Vac->PATH;
     2.7-	if(venti == nil || vac == nil)
     2.8-		error("loading venti,vac");
     2.9+
    2.10 	venti->init();
    2.11 	vac->init();
    2.12 
    2.13@@ -50,8 +49,7 @@
    2.14 		'p' =>	pflag++;
    2.15 		't' =>	tflag++;
    2.16 		'v' =>	vflag++;
    2.17-		* =>	warn(sprint("bad option: -%c", c));
    2.18-			arg->usage();
    2.19+		* =>	arg->usage();
    2.20 		}
    2.21 	args = arg->argv();
    2.22 	if(len args != 1)
    2.23@@ -97,7 +95,7 @@
    2.24 		d.gid = de.gid;
    2.25 		d.mode = de.emode;
    2.26 		if(sys->fwstat(fd, d) != 0) {
    2.27-			warn(sprint("fwstat %s for uid/gid/mode: %r", path));
    2.28+			fprint(fildes(2), "fwstat %s for uid/gid/mode: %r", path);
    2.29 			d.uid = d.gid = "";
    2.30 			sys->fwstat(fd, d);
    2.31 		}
    2.32@@ -122,7 +120,7 @@
    2.33 
    2.34 		oflags := de.mode&~(Modeperm|Modeappend|Modeexcl|Modedir|Modesnapshot);
    2.35 		if(oflags)
    2.36-			warn(sprint("%s: not all bits in mode can be set: 0x%x", newpath, oflags));
    2.37+			fprint(fildes(2), "%s: not all bits in mode can be set: 0x%x", newpath, oflags);
    2.38 
    2.39 		if(tflag || vflag)
    2.40 			fprint(fildes(2), "%s\n", newpath);
    2.41@@ -165,7 +163,7 @@
    2.42 				d := sys->nulldir;
    2.43 				d.mtime = de.mtime;
    2.44 				if(sys->fwstat(fd, d) < 0)
    2.45-					warn(sprint("fwstat %s for mtime: %r", newpath));
    2.46+					fprint(fildes(2), "fwstat %s for mtime: %r", newpath);
    2.47 			}
    2.48 			fd = nil;
    2.49 		}
    2.50@@ -178,13 +176,8 @@
    2.51 	raise "fail:"+s;
    2.52 }
    2.53 
    2.54-warn(s: string)
    2.55-{
    2.56-	fprint(fildes(2), "%s\n", s);
    2.57-}
    2.58-
    2.59 say(s: string)
    2.60 {
    2.61 	if(Dflag)
    2.62-		warn(s);
    2.63+		fprint(fildes(2), "%s\n", s);
    2.64 }
     3.1--- a/appl/cmd/vacput.b	Tue Aug 07 00:14:14 2007 +0200
     3.2+++ b/appl/cmd/vacput.b	Wed Aug 15 16:02:22 2007 +0200
     3.3@@ -48,8 +48,7 @@
     3.4 	venti = load Venti Venti->PATH;
     3.5 	vac = load Vac Vac->PATH;
     3.6 	rabin = load Rabin Rabin->PATH;
     3.7-	if(venti == nil || vac == nil || rabin == nil)
     3.8-		error("loading venti,vac,rabin");
     3.9+
    3.10 	venti->init();
    3.11 	vac->init();
    3.12 	rabin->init(bufio);
    3.13@@ -79,8 +78,7 @@
    3.14 		'q' =>	qflag++;
    3.15 		'r' =>	rflag++;
    3.16 		'v' =>	vflag++;
    3.17-		* =>	warn(sprint("bad option: -%c", c));
    3.18-			arg->usage();
    3.19+		* =>	arg->usage();
    3.20 		}
    3.21 	args = arg->argv();
    3.22 	if(len args == 0)
    3.23@@ -198,11 +196,11 @@
    3.24 		error(sprint("fstat %s: %r", path));
    3.25 say("writepath: file opened");
    3.26 	if(dir.mode&sys->DMAUTH) {
    3.27-		warn(path+": is auth file, skipping");
    3.28+		fprint(fildes(2), "%s: is auth file, skipping", path);
    3.29 		return;
    3.30 	}
    3.31 	if(dir.mode&sys->DMTMP) {
    3.32-		warn(path+": is temporary file, skipping");
    3.33+		fprint(fildes(2), "%s: is temporary file, skipping", path);
    3.34 		return;
    3.35 	}
    3.36 
    3.37@@ -360,17 +358,12 @@
    3.38 
    3.39 error(s: string)
    3.40 {
    3.41-	warn(s);
    3.42+	fprint(fildes(2), "%s\n", s);
    3.43 	raise "fail:"+s;
    3.44 }
    3.45 
    3.46-warn(s: string)
    3.47-{
    3.48-	fprint(fildes(2), "%s\n", s);
    3.49-}
    3.50-
    3.51 say(s: string)
    3.52 {
    3.53 	if(Dflag)
    3.54-		warn(s);
    3.55+		fprint(fildes(2), "%s\n", s);
    3.56 }
     4.1--- a/appl/cmd/venti/copy.b	Tue Aug 07 00:14:14 2007 +0200
     4.2+++ b/appl/cmd/venti/copy.b	Wed Aug 15 16:02:22 2007 +0200
     4.3@@ -35,8 +35,7 @@
     4.4 	str = load String String->PATH;
     4.5 	venti = load Venti Venti->PATH;
     4.6 	vac = load Vac Vac->PATH;
     4.7-	if(venti == nil || vac == nil)
     4.8-		error("loading venti,vac");
     4.9+
    4.10 	venti->init();
    4.11 	vac->init();
    4.12 
    4.13@@ -47,8 +46,7 @@
    4.14 		'd' =>	dflag++;
    4.15 			vac->dflag++;
    4.16 		'f' =>	fflag++;
    4.17-		* =>	fprint(fildes(2), "bad option: -%c\n", c);
    4.18-			arg->usage();
    4.19+		* =>	arg->usage();
    4.20 		}
    4.21 	args = arg->argv();
    4.22 	if(len args != 3)
     5.1--- a/appl/cmd/venti/get.b	Tue Aug 07 00:14:14 2007 +0200
     5.2+++ b/appl/cmd/venti/get.b	Wed Aug 15 16:02:22 2007 +0200
     5.3@@ -36,8 +36,7 @@
     5.4 	str = load String String->PATH;
     5.5 	venti = load Venti Venti->PATH;
     5.6 	vac = load Vac Vac->PATH;
     5.7-	if(venti == nil || vac == nil)
     5.8-		error("loading venti,vac");
     5.9+
    5.10 	venti->init();
    5.11 	vac->init();
    5.12 
    5.13@@ -48,8 +47,7 @@
    5.14 		'a' =>	addr = arg->earg();
    5.15 		'd' =>	dflag++;
    5.16 			vac->dflag++;
    5.17-		* =>	fprint(fildes(2), "bad option: -%c\n", c);
    5.18-			arg->usage();
    5.19+		* =>	arg->usage();
    5.20 		}
    5.21 	args = arg->argv();
    5.22 	if(len args != 1)
     6.1--- a/appl/cmd/venti/parse.b	Tue Aug 07 00:14:14 2007 +0200
     6.2+++ b/appl/cmd/venti/parse.b	Wed Aug 15 16:02:22 2007 +0200
     6.3@@ -27,8 +27,7 @@
     6.4 	str = load String String->PATH;
     6.5 	venti = load Venti Venti->PATH;
     6.6 	vac = load Vac Vac->PATH;
     6.7-	if(vac == nil)
     6.8-		error("loading vac");
     6.9+
    6.10 	venti->init();
    6.11 	vac->init();
    6.12 
    6.13@@ -36,8 +35,7 @@
    6.14 	arg->setusage(arg->progname() + " [type]");
    6.15 	while((c := arg->opt()) != 0)
    6.16 		case c {
    6.17-		* =>	fprint(fildes(2), "bad option: -%c\n", c);
    6.18-			arg->usage();
    6.19+		* =>	arg->usage();
    6.20 		}
    6.21 	args = arg->argv();
    6.22 	if(len args >= 2)
     7.1--- a/appl/cmd/venti/ping.b	Tue Aug 07 00:14:14 2007 +0200
     7.2+++ b/appl/cmd/venti/ping.b	Wed Aug 15 16:02:22 2007 +0200
     7.3@@ -33,8 +33,7 @@
     7.4 		'a' =>	addr = arg->earg();
     7.5 		'd' =>	dflag++;
     7.6 		'n' =>	n = int arg->earg();
     7.7-		* =>	fprint(fildes(2), "bad option: -%c", c);
     7.8-			arg->usage();
     7.9+		* =>	arg->usage();
    7.10 		}
    7.11 	args = arg->argv();
    7.12 	if(len args != 0)
     8.1--- a/appl/cmd/venti/put.b	Tue Aug 07 00:14:14 2007 +0200
     8.2+++ b/appl/cmd/venti/put.b	Wed Aug 15 16:02:22 2007 +0200
     8.3@@ -39,8 +39,7 @@
     8.4 	venti = load Venti Venti->PATH;
     8.5 	vac = load Vac Vac->PATH;
     8.6 	rabin = load Rabin Rabin->PATH;
     8.7-	if(venti == nil || vac == nil)
     8.8-		error("loading venti,vac");
     8.9+
    8.10 	venti->init();
    8.11 	vac->init();
    8.12 	rabin->init(bufio);
    8.13@@ -60,8 +59,7 @@
    8.14 		'r' =>	rflag++;
    8.15 		'd' =>	dflag++;
    8.16 			vac->dflag++;
    8.17-		* =>	fprint(fildes(2), "bad option: -%c", c);
    8.18-			arg->usage();
    8.19+		* =>	arg->usage();
    8.20 		}
    8.21 	args = arg->argv();
    8.22 	if(len args != 0)
     9.1--- a/appl/cmd/venti/read.b	Tue Aug 07 00:14:14 2007 +0200
     9.2+++ b/appl/cmd/venti/read.b	Wed Aug 15 16:02:22 2007 +0200
     9.3@@ -31,8 +31,7 @@
     9.4 		case c {
     9.5 		'a' =>	addr = arg->earg();
     9.6 		'd' =>	dflag++;
     9.7-		* =>	fprint(fildes(2), "bad option: -%c\n", c);
     9.8-			arg->usage();
     9.9+		* =>	arg->usage();
    9.10 		}
    9.11 	args = arg->argv();
    9.12 	if(len args != 2)
    10.1--- a/appl/cmd/venti/sync.b	Tue Aug 07 00:14:14 2007 +0200
    10.2+++ b/appl/cmd/venti/sync.b	Wed Aug 15 16:02:22 2007 +0200
    10.3@@ -31,8 +31,7 @@
    10.4 		case c {
    10.5 		'a' =>	addr = arg->earg();
    10.6 		'd' =>	dflag++;
    10.7-		* =>	fprint(fildes(2), "bad option: -%c", c);
    10.8-			arg->usage();
    10.9+		* =>	arg->usage();
   10.10 		}
   10.11 	args = arg->argv();
   10.12 	if(len args != 0)
    11.1--- a/appl/cmd/venti/write.b	Tue Aug 07 00:14:14 2007 +0200
    11.2+++ b/appl/cmd/venti/write.b	Wed Aug 15 16:02:22 2007 +0200
    11.3@@ -33,8 +33,7 @@
    11.4 		'a' =>	addr = arg->earg();
    11.5 		'd' =>	dflag++;
    11.6 		't' =>	vtype = int arg->earg();
    11.7-		* =>	fprint(fildes(2), "bad option: -%c\n", c);
    11.8-			arg->usage();
    11.9+		* =>	arg->usage();
   11.10 		}
   11.11 	args = arg->argv();
   11.12 	if(len args != 0)
    12.1--- a/appl/cmd/ventry.b	Tue Aug 07 00:14:14 2007 +0200
    12.2+++ b/appl/cmd/ventry.b	Wed Aug 15 16:02:22 2007 +0200
    12.3@@ -31,8 +31,7 @@
    12.4 	bufio = load Bufio Bufio->PATH;
    12.5 	venti = load Venti Venti->PATH;
    12.6 	vac = load Vac Vac->PATH;
    12.7-	if(vac == nil)
    12.8-		error("loading vac");
    12.9+
   12.10 	venti->init();
   12.11 	vac->init();
   12.12 
   12.13@@ -45,8 +44,7 @@
   12.14 		'd' =>	dflag++;
   12.15 			vac->dflag++;
   12.16 		'i' =>	index = int arg->earg();
   12.17-		* =>	warn(sprint("bad option: -%c", c));
   12.18-			arg->usage();
   12.19+		* =>	arg->usage();
   12.20 		}
   12.21 	args = arg->argv();
   12.22 	if(len args != 1)
   12.23@@ -99,11 +97,6 @@
   12.24 		error(sprint("closing: %r"));
   12.25 }
   12.26 
   12.27-warn(s: string)
   12.28-{
   12.29-	fprint(fildes(2), "%s\n", s);
   12.30-}
   12.31-
   12.32 error(s: string)
   12.33 {
   12.34 	fprint(fildes(2), "%s\n", s);
   12.35@@ -113,5 +106,5 @@
   12.36 say(s: string)
   12.37 {
   12.38 	if(dflag)
   12.39-		warn(s);
   12.40+		fprint(fildes(2), "%s\n", s);
   12.41 }
    13.1--- a/appl/cmd/vtest.b	Tue Aug 07 00:14:14 2007 +0200
    13.2+++ b/appl/cmd/vtest.b	Wed Aug 15 16:02:22 2007 +0200
    13.3@@ -34,8 +34,7 @@
    13.4 		'a' =>	addr = arg->earg();
    13.5 		'd' =>	dflag++;
    13.6 		'n' =>	n = int arg->earg();
    13.7-		* =>	warn(sprint("bad option: -%c", c));
    13.8-			arg->usage();
    13.9+		* =>	arg->usage();
   13.10 		}
   13.11 	args = arg->argv();
   13.12 	if(len args != 2)
   13.13@@ -74,11 +73,6 @@
   13.14 	}
   13.15 }
   13.16 
   13.17-warn(s: string)
   13.18-{
   13.19-	fprint(fildes(2), "%s\n", s);
   13.20-}
   13.21-
   13.22 error(s: string)
   13.23 {
   13.24 	fprint(fildes(2), "%s\n", s);
   13.25@@ -88,5 +82,5 @@
   13.26 say(s: string)
   13.27 {
   13.28 	if(dflag)
   13.29-		warn(s);
   13.30+		fprint(fildes(2), "%s\n", s);
   13.31 }