shithub: riscv

Download patch

ref: d1a1034cbe1492a5b4cfdac5c3190dd5d069bc4f
parent: c67c29952af0a50c265bf34fc317518fd43a8950
author: cinap_lenrek <cinap_lenrek@centraldogma>
date: Thu Apr 28 15:40:57 EDT 2011

cwfs: reduce verbosity, added -d options if you want it anyway

--- a/sys/src/cmd/cwfs/auth.c
+++ b/sys/src/cmd/cwfs/auth.c
@@ -24,16 +24,18 @@
 	uchar csum;
 
 	if (readnvram(&nvr, NVread) < 0) {
-		print("nvrcheck: can't read nvram\n");
+		fprint(2, "nvrcheck: can't read nvram\n");
 		return 1;
 	} else
 		gotnvr = 1;
-	print("nvr read\n");
 
+	if(chatty)
+		print("nvr read\n");
+
 	csum = nvcsum(nvr.machkey, sizeof nvr.machkey);
 	if(csum != nvr.machsum) {
-		print("\n\n ** NVR key checksum is incorrect  **\n");
-		print(" ** set password to allow attaches **\n\n");
+		fprint(2, "\n\n ** NVR key checksum is incorrect  **\n");
+		fprint(2, " ** set password to allow attaches **\n\n");
 		memset(nvr.machkey, 0, sizeof nvr.machkey);
 		return 1;
 	}
--- a/sys/src/cmd/cwfs/config.c
+++ b/sys/src/cmd/cwfs/config.c
@@ -41,7 +41,7 @@
 
 		switch(d1->type) {
 		default:
-			print("can't compare dev: %Z\n", d1);
+			fprint(2, "can't compare dev: %Z\n", d1);
 			panic("devcmp");
 			return 1;
 
@@ -208,17 +208,16 @@
 			break;
 	if (map == nil)
 		return;
-	if (access(map->to, AEXIST) >= 0)
-{ print("map: mapped wren %Z to existing file %s\n", d, map->to); // DEBUG
+	if (access(map->to, AEXIST) >= 0){
+		if(chatty)
+			print("map: mapped wren %Z to existing file %s\n", d, map->to);
 		d->wren.file = map->to;		/* wren -> file mapping */
-}
-	else if (map->tdev != nil)
-{ print("map: mapped wren %Z to dev %Z\n", d, map->tdev); // DEBUG
+	} else if (map->tdev != nil){
+		if(chatty)
+			print("map: mapped wren %Z to dev %Z\n", d, map->tdev);
 		*d = *map->tdev;		/* wren -> wren mapping */
-}
-	else
-		print("bad mapping %Z to %s; no such file or device",
-			d, map->to);
+	} else
+		fprint(2, "bad mapping %Z to %s; no such file or device", d, map->to);
 	d->wren.mapped = 1;
 }
 
@@ -476,7 +475,7 @@
 		} else if ((fsp = getpar(word)) != nil) {
 			cp = getwrd(word, cp);
 			if (!isascii(word[0]) || !isdigit(word[0]))
-				print("bad %s value: %s", fsp->name, word);
+				fprint(2, "bad %s value: %s", fsp->name, word);
 			else
 				fsp->declared = atol(word);
 		} else {
@@ -539,7 +538,8 @@
 	devnone = iconfig("n");
 
 	cp = nvrgetconfig();
-	print("config %s\n", cp);
+	if(chatty)
+		print("config %s\n", cp);
 
 	confdev = d = iconfig(cp);
 	devinit(d);
@@ -568,7 +568,7 @@
 		}
 		/* warn if declared value is not our compiled-in value */
 		if (fsp->declared != fsp->actual)
-			print("warning: config %s %ld != compiled-in %ld\n",
+			fprint(2, "warning: config %s %ld != compiled-in %ld\n",
 				fsp->name, fsp->declared, fsp->actual);
 	}
 
@@ -593,12 +593,12 @@
 
 		putbuf(p);
 		f.modconf = f.newconf = 0;
-		print("config block written\n");
 		goto start;
 	}
 	putbuf(p);
 
-	print("service %s\n", service);
+	if(chatty)
+		print("service %s\n", service);
 
 loop:
 	/*
@@ -618,7 +618,8 @@
 	 */
 	error = 0;
 	for(fs=filsys; fs->name; fs++) {
-		print("filsys %s %s\n", fs->name, fs->conf);
+		if(chatty)
+			print("filsys %s %s\n", fs->name, fs->conf);
 		fs->dev = iconfig(fs->conf);
 		if(f.error) {
 			error = 1;
@@ -633,7 +634,8 @@
 	 */
 	for(fs=filsys; fs->name; fs++) {
 		delay(3000);
-		print("sysinit: %s\n", fs->name);
+		if(chatty)
+			print("sysinit: %s\n", fs->name);
 		if(fs->flags & FREAM)
 			devream(fs->dev, 1);
 		if(fs->flags & FRECOVER)
@@ -669,7 +671,7 @@
 	Iobuf *p = getbuf(d, a, Brd);
 
 	if (p == 0) {
-		print("i/o error reading %Z block %lld\n", d, (Wideoff)a);
+		fprint(2, "i/o error reading %Z block %lld\n", d, (Wideoff)a);
 		return 0;
 	}
 	putbuf(p);
@@ -695,7 +697,6 @@
 		if (cw != nil && cw->type == Devcw)
 			worm = cw->cw.w;
 	}
-	// print("wormof(%Z)=%Z\n", dev, worm);
 	return worm;
 }
 
@@ -709,7 +710,8 @@
 	Devsize lim = devsize(worm);
 	Iobuf *p;
 
-	print("devsize(%Z) = %lld\n", worm, (Wideoff)lim);
+	if(chatty)
+		print("devsize(%Z) = %lld\n", worm, (Wideoff)lim);
 	if (!blockok(worm, 0) || !blockok(worm, lim-1))
 		return 0;
 	delay(5*1000);
@@ -729,7 +731,8 @@
 			break;
 		}
 	}
-	print("limit(%Z) = %lld\n", worm, (Wideoff)lim);
+	if(chatty)
+		print("limit(%Z) = %lld\n", worm, (Wideoff)lim);
 	if (lim <= 0)
 		return 0;
 	return lim + 1;
@@ -898,7 +901,7 @@
 		 * be contiguous.
 		 */
 		if (p == 0) {
-			print("%lld not written yet; can't read\n", (Wideoff)a);
+			fprint(2, "%lld not written yet; can't read\n", (Wideoff)a);
 			continue;
 		}
 		if (to != 0 && devwrite(to, p->addr, p->iobuf) != 0) {
--- a/sys/src/cmd/cwfs/cw.c
+++ b/sys/src/cmd/cwfs/cw.c
@@ -8,7 +8,6 @@
 #define	RDEV(d)		((d)->cw.ro)
 
 enum {
-	DEBUG		= 0,
 	FIRST		= SUPER_ADDR,
 
 	ADDFREE		= 100,
@@ -194,9 +193,6 @@
 	/* print stats in terms of (first-)disc sides */
 	dsize = wormsizeside(dev, 0);
 	if (dsize < 1) {
-		if (DEBUG)
-			print("wormsizeside returned size %lld for %Z side 0\n",
-				(Wideoff)dsize, dev);
 		dsize = h->wsize;	/* it's probably a fake worm */
 		if (dsize < 1)
 			dsize = 1000;	/* don't divide by zero */
@@ -297,8 +293,9 @@
 		}
 		putbuf(p);
 	}
-	if(cw->ncopy) {
-		print("%lld blocks copied to worm\n", (Wideoff)cw->ncopy);
+	if(cw->ncopy){
+		if(chatty)
+			print("%lld blocks copied to worm\n", (Wideoff)cw->ncopy);
 		cw->ncopy = 0;
 	}
 	cw->nodump = 1;
@@ -342,7 +339,7 @@
 		if(s1)
 			goto stop1;
 		if(memcmp(p1->iobuf, p2->iobuf, RBUFSIZE)) {
-			print("reread C%lld W%lld didnt compare\n",
+			fprint(2, "reread C%lld W%lld didnt compare\n",
 				(Wideoff)a, (Wideoff)m);
 			goto stop1;
 		}
@@ -429,8 +426,9 @@
 	h->time = time(nil);
 	m = h->wsize;
 	if(l != m) {
-		print("wdev changed size %lld to %lld\n",
-			(Wideoff)m, (Wideoff)l);
+		if(chatty)
+			print("wdev changed size %lld to %lld\n",
+				(Wideoff)m, (Wideoff)l);
 		h->wsize = l;
 		cb->flags |= Bmod;
 	}
@@ -464,7 +462,7 @@
 
 	switch(dev->type) {
 	default:
-		print("unknown dev in cwraddr %Z\n", dev);
+		fprint(2, "unknown dev in cwraddr %Z\n", dev);
 		return 1;
 
 	case Devcw:
@@ -517,7 +515,7 @@
 	d = dev->ro.parent;
 	if(d == 0 || d->type != Devcw ||
 	   d->private == 0 || RDEV(d) != dev) {
-		print("bad rodev %Z\n", dev);
+		fprint(2, "bad rodev %Z\n", dev);
 		return 1;
 	}
 	s = cwio(d, b, 0, Onone);
@@ -581,7 +579,7 @@
 	c = getcentry(b, addr);
 	if(c == 0) {
 		putbuf(p);
-		print("%Z disk cache bucket %lld is full\n",
+		fprint(2, "%Z disk cache bucket %lld is full\n",
 			cw->cdev, (Wideoff)a1);
 		return Cerror;
 	}
@@ -646,7 +644,7 @@
 			p1 = getbuf(devnone, Cwio1, 0);
 			if(devread(cw->cdev, a2, p1->iobuf)) {
 				putbuf(p1);
-				print("cwio: write induced dump error - r cache\n");
+				fprint(2, "cwio: write induced dump error - r cache\n");
 
 			casenone:
 				if(devwrite(cw->cdev, a2, buf)) {
@@ -661,13 +659,13 @@
 				if(devread(cw->wdev, addr, p2->iobuf)) {
 					putbuf(p1);
 					putbuf(p2);
-					print("cwio: write induced dump error - r+w worm\n");
+					fprint(2, "cwio: write induced dump error - r+w worm\n");
 					goto casenone;
 				}
 				if(memcmp(p1->iobuf, p2->iobuf, RBUFSIZE)) {
 					putbuf(p1);
 					putbuf(p2);
-					print("cwio: write induced dump error - w worm\n");
+					fprint(2, "cwio: write induced dump error - w worm\n");
 					goto casenone;
 				}
 				putbuf(p2);
@@ -697,7 +695,7 @@
 
 	case Ogrow:
 		if(state != Cnone) {
-			print("%Z for block %lld cwgrow with state = %s\n",
+			fprint(2, "%Z for block %lld cwgrow with state = %s\n",
 				cw->cdev, (Wideoff)addr, cwnames[state]);
 			break;
 		}
@@ -706,7 +704,7 @@
 
 	case Odump:
 		if(state != Cdirty) {	/* BOTCH */
-			print("%Z for block %lld cwdump with state = %s\n",
+			fprint(2, "%Z for block %lld cwdump with state = %s\n",
 				cw->cdev, (Wideoff)addr, cwnames[state]);
 			break;
 		}
@@ -717,7 +715,7 @@
 	case Orele:
 		if(state != Cwrite) {
 			if(state != Cdump1)
-				print("%Z for block %lld cwrele with state = %s\n",
+				fprint(2, "%Z for block %lld cwrele with state = %s\n",
 					cw->cdev, (Wideoff)addr, cwnames[state]);
 			break;
 		}
@@ -729,7 +727,7 @@
 			c->state = Cnone;
 		break;
 	}
-	if(DEBUG)
+	if(chatty > 1)
 		print("cwio: %Z %lld s=%s o=%s ns=%s\n",
 			dev, (Wideoff)addr, cwnames[state],
 			cwnames[opcode],
@@ -745,7 +743,7 @@
 	return state;
 
 bad:
-	print("%Z block %lld cw state = %s; cw opcode = %s",
+	fprint(2, "%Z block %lld cw state = %s; cw opcode = %s",
 		dev, (Wideoff)addr, cwnames[state], cwnames[opcode]);
 	return Cerror;
 }
@@ -942,7 +940,8 @@
 	Device *cdev;
 	Off m;
 
-	print("cache init %Z\n", dev);
+	if(chatty)
+		print("cache init %Z\n", dev);
 	cdev = CDEV(dev);
 	devinit(cdev);
 
@@ -980,7 +979,6 @@
 		settag(p, Tbuck, m);
 		putbuf(p);
 	}
-	print("done cacheinit\n");
 	return cb;
 }
 
@@ -990,17 +988,17 @@
 	Filsys *f;
 	Startsb *s;
 
-	for(f=filsys; f->name; f++)
+	for(f=filsys; f->name; f++){
 		if(devcmpr(f->dev, dev) == 0) {
 			for(s=startsb; s->name; s++)
 				if(strcmp(f->name, s->name) == 0)
 					return s->startsb;
-			print(
-		"getstartsb: no special starting superblock for %Z %s\n",
+			fprint(2, "getstartsb: no special starting superblock for %Z %s\n",
 				dev, f->name);
 			return FIRST;
 		}
-	print("getstartsb: no filsys for device %Z\n", dev);
+	}
+	fprint(2, "getstartsb: no filsys for device %Z\n", dev);
 	return FIRST;
 }
 
@@ -1019,7 +1017,8 @@
 	Off m, baddr;
 	Device *wdev;
 
-//	print("cwrecover %Z\n", dev);	// DEBUG
+	if(chatty)
+		print("cwrecover %Z\n", dev);
 	cwinit1(dev);
 	wdev = WDEV(dev);
 
@@ -1037,7 +1036,8 @@
 			break;
 		baddr = m;
 		m = s->next;
-		print("dump %lld is good; %lld next\n", (Wideoff)baddr, (Wideoff)m);
+		if(chatty)
+			print("dump %lld is good; %lld next\n", (Wideoff)baddr, (Wideoff)m);
 		if(baddr == conf.recovsb)
 			break;
 	}
@@ -1075,7 +1075,6 @@
 		s->roraddr = conf.recovro;
 
 	putbuf(p);
-	print("done recover\n");
 }
 
 /*
@@ -1092,7 +1091,8 @@
 	Off m, baddr;
 	Device *cdev;
 
-	print("cwream %Z\n", dev);
+	if(chatty)
+		print("cwream %Z\n", dev);
 	cwinit1(dev);
 	cdev = CDEV(dev);
 	devinit(cdev);
@@ -1148,7 +1148,7 @@
 	p = getbuf(cw->dev, up->addr, Brd|Bmod);
 	d = getdir(p, up->slot);
 	if(!d || !(d->mode & DALLOC)) {
-		print("rewalk1 1\n");
+		fprint(2, "rewalk1 1\n");
 		if(p)
 			putbuf(p);
 		return addr;
@@ -1155,12 +1155,12 @@
 	}
 	p1 = dnodebuf(p, d, slot/DIRPERBUF, 0, 0);
 	if(!p1) {
-		print("rewalk1 2\n");
+		fprint(2, "rewalk1 2\n");
 		if(p)
 			putbuf(p);
 		return addr;
 	}
-	if(DEBUG)
+	if(chatty > 1)
 		print("rewalk1 %lld to %lld \"%s\"\n",
 			(Wideoff)addr, (Wideoff)p1->addr, d->name);
 	addr = p1->addr;
@@ -1182,7 +1182,7 @@
 	p = getbuf(cw->rodev, up->addr, Brd);
 	d = getdir(p, up->slot);
 	if(!d || !(d->mode & DALLOC)) {
-		print("rewalk2 1\n");
+		fprint(2, "rewalk2 1\n");
 		if(p)
 			putbuf(p);
 		return addr;
@@ -1189,12 +1189,12 @@
 	}
 	p1 = dnodebuf(p, d, slot/DIRPERBUF, 0, 0);
 	if(!p1) {
-		print("rewalk2 2\n");
+		fprint(2, "rewalk2 2\n");
 		if(p)
 			putbuf(p);
 		return addr;
 	}
-	if(DEBUG)
+	if(chatty > 1)
 		print("rewalk2 %lld to %lld \"%s\"\n",
 			(Wideoff)addr, (Wideoff)p1->addr, d->name);
 	addr = p1->addr;
@@ -1251,8 +1251,8 @@
 		 */
 		if(!p) {
 			p = getbuf(cw->dev, addr, Brd);
-			if(!p) {
-				print("split: null getbuf\n");
+			if(p == nil) {
+				fprint(2, "split: null getbuf\n");
 				break;
 			}
 		}
@@ -1303,7 +1303,7 @@
 	p = getbuf(cw->dev, addr, Bprobe);
 	if(!isdirty(cw, p, addr, tag)) {
 		if(!cw->all) {
-			if(DEBUG)
+			if(chatty > 1)
 				print("cwrecur: %lld t=%s not dirty %s\n",
 					(Wideoff)addr, tagnames[tag], cw->name);
 			if(p)
@@ -1312,11 +1312,11 @@
 		}
 		shouldstop = 1;
 	}
-	if(DEBUG)
+	if(chatty > 1)
 		print("cwrecur: %lld t=%s %s\n",
 			(Wideoff)addr, tagnames[tag], cw->name);
 	if(cw->depth >= 100) {
-		print("dump depth too great %s\n", cw->name);
+		fprint(2, "dump depth too great %s\n", cw->name);
 		if(p)
 			putbuf(p);
 		return 0;
@@ -1325,7 +1325,7 @@
 
 	switch(tag) {
 	default:
-		print("cwrecur: unknown tag %d %s\n", tag, cw->name);
+		fprint(2, "cwrecur: unknown tag %d %s\n", tag, cw->name);
 
 	case Tfile:
 		break;
@@ -1334,8 +1334,8 @@
 	case Tdir:
 		if(!p) {
 			p = getbuf(cw->dev, addr, Brd);
-			if(!p) {
-				print("cwrecur: Tdir p null %s\n",
+			if(p == nil) {
+				fprint(2, "cwrecur: Tdir p null %s\n",
 					cw->name);
 				break;
 			}
@@ -1358,7 +1358,7 @@
 				strncpy(np, d->name, NAMELEN);
 			else
 			if(i > 0)
-				print("cwrecur: root with >1 directory\n");
+				fprint(2, "cwrecur: root with >1 directory\n");
 			tag1 = Tfile;
 			if(d->mode & DDIR)
 				tag1 = Tdir;
@@ -1400,8 +1400,8 @@
 	tind:
 		if(!p) {
 			p = getbuf(cw->dev, addr, Brd);
-			if(!p) {
-				print("cwrecur: Tind p null %s\n", cw->name);
+			if(p == nil) {
+				fprint(2, "cwrecur: Tind p null %s\n", cw->name);
 				break;
 			}
 		}
@@ -1421,7 +1421,7 @@
 	cw->depth--;
 	if(na && shouldstop) {
 		if(cw->falsehits < 10)
-			print("shouldstop %lld %lld t=%s %s\n",
+			fprint(2, "shouldstop %lld %lld t=%s %s\n",
 				(Wideoff)addr, (Wideoff)na,
 				tagnames[tag], cw->name);
 		cw->falsehits++;
@@ -1445,12 +1445,12 @@
 	Cw *cw;
 
 	if(fs->dev->type != Devcw) {
-		print("cant dump; not cw device: %Z\n", fs->dev);
+		fprint(2, "cant dump; not cw device: %Z\n", fs->dev);
 		return;
 	}
 	cw = fs->dev->private;
 	if(cw == 0) {
-		print("cant dump: has not been inited: %Z\n", fs->dev);
+		fprint(2, "cant dump: has not been inited: %Z\n", fs->dev);
 		return;
 	}
 
@@ -1471,13 +1471,15 @@
 	sync("before dump");
 	cw->fsize = cwsize(cw->dev);
 	orba = cwraddr(cw->dev);
-	print("cwroot %lld", (Wideoff)orba);
+	if(chatty)
+		print("cwroot %lld", (Wideoff)orba);
 	cons.noage = 1;
 	cw->all = cw->allflag;
 	rba = cwrecur(cw, orba, Tsuper, 0, QPROOT);
 	if(rba == 0)
 		rba = orba;
-	print("->%lld\n", (Wideoff)rba);
+	if(chatty)
+		print("->%lld\n", (Wideoff)rba);
 	sync("after cw");
 
 	/*
@@ -1586,16 +1588,16 @@
 
 	cw->fsize = cwsize(cw->dev);
 	oroa = cwraddr(cw->rodev);		/* probably redundant */
-	print("roroot %lld", (Wideoff)oroa);
+	if(chatty)
+		print("roroot %lld", (Wideoff)oroa);
 
 	cons.noage = 0;
 	cw->all = 0;
 	roa = cwrecur(cw, oroa, Tsuper, 0, QPROOT);
-	if(roa == 0) {
-		print("[same]");
+	if(roa == 0)
 		roa = oroa;
-	}
-	print("->%lld /%.4s/%s\n", (Wideoff)roa, tstr, tstr+4);
+	if(chatty)
+		print("->%lld /%.4s/%s\n", (Wideoff)roa, tstr, tstr+4);
 	sync("after ro");
 
 	/*
@@ -1602,7 +1604,8 @@
 	 * final super block
 	 */
 	a = cwsaddr(cw->dev);
-	print("sblock %lld", (Wideoff)a);
+	if(chatty)
+		print("sblock %lld", (Wideoff)a);
 	p = getbuf(cw->dev, a, Brd|Bmod|Bimm);
 	s = (Superb*)p->iobuf;
 	s->last = a;
@@ -1615,7 +1618,8 @@
 	cwio(cw->dev, sba, 0, Ogrow);
 	cwio(cw->dev, sba, p->iobuf, Owrite);
 	cwio(cw->dev, sba, 0, Odump);
-	print("->%lld (->%lld)\n", (Wideoff)sba, (Wideoff)s->next);
+	if(chatty)
+		print("->%lld (->%lld)\n", (Wideoff)sba, (Wideoff)s->next);
 
 	putbuf(p);
 
@@ -1632,8 +1636,10 @@
 	rewalk(cw);
 	sync("all done");
 
-	print("%lld blocks queued for worm\n", (Wideoff)cw->ndump);
-	print("%lld falsehits\n", (Wideoff)cw->falsehits);
+	if(chatty){
+		print("%lld blocks queued for worm\n", (Wideoff)cw->ndump);
+		print("%lld falsehits\n", (Wideoff)cw->falsehits);
+	}
 	cw->nodump = 0;
 
 	/*
@@ -1746,9 +1752,9 @@
 	memset(p->iobuf, 0, RBUFSIZE);
 	if(devread(WDEV(dev), m, p->iobuf) ||
 	   checktag(p, Tsuper, QPSUPER))
-		print("%Z block %lld WORM SUPER BLOCK READ FAILED\n",
+		fprint(2, "%Z block %lld WORM SUPER BLOCK READ FAILED\n",
 			WDEV(dev), (Wideoff)m);
-	else
+	else if(chatty)
 		print("%Z touch superblock %lld\n", WDEV(dev), (Wideoff)m);
 	putbuf(p);
 }
@@ -1765,7 +1771,7 @@
 
 	ps = getbuf(devnone, Cwxx2, 0);
 	if(!ps) {
-		print("sbstore: getbuf\n");
+		fprint(2, "sbstore: getbuf\n");
 		return;
 	}
 
@@ -1851,7 +1857,7 @@
 	Device *cdev;
 
 	if(walkto("/adm/cache") || con_open(FID2, OWRITE|OTRUNC)) {
-		print("cant open /adm/cache\n");
+		fprint(2, "cant open /adm/cache\n");
 		return;
 	}
 	cdev = CDEV(dev);
@@ -1905,7 +1911,7 @@
 	Sidestarts ss;
 
 	if(walkto("/adm/cache") || con_open(FID2, OREAD)) {
-		print("cant open /adm/cache\n");
+		fprint(2, "cant open /adm/cache\n");
 		return;
 	}
 
@@ -1981,13 +1987,13 @@
 
 	p1 = getbuf(WDEV(dev), wa, Brd);
 	if(!p1) {
-		print("blockcmp: wdev error\n");
+		fprint(2, "blockcmp: wdev error\n");
 		return;
 	}
 
 	p2 = getbuf(CDEV(dev), ca, Brd);
 	if(!p2) {
-		print("blockcmp: cdev error\n");
+		fprint(2, "blockcmp: cdev error\n");
 		putbuf(p1);
 		return;
 	}
@@ -2004,8 +2010,6 @@
 				break;
 		}
 
-	if(c == 0)
-		print("no error\n");
 	putbuf(p1);
 	putbuf(p2);
 }
--- a/sys/src/cmd/cwfs/fworm.c
+++ b/sys/src/cmd/cwfs/fworm.c
@@ -2,8 +2,6 @@
 
 #define	FDEV(d)		((d)->fw.fw)
 
-enum { DEBUG = 0 };
-
 Devsize
 fwormsize(Device *d)
 {
@@ -21,13 +19,16 @@
 	Device *fdev;
 	Off a, b;
 
-	print("fworm ream\n");
+	if(chatty)
+		print("fworm ream\n");
 	devinit(d);
 	fdev = FDEV(d);
 	a = fwormsize(d);
 	b = devsize(fdev);
-	print("\tfwsize = %lld\n", (Wideoff)a);
-	print("\tbwsize = %lld\n", (Wideoff)b-a);
+	if(chatty){
+		print("\tfwsize = %lld\n", (Wideoff)a);
+		print("\tbwsize = %lld\n", (Wideoff)b-a);
+	}
 	for(; a < b; a++) {
 		p = getbuf(fdev, a, Bmod|Bres);
 		if(!p)
@@ -52,7 +53,7 @@
 	Device *fdev;
 	Devsize l;
 
-	if(DEBUG)
+	if(chatty > 1)
 		print("fworm read  %lld\n", (Wideoff)b);
 	fdev = FDEV(d);
 	l = devsize(fdev);
@@ -67,7 +68,7 @@
 	l = b % (BUFSIZE*8);
 	if(!(p->iobuf[l/8] & (1<<(l%8)))) {
 		putbuf(p);
-		print("fworm: read %lld\n", (Wideoff)b);
+		fprint(2, "fworm: read %lld\n", (Wideoff)b);
 		return 1;
 	}
 	putbuf(p);
@@ -81,7 +82,7 @@
 	Device *fdev;
 	Devsize l;
 
-	if(DEBUG)
+	if(chatty > 1)
 		print("fworm write %lld\n", (Wideoff)b);
 	fdev = FDEV(d);
 	l = devsize(fdev);
@@ -96,7 +97,7 @@
 	l = b % (BUFSIZE*8);
 	if((p->iobuf[l/8] & (1<<(l%8)))) {
 		putbuf(p);
-		print("fworm: write %lld\n", (Wideoff)b);
+		fprint(2, "fworm: write %lld\n", (Wideoff)b);
 		return 1;
 	}
 	p->iobuf[l/8] |= 1<<(l%8);
--- a/sys/src/cmd/cwfs/iobuf.c
+++ b/sys/src/cmd/cwfs/iobuf.c
@@ -1,8 +1,6 @@
 #include	"all.h"
 #include	"io.h"
 
-enum { DEBUG = 0 };
-
 extern	long nhiob;
 extern	Hiob *hiob;
 
@@ -13,7 +11,7 @@
 	Hiob *hp;
 	Off h;
 
-	if(DEBUG)
+	if(chatty > 1)
 		print("getbuf %Z(%lld) f=%x\n", d, (Wideoff)addr, flag);
 	h = addr + (Off)(uintptr)d*1009;
 	if(h < 0)
@@ -66,7 +64,7 @@
 	if(!canqlock(p)) {
 		if(p == hp->link) {
 			unlock(hp);
-			print("iobuf all locked\n");
+			fprint(2, "iobuf all locked\n");
 			goto loop;
 		}
 		s = p;
@@ -82,7 +80,7 @@
 		qunlock(p);
 		if(p == hp->link) {
 			unlock(hp);
-			print("iobuf all reserved\n");
+			fprint(2, "iobuf all reserved\n");
 			goto loop;
 		}
 		s = p;
@@ -102,7 +100,6 @@
 	p->addr = addr;
 	p->dev = d;
 	p->flags = flag;
-//	p->pc = getcallerpc(&d);
 	unlock(hp);
 	if(iobufmap(p))
 		if(flag & Brd) {
@@ -112,7 +109,7 @@
 		} else
 			return p;
 	else
-		print("iobuf cant map buffer\n");
+		fprint(2, "iobuf cant map buffer %Z(%lld)\n", p->dev, (Wideoff)p->addr);
 	p->flags = 0;
 	p->dev = devnone;
 	p->addr = -1;
@@ -176,11 +173,11 @@
 {
 	long i;
 
-	print("sync: %s\n", reason);
+	if(chatty)
+		print("sync: %s\n", reason);
 	for(i=10*nhiob; i>0; i--)
 		if(!syncblock())
 			return;
-	print("sync shorted\n");
 }
 
 void
@@ -188,10 +185,10 @@
 {
 
 	if(canqlock(p))
-		print("buffer not locked %Z(%lld)\n", p->dev, (Wideoff)p->addr);
+		fprint(2, "buffer not locked %Z(%lld)\n", p->dev, (Wideoff)p->addr);
 	if(p->flags & Bimm) {
 		if(!(p->flags & Bmod))
-			print("imm and no mod %Z(%lld)\n",
+			fprint(2, "imm and no mod %Z(%lld)\n",
 				p->dev, (Wideoff)p->addr);
 		if(!devwrite(p->dev, p->addr, p->iobuf))
 			p->flags &= ~(Bmod|Bimm);
@@ -212,43 +209,14 @@
 		pc = getcallerpc(&p);
 
 		if(qpath == QPNONE){
-			print("checktag pc=%lux %Z(%llux) tag/path=%G/%llud; expected %G\n",
+			fprint(2, "checktag pc=%lux %Z(%llux) tag/path=%G/%llud; expected %G\n",
 				pc, p->dev, (Wideoff)p->addr, t->tag, (Wideoff)t->path, tag);
 		} else {
-			print("checktag pc=%lux %Z(%llux) tag/path=%G/%llud; expected %G/%llud\n",
+			fprint(2, "checktag pc=%lux %Z(%llux) tag/path=%G/%llud; expected %G/%llud\n",
 				pc, p->dev, (Wideoff)p->addr, t->tag, (Wideoff)t->path, tag, qpath);
 		}
 		return 1;
-	}
-
-	/*
-	if(t->tag != tag) {
-		if(p->flags & Bmod) {
-			print("\t%llux: tag = %G/%llud; expected %G/%d -- not flushed\n",
-				t->tag, (Wideoff)t->path, (Wideoff)qpath, tag);
-			return 2;
-		}
-		if(p->dev != nil && p->dev->type == Devcw)
-			cwfree(p->dev, p->addr);
-		if(p->addr != lastaddr)
-			print("\t%llux: tag = %G/%llud; expected %G/%lld -- flushed\n",
-				(Wideoff)p->addr, t->tag, (Wideoff)t->path, tag, (Wideoff)qpath);
-
-		lastaddr = p->addr;
-		p->dev = devnone;
-		p->addr = -1;
-		p->flags = 0;
-		return 2;
-	}
-	if(qpath != QPNONE) {
-		if(qpath ^ t->path) {
-			print("\t%llux: tag/path = %G/%llud; expected %G/%llux\n",
-				(Wideoff)p->addr, t->tag, (Wideoff)t->path, tag, (Wideoff)qpath);
-			return 0;
-		}
-	}
-	*/
-	
+	}	
 	return 0;
 }
 
@@ -276,9 +244,7 @@
 {
 	Iobuf *p, *s;
 	Hiob *hp;
-	Tag *t;
 	long h;
-	int tag;
 
 	for(h=0; h<nhiob; h++) {
 		hp = &hiob[h];
@@ -286,12 +252,6 @@
 		s = hp->link;
 		for(p=s;;) {
 			if(qlmatch(q, p)) {
-				t = (Tag*)(p->iobuf+BUFSIZE);
-				tag = t->tag;
-				if(tag < 0 || tag >= MAXTAG)
-					tag = Tnone;
-				print("\tIobuf %Z(%lld) t=%s\n",
-					p->dev, (Wideoff)p->addr, tagnames[tag]);
 				unlock(hp);
 				return 1;
 			}
--- a/sys/src/cmd/cwfs/juke.c
+++ b/sys/src/cmd/cwfs/juke.c
@@ -103,8 +103,8 @@
 		print("NOT writing new label\n");
 	else if (wormwrite(d, labelblk, labelbuf))
 		/* wormwrite will have complained in detail */
-		print("can't write new label on side %d\n", vord);
-	else
+		fprint(2, "can't write new label on side %d\n", vord);
+	else if (chatty)
 		print("wrote new label on side %d\n", vord);
 }
 
@@ -129,13 +129,12 @@
 		 * no need to repeat most of that detail.
 		 * probably an unwritten WORM-disc label; write a new one.
 		 */
-		print("error reading label block of side %d\n", vord);
+		fprint(2, "error reading label block of side %d\n", vord);
 		newlabel(d, labelblk, labelbuf, vord);
 	} else if (label->magic != Labmagic) {
 		swab8(&label->magic);
 		if (label->magic == Labmagic) {
-			print(
-"side %d's label magic byte-swapped; filsys should be configured with xD",
+			fprint(2, "side %d's label magic byte-swapped; filsys should be configured with xD",
 				vord);
 			swab2(&label->ord);
 			/* could look for Devswab in Juke's filsys */
@@ -145,7 +144,7 @@
 			 * probably the label is empty on RW media,
 			 * so create a new one and try to write it.
 			 */
-			print("bad magic number in label of side %d\n", vord);
+			fprint(2, "bad magic number in label of side %d\n", vord);
 			newlabel(d, labelblk, labelbuf, vord);
 		}
 	}
@@ -155,15 +154,14 @@
 		panic("wormlabel: side %d switched ordinal to %d underfoot",
 			vord, v->ord);
 	if (label->ord != vord) {
-		print(
-	"labelled worm side %Z has wrong ordinal in label (%d, want %d)",
+		fprint(2, "labelled worm side %Z has wrong ordinal in label (%d, want %d)",
 			d, label->ord, vord);
 		qunlock(v);
 		cmd_wormreset(0, nil);			/* put discs away */
 		panic("wrong ordinal in label");
 	}
-
-	print("label %Z ordinal %d\n", d, v->ord);
+	if(chatty)
+		print("label %Z ordinal %d\n", d, v->ord);
 	qunlock(v);
 	/*
 	 * wormunit should return without calling us again,
@@ -213,7 +211,8 @@
 			qunlock(w);
 			delay(100);
 		}
-		print("\tload   r%ld drive %Z\n", v-w->side, w->drive[drive]);
+		if(chatty)
+			print("\tload   r%ld drive %Z\n", v-w->side, w->drive[drive]);
 		if(mmove(w, w->mt0, v->elem, w->dt0+drive, v->rot)) {
 			qunlock(w);
 			goto sbad;
@@ -230,9 +229,9 @@
 		dr = w->drive[v->drive];
 	if(v->status != Sstart) {
 		if(v->status == Sempty)
-			print("worm: unit empty %Z\n", d);
+			fprint(2, "worm: unit empty %Z\n", d);
 		else
-			print("worm: not started %Z\n", d);
+			fprint(2, "worm: not started %Z\n", d);
 		goto sbad;
 	}
 
@@ -259,14 +258,15 @@
 	if (dr->wren.fd == 0)
 		dr->wren.fd = open(dr->wren.sddata, ORDWR);
 	if (dr->wren.fd < 0) {
-		print("wormunit: can't open %s for %Z: %r\n", dr->wren.sddata, d);
+		fprint(2, "wormunit: can't open %s for %Z: %r\n", dr->wren.sddata, d);
 		goto sbad;
 	}
 
 	v->block = inqsize(dr->wren.sddata);
 	if(v->block <= 0) {
-		print("\twormunit %Z block size %ld, setting to %d\n",
-			d, v->block, Sectorsz);
+		if(chatty)
+			print("\twormunit %Z block size %ld, setting to %d\n",
+				d, v->block, Sectorsz);
 		v->block = Sectorsz;
 	}
 
@@ -277,11 +277,13 @@
 	v->mult = (RBUFSIZE + v->block - 1) / v->block;
 	v->max = (v->nblock + 1) / v->mult;
 
-	print("\tworm %Z: drive %Z (juke drive %d)\n",
-		d, w->drive[v->drive], v->drive);
-	print("\t\t%,ld %ld-byte sectors, ", v->nblock, v->block);
-	print("%,ld %d-byte blocks\n", v->max, RBUFSIZE);
-	print("\t\t%ld multiplier\n", v->mult);
+	if(chatty){
+		print("\tworm %Z: drive %Z (juke drive %d)\n",
+			d, w->drive[v->drive], v->drive);
+		print("\t\t%,ld %ld-byte sectors, ", v->nblock, v->block);
+		print("%,ld %d-byte blocks\n", v->max, RBUFSIZE);
+		print("\t\t%ld multiplier\n", v->mult);
+	}
 	if(d->type == Devlworm)
 		return wormlabel(d, v);
 	else
@@ -303,7 +305,7 @@
 		panic("waitready: bad magic in Juke (d->private) for %Z", d);
 	p = d->wren.targ;
 	if(p < 0 || p >= w->nside) {
-		print("waitready: target %d out of range for %Z\n", p, d);
+		fprint(2, "waitready: target %d out of range for %Z\n", p, d);
 		return 0;
 	}
 
@@ -322,16 +324,16 @@
 
 	rv = 0;
 	for(e=0; e < 100; e++) {
-		if (e == 10)
-			print("waitready: waiting for %s to exist\n", datanm); // DEBUG
-		if (access(datanm, AEXIST) >= 0) {
+		if(e == 10 && chatty)
+			print("waitready: waiting for %s to exist\n", datanm);
+		if(access(datanm, AEXIST) >= 0){
 			rv = 1;
 			break;
 		}
 		delay(200);
 	}
-	if (rv == 0)
-		print("waitready: %s for %Z didn't come ready\n", datanm, d);
+	if(rv == 0)
+		fprint(2, "waitready: %s for %Z didn't come ready\n", datanm, d);
 	free(datanm);
 	return rv;
 }
@@ -395,8 +397,9 @@
 				qunlock(v);
 				goto loop;
 			}
-			print("\tunload r%ld drive %Z\n",
-				v-w->side, w->drive[drive]);
+			if(chatty)
+				print("\tunload r%ld drive %Z\n",
+					v-w->side, w->drive[drive]);
 			if(mmove(w, w->mt0, w->dt0+drive, v->elem, v->rot)) {
 				qunlock(v);
 				goto loop;
@@ -417,7 +420,7 @@
 
 	w = d->private;
 	if (w->magic != Jukemagic)
-		print("wormsize: bad magic in Juke (d->private) for %Z\n", d);
+		fprint(2, "wormsize: bad magic in Juke (d->private) for %Z\n", d);
 	if(w->isfixedsize && w->fixedsize != 0)
 		size = w->fixedsize;	/* fixed size is now known */
 	else {
@@ -450,8 +453,7 @@
 	while (d != nil)
 		switch(d->type) {
 		default:
-			print("devtojuke: type of device %Z of %Z unknown\n",
-				d, top);
+			fprint(2, "devtojuke: type of device %Z of %Z unknown\n", d, top);
 			return nil;
 
 		case Devjuke:
@@ -469,8 +471,8 @@
 			 * d->private is a (Juke *) with nside, etc.,
 			 * but we're not supposed to get here.
 			 */
-			print("devtojuke: (l)worm %Z of %Z encountered\n",
-				d, top);
+			if(chatty)
+				print("devtojuke: (l)worm %Z of %Z encountered\n", d, top);
 			/* FALL THROUGH */
 		case Devwren:
 			return nil;
@@ -509,7 +511,7 @@
 
 	for (x = mcat->cat.first; x != nil; x = x->link) {
 		if (!devisside(x)) {
-			print("wormsizeside: %Z of %Z of %Z type not (l)worm\n",
+			fprint(2, "wormsizeside: %Z of %Z of %Z type not (l)worm\n",
 				x, mcat, top);
 			return nil;
 		}
@@ -523,7 +525,7 @@
 	if (x == nil)
 		return nil;
 	if (w->side[i].time == 0) {
-		print("wormsizeside: side %d not in jukebox %Z\n", i, juke);
+		fprint(2, "wormsizeside: side %d not in jukebox %Z\n", i, juke);
 		return nil;
 	}
 	return x;
@@ -581,7 +583,7 @@
 	 */
 	x = d->cat.first;
 	if (x == nil) {
-		print("visitsides: %Z of %Z: empty mcat\n", d, vp->topdev);
+		fprint(2, "visitsides: %Z of %Z: empty mcat\n", d, vp->topdev);
 		return 0;
 	}
 	if (!devisside(x)) {
@@ -592,7 +594,7 @@
 
 	/* the side we want is in this jukebox, thus this mcat (d) */
 	if (parentj == nil) {
-		print("visitsides: no parent juke for sides mcat %Z\n", d);
+		fprint(2, "visitsides: no parent juke for sides mcat %Z\n", d);
 		vp->sleft = -1;
 		return 0;
 	}
@@ -628,7 +630,7 @@
 	visit.topdev = d;
 	size = visitsides(d, nil, &visit);
 	if (visit.sawjuke && (visit.sleft != 0 || !visit.sized)) {
-		print("wormsizeside: fewer than %d sides in %Z\n", side, d);
+		fprint(2, "wormsizeside: fewer than %d sides in %Z\n", side, d);
 		return 0;
 	}
 	return size;
@@ -667,11 +669,11 @@
 		panic("wormread: unopened fd for %Z", d);
 	max = (d->type == Devlworm? v->max + 1: v->max);
 	if(b >= max) {
-		print("wormread: block out of range %Z(%lld)\n", d, (Wideoff)b);
+		fprint(2, "wormread: block out of range %Z(%lld)\n", d, (Wideoff)b);
 		r = 0x071;
 	} else if (pread(dr->wren.fd, c, RBUFSIZE, (vlong)b*RBUFSIZE) != RBUFSIZE) {
 		fd2path(dr->wren.fd, name, sizeof name);
-		print("wormread: error on %Z(%lld) on %s in %s: %r\n",
+		fprint(2, "wormread: error on %Z(%lld) on %s in %s: %r\n",
 			d, (Wideoff)b, name, dr->wren.sddir);
 		cons.nwormre++;
 		r = 1;
@@ -697,12 +699,11 @@
 		panic("wormwrite: unopened fd for %Z", d);
 	max = (d->type == Devlworm? v->max + 1: v->max);
 	if(b >= max) {
-		print("wormwrite: block out of range %Z(%lld)\n",
-			d, (Wideoff)b);
+		fprint(2, "wormwrite: block out of range %Z(%lld)\n", d, (Wideoff)b);
 		r = 0x071;
 	} else if (pwrite(dr->wren.fd, c, RBUFSIZE, (vlong)b*RBUFSIZE) != RBUFSIZE) {
 		fd2path(dr->wren.fd, name, sizeof name);
-		print("wormwrwite: error on %Z(%lld) on %s in %s: %r\n",
+		fprint(2, "wormwrwite: error on %Z(%lld) on %s in %s: %r\n",
 			d, (Wideoff)b, name, dr->wren.sddir);
 		cons.nwormwe++;
 		r = 1;
@@ -814,28 +815,28 @@
 
 	s = scsiio(w->juke, SCSIread, cmd, sizeof cmd, buf, sizeof buf); /* read elem sts */
 	if(s) {
-		print("scsiio #%x\n", s);
+		fprint(2, "scsiio #%x\n", s);
 		goto bad;
 	}
 
 	s = (buf[0]<<8) | buf[1];
 	if(s != e) {
-		print("element = %d\n", s);
+		fprint(2, "element = %d\n", s);
 		goto bad;
 	}
 	if(buf[3] != 1) {
-		print("number reported = %d\n", buf[3]);
+		fprint(2, "number reported = %d\n", buf[3]);
 		goto bad;
 	}
 	s = (buf[8+8+0]<<8) | buf[8+8+1];
 	if(s != e) {
-		print("element1 = %d\n", s);
+		fprint(2, "element1 = %d\n", s);
 		goto bad;
 	}
 
 	switch(buf[8+0]) {	/* element type */
 	default:
-		print("unknown element %d: %d\n", e, buf[8+0]);
+		fprint(2, "unknown element %d: %d\n", e, buf[8+0]);
 		goto bad;
 	case 1:			/* transport */
 		s = e - w->mt0;
@@ -842,7 +843,7 @@
 		if(s < 0 || s >= w->nmt)
 			goto bad;
 		if(buf[8+8+2] & 1)
-			print("transport %d full %d.%d\n", s,
+			fprint(2, "transport %d full %d.%d\n", s,
 				(buf[8+8+10]<<8) | buf[8+8+11],
 				(buf[8+8+9]>>6) & 1);
 		break;
@@ -860,25 +861,26 @@
 		s = e - w->ie0;
 		if(s < 0 || s >= w->nie)
 			goto bad;
-		print("import/export %d #%.2x %d.%d\n", s,
-			buf[8+8+2],
-			(buf[8+8+10]<<8) | buf[8+8+11],
-			(buf[8+8+9]>>6) & 1);
+		if(chatty)
+			print("import/export %d #%.2x %d.%d\n", s,
+				buf[8+8+2],
+				(buf[8+8+10]<<8) | buf[8+8+11],
+				(buf[8+8+9]>>6) & 1);
 		break;
 	case 4:			/* data transfer */
 		s = e - w->dt0;
 		if(s < 0 || s >= w->ndt)
 			goto bad;
-		print("data transfer %d #%.2x %d.%d\n", s,
-			buf[8+8+2],
-			(buf[8+8+10]<<8) | buf[8+8+11],
-			(buf[8+8+9]>>6) & 1);
+		if(chatty)
+			print("data transfer %d #%.2x %d.%d\n", s,
+				buf[8+8+2],
+				(buf[8+8+10]<<8) | buf[8+8+11],
+				(buf[8+8+9]>>6) & 1);
 		if(buf[8+8+2] & 1) {
 			t = ((buf[8+8+10]<<8) | buf[8+8+11]) - w->se0;
 			if (t < 0 || t >= w->nse || t >= MAXSIDE ||
 			    s >= MAXDRIVE) {
-				print(
-		"element: juke %Z lies; claims side %d is in drive %d\n",
+				fprint(2, "element: juke %Z lies; claims side %d is in drive %d\n",
 					w->juke, t, s);	/* lying sack of ... */
 				/*
 				 * at minimum, we've avoided corrupting our
@@ -890,10 +892,10 @@
 				 */
 				goto bad;
 			}
-			print("r%d in drive %d\n", t, s);
-			if(mmove(w, w->mt0, w->dt0+s, w->se0+t,
-			    (buf[8+8+9]>>6) & 1)) {
-				print("mmove initial unload\n");
+			if(chatty)
+				print("r%d in drive %d\n", t, s);
+			if(mmove(w, w->mt0, w->dt0+s, w->se0+t,(buf[8+8+9]>>6) & 1)){
+				fprint(2, "mmove initial unload\n");
 				goto bad;
 			}
 			w->side[t].status = Sunload;
@@ -900,8 +902,8 @@
 			if(w->rot)
 				w->side[w->nse+t].status = Sunload;
 		}
-		if(buf[8+8+2] & 4) {
-			print("drive w%d has exception #%.2x #%.2x\n", s,
+		if(buf[8+8+2] & 4){
+			fprint(2, "drive w%d has exception #%.2x #%.2x\n", s,
 				buf[8+8+4], buf[8+8+5]);
 			goto bad;
 		}
@@ -956,7 +958,7 @@
 
 	switch(d->type) {
 	default:
-		print("juke platter not (devmcat of) dev(l)worm: %Z\n", d);
+		fprint(2, "juke platter not (devmcat of) dev(l)worm: %Z\n", d);
 		panic("jinit: type");
 
 	case Devmcat:
@@ -977,7 +979,7 @@
 		/* FALL THROUGH */
 	case Devworm:
 		if(d->private) {
-			print("juke platter private pointer set %p\n",
+			fprint(2, "juke platter private pointer set %p\n",
 				d->private);
 			panic("jinit: private");
 		}
@@ -996,7 +998,7 @@
 	i = number(arg, -1, 10) - 1;
 	w = jukelist;
 	if(i < 0 || i >= w->nside) {
-		print("bad unit number %s (%d)\n", arg, i+1);
+		fprint(2, "bad unit number %s (%d)\n", arg, i+1);
 		return 0;
 	}
 	j = i;
@@ -1045,7 +1047,7 @@
 	u = number(argv[1], -1, 10);
 	w = jukelist;
 	if(u < 0 || u >= w->ndrive) {
-		print("bad drive %s (0<=%d<%d)\n", argv[1], u, w->ndrive);
+		fprint(2, "bad drive %s (0<=%d<%d)\n", argv[1], u, w->ndrive);
 		return;
 	}
 	if(w->offline[u])
@@ -1154,7 +1156,7 @@
 	if (xdev == nil)
 		panic("querychanger: nil Device");
 	if(xdev->type != Devwren) {
-		print("juke changer not wren %Z\n", xdev);
+		fprint(2, "juke changer not wren %Z\n", xdev);
 		goto bad;
 	}
 	for(w=jukelist; w; w=w->link)
@@ -1171,7 +1173,9 @@
 	w->link = jukelist;
 	jukelist = w;
 
-	print("alloc juke %Z\n", xdev);
+	if(chatty)
+		print("alloc juke %Z\n", xdev);
+
 	qlock(w);
 	qunlock(w);
 //	w->name = "juke";
@@ -1190,7 +1194,7 @@
 	if(w->rot)
 		w->nside += w->nside;
 	if(w->nside > MAXSIDE) {
-		print("too many sides: %d max %d\n", w->nside, MAXSIDE);
+		fprint(2, "too many sides: %d max %d\n", w->nside, MAXSIDE);
 		goto bad;
 	}
 	for(i=0; i < w->nse; i++) {
@@ -1203,7 +1207,8 @@
 
 	w->ndrive = w->ndt;
 	if(w->ndrive > MAXDRIVE) {
-		print("ndrives truncated to %d\n", MAXDRIVE);
+		if(chatty)
+			print("ndrives truncated to %d\n", MAXDRIVE);
 		w->ndrive = MAXDRIVE;
 	}
 
@@ -1231,7 +1236,7 @@
 		panic("jukeinit: nil Device");
 	xdev = d->j.j;
 	if(xdev == nil || xdev->type != Devmcat) {
-		print("juke union not mcat\n");
+		fprint(2, "juke union not mcat\n");
 		goto bad;
 	}
 
@@ -1260,17 +1265,17 @@
 	i = 0;
 	while(xdev = xdev->link) {
 		if(xdev->type != Devwren) {
-			print("drive not devwren: %Z\n", xdev);
+			fprint(2, "drive not devwren: %Z\n", xdev);
 			goto bad;
 		}
 		if(w->drive[i]->type != Devnone &&
 		   xdev != w->drive[i]) {
-			print("double init drive %d %Z %Z\n",
+			fprint(2, "double init drive %d %Z %Z\n",
 				i, w->drive[i], xdev);
 			goto bad;
 		}
 		if(i >= w->ndrive) {
-			print("too many drives %Z\n", xdev);
+			fprint(2, "too many drives %Z\n", xdev);
 			goto bad;
 		}
 		w->drive[i++] = xdev;
@@ -1277,7 +1282,7 @@
 	}
 
 	if(i <= 0) {
-		print("no drives\n");
+		fprint(2, "no drives\n");
 		goto bad;
 	}
 
@@ -1314,8 +1319,9 @@
 				continue;
 			if(v->status == Sstart && t > v->time) {
 				drive = v->drive;
-				print("\ttime   r%ld drive %Z\n",
-					v-w->side, w->drive[drive]);
+				if(chatty)
+					print("\ttime   r%ld drive %Z\n",
+						v-w->side, w->drive[drive]);
 				mmove(w, w->mt0, w->dt0+drive, v->elem, v->rot);
 				v->status = Sunload;
 			}
--- a/sys/src/cmd/cwfs/main.c
+++ b/sys/src/cmd/cwfs/main.c
@@ -9,6 +9,7 @@
 
 int sfd, rfd;
 Biobuf bin;
+int chatty = 0;
 
 void
 machinit(void)
@@ -59,7 +60,7 @@
 	n = vseprint(buf, buf + sizeof buf, fmt, arg) - buf;
 	va_end(arg);
 	buf[n] = '\0';
-	print("panic: %s\n", buf);
+	fprint(2, "panic: %s\n", buf);
 	exit();
 }
 
@@ -92,12 +93,12 @@
 	if (bp == nil)
 		sysfatal("can't read %s", mapfile);
 	devmap = nil;
-	while ((ln = Brdline(bp, '\n')) != nil) {
+	while((ln = Brdline(bp, '\n')) != nil) {
 		ln[Blinelen(bp)-1] = '\0';
-		if (*ln == '\0' || *ln == '#')
+		if(*ln == '\0' || *ln == '#')
 			continue;
 		nf = tokenize(ln, fields, nelem(fields));
-		if (nf != 2)
+		if(nf != 2)
 			continue;
 		if(testconfig(fields[0]) != 0) {
 			print("bad `from' device %s in %s\n",
@@ -109,7 +110,7 @@
 		map->to =   strdup(fields[1]);
 		map->fdev = iconfig(fields[0]);
 		map->tdev = nil;
-		if (access(map->to, AEXIST) < 0) {
+		if(access(map->to, AEXIST) < 0) {
 			/*
 			 * map->to isn't an existing file, so it had better be
 			 * a config string for a device.
@@ -291,7 +292,7 @@
 	rfork(RFNOTEG);
 	formatinit();
 	machinit();
-	conf.confdev = "/dev/sdC0/cwfs";
+	conf.confdev = "/dev/sdC0/fscache";
 
 	rfd = sfd = -1;
 
@@ -330,6 +331,9 @@
 	case 'm':			/* name device-map file */
 		conf.devmap = EARGF(usage());
 		break;
+	case 'd':
+		chatty++;
+		break;
 	default:
 		usage();
 		break;
@@ -341,9 +345,11 @@
 	Binit(&bin, 0, OREAD);
 	confinit();
 
-	print("\nPlan 9 %d-bit cached-worm file server with %d-deep indir blks\n",
-		sizeof(Off)*8 - 1, NIBLOCK);
-	printsizes();
+	if(chatty){
+		print("\nPlan 9 %d-bit cached-worm file server with %d-deep indir blks\n",
+			sizeof(Off)*8 - 1, NIBLOCK);
+		printsizes();
+	}
 
 	qlock(&reflock);
 	qunlock(&reflock);
@@ -364,15 +370,12 @@
 	uid = malloc(conf.nuid * sizeof(*uid));
 	gidspace = malloc(conf.gidspace * sizeof(*gidspace));
 
-	print("iobufinit\n");
 	iobufinit();
 
 	arginit();
 	boottime = time(nil);
 
-	print("sysinit\n");
 	sysinit();
-
 	srvinit();
 
 	/*
@@ -509,11 +512,9 @@
 					cp->protocol = fsprotocol[i];
 					break;
 				}
-			if(cp->protocol == nil){
+			if(cp->protocol == nil && (chatty > 1)){
 				print("no protocol for message\n");
-				for(i = 0; i < 12; i++)
-					print(" %2.2uX", mb->data[i]);
-				print("\n");
+				hexdump(mb->data, 12);
 			}
 		} else
 			/* process the request, generate an answer and reply */
@@ -551,7 +552,7 @@
 {
 	Timet nddate = nextime(t+MINUTE(100), DUMPTIME, WEEKMASK);
 
-	if(!conf.nodump)
+	if(!conf.nodump && chatty)
 		print("next dump at %T\n", nddate);
 	return nddate;
 }
@@ -578,10 +579,6 @@
 		}
 		dt = time(nil) - t;
 		if(dt < 0 || dt > MINUTE(100)) {
-			if(dt < 0)
-				print("time went back\n");
-			else
-				print("time jumped ahead\n");
 			dorecalc = 1;
 			continue;
 		}
--- a/sys/src/cmd/cwfs/malloc.c
+++ b/sys/src/cmd/cwfs/malloc.c
@@ -57,7 +57,9 @@
 	wlock(&mainlock);	/* init */
 	wunlock(&mainlock);
 
-	prbanks();
+	if(chatty)
+		prbanks();
+
 	m = 0;
 	for(mbp = mconf.bank; mbp < &mconf.bank[mconf.nbank]; mbp++)
 		m += mbp->limit - mbp->base;
@@ -66,7 +68,8 @@
 	nhiob = niob / HWIDTH;
 	while(!prime(nhiob))
 		nhiob++;
-	print("\t%ld buffers; %ld hashes\n", niob, nhiob);
+	if(chatty)
+		print("\t%ld buffers; %ld hashes\n", niob, nhiob);
 	hiob = ialloc(nhiob * sizeof(Hiob), 0);
 	hp = hiob;
 	for(i=0; i<nhiob; i++) {
@@ -78,7 +81,6 @@
 	xiop = ialloc(niob * RBUFSIZE, 0);
 	hp = hiob;
 	for(i=0; i < niob; i++) {
-//		p->name = "buf";
 		qlock(p);
 		qunlock(p);
 		if(hp == hiob)
@@ -97,7 +99,6 @@
 		}
 		p->dev = devnone;
 		p->addr = -1;
-//		p->xiobuf = ialloc(RBUFSIZE, RBUFSIZE);
 		p->xiobuf = xiop;
 		p->iobuf = (char*)-1;
 		p++;
@@ -112,7 +113,8 @@
 	i = 0;
 	for(mbp = mconf.bank; mbp < &mconf.bank[mconf.nbank]; mbp++)
 		i += mbp->limit - mbp->base;
-	print("\tmem left = %,d, out of %,ld\n", i, conf.mem);
+	if(chatty)
+		print("\tmem left = %,d, out of %,ld\n", i, conf.mem);
 	/* paranoia: add this command as late as is easy */
 	cmd_install("memory", "-- print ranges of memory banks", cmd_memory);
 }
--- a/sys/src/cmd/cwfs/portdat.h
+++ b/sys/src/cmd/cwfs/portdat.h
@@ -768,3 +768,4 @@
 extern Biobuf	bin;
 extern Map	*devmap;
 extern int	(*fsprotocol[])(Msgbuf*);
+extern int	chatty;
--- a/sys/src/cmd/cwfs/srv.c
+++ b/sys/src/cmd/cwfs/srv.c
@@ -52,7 +52,8 @@
 	if(decref(srv))
 		return;
 
-	print("%s closed\n", srv->name);
+	if(chatty)
+		print("%s closed\n", srv->name);
 
 	chanhangup(srv->chan, "", 0);
 	memset(srv->buf, 0, sizeof(srv->buf));
@@ -70,8 +71,6 @@
 	Msgbuf *mb;
 	char buf[ERRMAX];
 
-	print("srvo\n");
-
 	for(;;){
 		mb = fs_recv(srvoq, 0);
 		if(mb == nil)
@@ -87,7 +86,7 @@
 			if(strstr(buf, "interrupt"))
 				continue;
 
-			if(buf[0])
+			if(buf[0] && chatty)
 				print("srvo %s: %s\n", srv->name, buf);
 			chanhangup(srv->chan, buf, 0);
 			break;
@@ -106,8 +105,6 @@
 	int n, m;
 	char buf[ERRMAX];
 
-	print("srvi %s\n", srv->name);
-
 	if((mb = mballoc(IOHDRSZ+Maxfdata, srv->chan, Mbeth1)) == nil)
 		panic("srvi %s: mballoc failed", srv->name);
 	b = mb->data;
@@ -154,7 +151,7 @@
 	if(strstr(buf, "interrupt"))
 		goto Read;
 
-	if(buf[0])
+	if(buf[0] && chatty)
 		print("srvi %s: %s\n", srv->name, buf);
 	chanhangup(srv->chan, buf, 0);
 	srvput(srv);
--- a/sys/src/cmd/cwfs/sub.c
+++ b/sys/src/cmd/cwfs/sub.c
@@ -187,7 +187,7 @@
 		return f;
 	} while(i != start);
 
-	print("out of files\n");
+	fprint(2, "out of files\n");
 	return 0;
 }
 
@@ -328,7 +328,7 @@
 		if(w >= ew)
 			w = &wpaths[0];
 		if(w == sw) {
-			print("out of wpaths\n");
+			fprint(2, "out of wpaths\n");
 			return 0;
 		}
 		if(w->refs)
@@ -466,7 +466,7 @@
 
 	p = getbuf(dev, superaddr(dev), Brd|Bmod);
 	if(!p || checktag(p, Tsuper, QPSUPER)) {
-		print("bufalloc: super block\n");
+		fprint(2, "bufalloc: super block\n");
 		if(p)
 			putbuf(p);
 		return 0;
@@ -477,7 +477,7 @@
 	n = --sb->fbuf.nfree;
 	sb->tfree--;
 	if(n < 0 || n >= FEPERBUF) {
-		print("bufalloc: %Z: bad freelist\n", dev);
+		fprint(2, "bufalloc: %Z: bad freelist\n", dev);
 		n = 0;
 		sb->fbuf.free[0] = 0;
 	}
@@ -495,7 +495,7 @@
 					goto loop;
 			}
 			putbuf(p);
-			print("fs %Z full uid=%d\n", dev, uid);
+			fprint(2, "fs %Z full uid=%d\n", dev, uid);
 			return 0;
 		}
 		bp = getbuf(dev, a, Brd);
@@ -955,7 +955,7 @@
 			sleep(1000);
 		if(!q->waitedfor) {
 			/* likely a bug; don't wait forever */
-			print("no readers yet for %s q\n", q->name);
+			fprint(2, "no readers yet for %s q\n", q->name);
 			abort();
 		}
 	}
@@ -1029,7 +1029,7 @@
 			return e;
 
 		case Devnone:
-			print("read from device none(%lld)\n", (Wideoff)b);
+			fprint(2, "read from device none(%lld)\n", (Wideoff)b);
 			return 1;
 		default:
 			panic("illegal device in devread: %Z %lld",
@@ -1059,7 +1059,7 @@
 			break;
 
 		case Devro:
-			print("write to ro device %Z(%lld)\n", d, (Wideoff)b);
+			fprint(2, "write to ro device %Z(%lld)\n", d, (Wideoff)b);
 			return 1;
 
 		case Devwren:
@@ -1206,10 +1206,11 @@
 	Device *l;
 
 loop:
-	print("\tdevream: %Z %d\n", d, top);
+	if(chatty)
+		print("\tdevream %Z %d\n", d, top);
 	switch(d->type) {
 	default:
-		print("ream: unknown dev type %Z\n", d);
+		fprint(2, "devream: unknown dev type %Z\n", d);
 		return;
 
 	case Devcw:
@@ -1262,10 +1263,11 @@
 devrecover(Device *d)
 {
 	for (;;) {
-		print("recover: %Z\n", d);
+		if(chatty)
+			print("recover %Z\n", d);
 		switch(d->type) {
 		default:
-			print("recover: unknown dev type %Z\n", d);
+			fprint(2, "devrecover: unknown dev type %Z\n", d);
 			return;
 
 		case Devcw:
@@ -1288,10 +1290,11 @@
 		if(d->init)
 			return;
 		d->init = 1;
-		print("\tdevinit %Z\n", d);
+		if(chatty)
+			print("\tdevinit %Z\n", d);
 		switch(d->type) {
 		default:
-			print("devinit unknown device %Z\n", d);
+			fprint(2, "devinit: unknown device %Z\n", d);
 			return;
 
 		case Devro:
@@ -1339,7 +1342,6 @@
 			break;
 
 		case Devnone:
-			print("devinit of Devnone\n");
 			return;
 		}
 	}
@@ -1429,18 +1431,9 @@
 
 	/* swab each block type */
 	switch(t->tag) {
-
 	default:
-		print("no swab for tag=%G rw=%d\n", t->tag, flag);
-		for(j=0; j<16; j++)
-			print(" %.2x", p[BUFSIZE+j]);
-		print("\n");
-		for(i=0; i<16; i++) {
-			print("%.4x", i*16);
-			for(j=0; j<16; j++)
-				print(" %.2x", p[i*16+j]);
-			print("\n");
-		}
+		fprint(2, "no swab for tag=%G rw=%d\n", t->tag, flag);
+		hexdump(p, 256);
 		panic("swab");
 		break;
 
--- a/sys/src/cmd/cwfs/wren.c
+++ b/sys/src/cmd/cwfs/wren.c
@@ -14,8 +14,6 @@
 	Devsize	nblock;			/* number of blocks -- from config */
 	long	mult;			/* multiplier to get physical blocks */
 	Devsize	max;			/* number of logical blocks */
-
-//	char	*sddir;			/* /dev/sdXX name */
 };
 
 char *
@@ -57,8 +55,9 @@
 
 	dr->block = inqsize(d->wren.sddata);
 	if(dr->block <= 0 || dr->block >= 16*1024) {
-		print("\twreninit %Z block size %ld, setting to %d\n",
-			d, dr->block, Sectorsz);
+		if(chatty)
+			print("\twreninit %Z block size %ld, setting to %d\n",
+				d, dr->block, Sectorsz);
 		dr->block = Sectorsz;
 	}
 
@@ -68,10 +67,12 @@
 
 	dr->mult = (RBUFSIZE + dr->block - 1) / dr->block;
 	dr->max = (dr->nblock + 1) / dr->mult;
-	print("\tdisk drive %Z: %,lld %ld-byte sectors, ",
-		d, (Wideoff)dr->nblock, dr->block);
-	print("%,lld %d-byte blocks\n", (Wideoff)dr->max, RBUFSIZE);
-	print("\t\t%ld multiplier\n", dr->mult);
+	if(chatty){
+		print("\tdisk drive %Z: %,lld %ld-byte sectors, ",
+			d, (Wideoff)dr->nblock, dr->block);
+		print("%,lld %d-byte blocks\n", (Wideoff)dr->max, RBUFSIZE);
+		print("\t\t%ld multiplier\n", dr->mult);
+	}
 }
 
 Devsize
@@ -89,10 +90,10 @@
 	if (dr == nil)
 		panic("wrenread: no drive (%Z) block %lld", d, (Wideoff)b);
 	if(b >= dr->max) {
-		print("wrenread: block out of range %Z(%lld)\n", d, (Wideoff)b);
+		fprint(2, "wrenread: block out of range %Z(%lld)\n", d, (Wideoff)b);
 		r = 0x040;
 	} else if (pread(d->wren.fd, c, RBUFSIZE, (vlong)b*RBUFSIZE) != RBUFSIZE) {
-		print("wrenread: error on %Z(%lld): %r\n", d, (Wideoff)b);
+		fprint(2, "wrenread: error on %Z(%lld): %r\n", d, (Wideoff)b);
 		cons.nwrenre++;
 		r = 1;
 	}
@@ -108,11 +109,11 @@
 	if (dr == nil)
 		panic("wrenwrite: no drive (%Z) block %lld", d, (Wideoff)b);
 	if(b >= dr->max) {
-		print("wrenwrite: block out of range %Z(%lld)\n",
+		fprint(2, "wrenwrite: block out of range %Z(%lld)\n",
 			d, (Wideoff)b);
 		r = 0x040;
 	} else if (pwrite(d->wren.fd, c, RBUFSIZE, (vlong)b*RBUFSIZE) != RBUFSIZE) {
-		print("wrenwrite: error on %Z(%lld): %r\n", d, (Wideoff)b);
+		fprint(2, "wrenwrite: error on %Z(%lld): %r\n", d, (Wideoff)b);
 		cons.nwrenwe++;
 		r = 1;
 	}