Browse Source

Plan 9 from Bell Labs 2003-08-23

David du Colombier 20 years ago
parent
commit
a9e6a8a1a9

+ 22 - 22
dist/replica/plan9.db

@@ -2752,7 +2752,7 @@ lib/tftpd - 20000000775 sys sys 944944178 0
 lib/unicode - 664 sys sys 958440028 223312
 lib/unicode.notice - 664 sys sys 958504386 1398
 lib/units - 664 sys sys 1014923483 9984
-lib/vgadb - 664 sys sys 1055701446 27652
+lib/vgadb - 664 sys sys 1061565169 27692
 lib/volcanoes - 664 sys sys 944944024 119831
 lib/words - 664 sys sys 1014923442 247097
 lp - 20000000775 sys sys 958199268 0
@@ -6851,7 +6851,7 @@ sys/src/cmd/aux/vga/tvp3026.c - 664 sys sys 1014925013 3580
 sys/src/cmd/aux/vga/tvp3026clock.c - 664 sys sys 1014925013 1960
 sys/src/cmd/aux/vga/vga.c - 664 sys sys 1014925013 9305
 sys/src/cmd/aux/vga/vga.h - 664 sys sys 1025416295 10154
-sys/src/cmd/aux/vga/virge.c - 664 sys sys 1048640341 17860
+sys/src/cmd/aux/vga/virge.c - 664 sys sys 1061565169 18440
 sys/src/cmd/aux/vga/vision864.c - 664 sys sys 1014925014 2325
 sys/src/cmd/aux/vga/vision964.c - 664 sys sys 1014925014 3426
 sys/src/cmd/aux/vga/vision968.c - 664 sys sys 1014925014 3959
@@ -7238,56 +7238,56 @@ sys/src/cmd/fmt.c - 664 sys sys 1025298248 3897
 sys/src/cmd/fortune.c - 664 sys sys 1035832953 1674
 sys/src/cmd/fossil - 20000000775 sys sys 1042005512 0
 sys/src/cmd/fossil/9.h - 664 sys sys 1055703747 4129
-sys/src/cmd/fossil/9auth.c - 664 sys sys 1050518977 3394
+sys/src/cmd/fossil/9auth.c - 664 sys sys 1061530721 3393
 sys/src/cmd/fossil/9dir.c - 664 sys sys 1042005502 1995
 sys/src/cmd/fossil/9excl.c - 664 sys sys 1042005502 1887
 sys/src/cmd/fossil/9fid.c - 664 sys sys 1045600016 5521
-sys/src/cmd/fossil/9fsys.c - 664 sys sys 1055703733 29755
+sys/src/cmd/fossil/9fsys.c - 664 sys sys 1061530721 29881
 sys/src/cmd/fossil/9lstn.c - 664 sys sys 1042005503 2865
-sys/src/cmd/fossil/9p.c - 664 sys sys 1055703732 21416
+sys/src/cmd/fossil/9p.c - 664 sys sys 1061530720 21414
 sys/src/cmd/fossil/9ping.c - 664 sys sys 1042005503 1563
-sys/src/cmd/fossil/9proc.c - 664 sys sys 1050518978 15245
+sys/src/cmd/fossil/9proc.c - 664 sys sys 1061530722 15243
 sys/src/cmd/fossil/9srv.c - 664 sys sys 1055703734 3589
-sys/src/cmd/fossil/9user.c - 664 sys sys 1055703735 17240
+sys/src/cmd/fossil/9user.c - 664 sys sys 1061530722 17239
 sys/src/cmd/fossil/Ccli.c - 664 sys sys 1042005504 1624
-sys/src/cmd/fossil/Ccmd.c - 664 sys sys 1050518979 7246
+sys/src/cmd/fossil/Ccmd.c - 664 sys sys 1061530723 7244
 sys/src/cmd/fossil/Ccons.c - 664 sys sys 1055703737 6620
 sys/src/cmd/fossil/Clog.c - 664 sys sys 1042005505 591
-sys/src/cmd/fossil/archive.c - 664 sys sys 1045600020 9112
+sys/src/cmd/fossil/archive.c - 664 sys sys 1061530723 9109
 sys/src/cmd/fossil/build - 664 sys sys 1042005505 449
 sys/src/cmd/fossil/buildsh - 775 sys sys 1042005505 561
 sys/src/cmd/fossil/bwatch.c - 664 sys sys 1042005505 6754
-sys/src/cmd/fossil/cache.c - 664 sys sys 1055703739 42854
+sys/src/cmd/fossil/cache.c - 664 sys sys 1061530724 42819
 sys/src/cmd/fossil/conf.rc - 775 sys sys 1055703747 1407
-sys/src/cmd/fossil/dat.h - 664 sys sys 1050518981 7855
+sys/src/cmd/fossil/dat.h - 664 sys sys 1061530727 7851
 sys/src/cmd/fossil/deadlock - 775 sys sys 1042005506 413
-sys/src/cmd/fossil/disk.c - 664 sys sys 1055703739 5809
+sys/src/cmd/fossil/disk.c - 664 sys sys 1061530724 5805
 sys/src/cmd/fossil/dump.c - 664 sys sys 1042005506 1340
 sys/src/cmd/fossil/epoch.c - 664 sys sys 1045600021 997
 sys/src/cmd/fossil/error.c - 664 sys sys 1042005507 1367
 sys/src/cmd/fossil/error.h - 664 sys sys 1042005507 744
-sys/src/cmd/fossil/file.c - 664 sys sys 1055703740 27846
-sys/src/cmd/fossil/flchk.c - 664 sys sys 1048859380 14275
-sys/src/cmd/fossil/flfmt.c - 664 sys sys 1048859380 10368
+sys/src/cmd/fossil/file.c - 664 sys sys 1061530725 27915
+sys/src/cmd/fossil/flchk.c - 664 sys sys 1061530720 14296
+sys/src/cmd/fossil/flfmt.c - 664 sys sys 1061530720 10358
 sys/src/cmd/fossil/flproto - 664 sys sys 1042005508 210
 sys/src/cmd/fossil/fns.h - 664 sys sys 1055703743 3039
 sys/src/cmd/fossil/fossil-acid - 664 sys sys 1042005508 3965
-sys/src/cmd/fossil/fossil.c - 664 sys sys 1055703731 2113
-sys/src/cmd/fossil/fs.c - 664 sys sys 1055703741 21075
+sys/src/cmd/fossil/fossil.c - 664 sys sys 1061530719 2112
+sys/src/cmd/fossil/fs.c - 664 sys sys 1061530725 21071
 sys/src/cmd/fossil/fs.h - 664 sys sys 1055703744 1398
 sys/src/cmd/fossil/history - 664 sys sys 1055703793 1400
 sys/src/cmd/fossil/invariants - 664 sys sys 1042005509 4073
 sys/src/cmd/fossil/mkfile - 664 sys sys 1055703730 1842
 sys/src/cmd/fossil/nobwatch.c - 664 sys sys 1042005509 329
-sys/src/cmd/fossil/pack.c - 664 sys sys 1042005510 4683
-sys/src/cmd/fossil/periodic.c - 664 sys sys 1042005510 1091
-sys/src/cmd/fossil/source.c - 664 sys sys 1055703742 18778
+sys/src/cmd/fossil/pack.c - 664 sys sys 1061530726 4682
+sys/src/cmd/fossil/periodic.c - 664 sys sys 1061530726 1087
+sys/src/cmd/fossil/source.c - 664 sys sys 1061530726 18771
 sys/src/cmd/fossil/srcload.c - 664 sys sys 1042005510 4178
 sys/src/cmd/fossil/stdinc.h - 664 sys sys 1042005510 155
 sys/src/cmd/fossil/trunc.c - 664 sys sys 1042005511 280
 sys/src/cmd/fossil/unpack - 775 sys sys 1042005511 286
-sys/src/cmd/fossil/vac.c - 664 sys sys 1042005511 12497
-sys/src/cmd/fossil/vac.h - 664 sys sys 1042005511 2782
+sys/src/cmd/fossil/vac.c - 664 sys sys 1061530727 12483
+sys/src/cmd/fossil/vac.h - 664 sys sys 1061530727 2779
 sys/src/cmd/fossil/view.c - 664 sys sys 1042005512 19708
 sys/src/cmd/fossil/walk.c - 664 sys sys 1042005512 963
 sys/src/cmd/freq.c - 664 sys sys 944961364 1682

+ 22 - 0
dist/replica/plan9.log

@@ -13056,3 +13056,25 @@
 1060664570 1 c sys/src/cmd/ndb/dnsdebug.c - 664 sys sys 1060663185 8430
 1060876871 0 c sys/src/cmd/htmlfmt/html.c - 664 sys sys 1060876449 6032
 1061497867 0 c sys/src/cmd/ip/ping.c - 664 sys sys 1061496964 5552
+1061532090 0 c sys/src/cmd/fossil/9auth.c - 664 sys sys 1061530721 3393
+1061532090 1 c sys/src/cmd/fossil/9fsys.c - 664 sys sys 1061530721 29881
+1061532090 2 c sys/src/cmd/fossil/9p.c - 664 sys sys 1061530720 21414
+1061532090 3 c sys/src/cmd/fossil/9proc.c - 664 sys sys 1061530722 15243
+1061532090 4 c sys/src/cmd/fossil/9user.c - 664 sys sys 1061530722 17239
+1061532090 5 c sys/src/cmd/fossil/Ccmd.c - 664 sys sys 1061530723 7244
+1061532090 6 c sys/src/cmd/fossil/archive.c - 664 sys sys 1061530723 9109
+1061532090 7 c sys/src/cmd/fossil/cache.c - 664 sys sys 1061530724 42819
+1061532090 8 c sys/src/cmd/fossil/dat.h - 664 sys sys 1061530727 7851
+1061532090 9 c sys/src/cmd/fossil/disk.c - 664 sys sys 1061530724 5805
+1061532090 10 c sys/src/cmd/fossil/file.c - 664 sys sys 1061530725 27915
+1061532090 11 c sys/src/cmd/fossil/flchk.c - 664 sys sys 1061530720 14296
+1061532090 12 c sys/src/cmd/fossil/flfmt.c - 664 sys sys 1061530720 10358
+1061532090 13 c sys/src/cmd/fossil/fossil.c - 664 sys sys 1061530719 2112
+1061532090 14 c sys/src/cmd/fossil/fs.c - 664 sys sys 1061530725 21071
+1061532090 15 c sys/src/cmd/fossil/pack.c - 664 sys sys 1061530726 4682
+1061532090 16 c sys/src/cmd/fossil/periodic.c - 664 sys sys 1061530726 1087
+1061532090 17 c sys/src/cmd/fossil/source.c - 664 sys sys 1061530726 18771
+1061532090 18 c sys/src/cmd/fossil/vac.c - 664 sys sys 1061530727 12483
+1061532090 19 c sys/src/cmd/fossil/vac.h - 664 sys sys 1061530727 2779
+1061566266 0 c lib/vgadb - 664 sys sys 1061565169 27692
+1061566266 1 c sys/src/cmd/aux/vga/virge.c - 664 sys sys 1061565169 18440

+ 2 - 0
lib/vgadb

@@ -659,6 +659,8 @@ t23 = 1400x1050							# 50Hz, ??.?KHz
 	clock=100
 	shb=1460 ehb=1644 ht=1820
 	vrs=1060 vre=1068 vt=1100
+t23 = 1280x1024
+	include=1280x1024@60Hz
 t23 = 1024x768
 	noclockset=1
 	include=1024x768

+ 16 - 1
sys/src/cmd/aux/vga/virge.c

@@ -153,6 +153,7 @@ snarf(Vga* vga, Ctlr* ctlr)
 	case 0x8A22:				/* Savage4 */
 	case 0x8A25:				/* ProSavage PN133 */
 	case 0x8A26:				/* ProSavage KN133 */
+	case 0x8D04:				/* ProSavage DDR, K.Okamoto */
 		vga->r[1] = 4;
 		vga->m[1] = 511;
 		vga->n[1] = 127;
@@ -187,6 +188,7 @@ options(Vga *vga, Ctlr* ctlr)
 	case 0x8A22:				/* Savage4 */
 	case 0x8A25:				/* ProSavage PN133 */
 	case 0x8A26:				/* ProSavage KN133 */
+	case 0x8D04:				/* ProSavabe DDR, K.Okamoto */
 		/*
 		 * Round up so stride is multiple of 16.
 		 */
@@ -409,7 +411,14 @@ init(Vga* vga, Ctlr* ctlr)
 		vga->crt[0x90] &= ~0x07;
 		vga->crt[0x90] |= (x>>8) & 0x07;
 
+	case 0x8D04:				/* ProSavage DDR, K.Okamoto */
+		x = mode->x * ((mode->z + 7) / 8);
+		x = (x + 7) / 8;
+		vga->crt[0x91] = x & 0xFF;
+		vga->crt[0x90] = (x >> 8) | 0x80;
+
 		/*FALLTHROUGH*/
+
 	case 0x8A22:				/* Savage4 */
 	case 0x8A25:				/* ProSavage PN133 */
 	case 0x8A26:				/* ProSavage KN133 */
@@ -428,7 +437,7 @@ init(Vga* vga, Ctlr* ctlr)
 		vga->crt[0x51] |= (width>>7) & 0x30;
 
 		/* pull screen width from GBD for graphics engine. */
-		vga->crt[0x50] = 0xC1;
+		vga->crt[0x50] = 0xC1;	/* set color mode */
 
 		/*
 		 * The high nibble is the mode; or'ing in 0x02 turns
@@ -515,6 +524,7 @@ init(Vga* vga, Ctlr* ctlr)
 		case 0x8A22:			/* Savage4 */
 		case 0x8A25:			/* ProSavage PN133 */
 		case 0x8A26:			/* ProSavage KN133 */
+		case 0x8D04:			/* ProSavage DDR, K.Okamoto */
 			vga->sequencer[0x12] = (vga->r[0]<<6)|(vga->n[0] & 0x3F);
 			vga->sequencer[0x39] &= ~0x01;
 			vga->sequencer[0x29] &= ~0x1C;
@@ -601,6 +611,7 @@ load(Vga* vga, Ctlr* ctlr)
 	case 0x8A22:				/* Savage4 */
 	case 0x8A25:				/* ProSavage PN133 */
 	case 0x8A26:				/* ProSavage KN133 */
+	case 0x8D04:				/* ProSavage DDR, K.Okamoto */
 		vgaxo(Seqx, 0x29, vga->sequencer[0x29]);
 		vgaxo(Seqx, 0x39, vga->sequencer[0x39]);
 		break;
@@ -636,6 +647,9 @@ load(Vga* vga, Ctlr* ctlr)
 		vgaxo(Crtx, 0x51, vga->crt[0x51]);
 		vgaxo(Crtx, 0x85, vga->crt[0x85]);
 		break;
+	case 0x8D04:				/* ProSavage DDR, K.Okamoto */
+		vgaxo(Crtx, 0x90, vga->crt[0x90]);		//K.Okamoto
+		vgaxo(Crtx, 0x91, vga->crt[0x91]);		//K.Okamoto
 	case 0x8C2E:				/* SuperSavage/IXC16 (let's try this -rsc) */
 	case 0x8C12:				/* Savage4/IX-MV */
 	case 0x8A22:				/* Savage4 */
@@ -706,6 +720,7 @@ dump(Vga* vga, Ctlr* ctlr)
 	case 0x8A22:				/* Savage4 */
 	case 0x8A25:				/* ProSavage PN133 */
 	case 0x8A26:				/* ProSavage KN133 */
+	case 0x8D04:				/* Prosavage DDR, K.Okamoto */
 		m = vga->sequencer[0x13] & 0xFF;
 		if(vga->sequencer[0x29] & (1<<3))
 			m |= 0x100;

+ 1 - 1
sys/src/cmd/fossil/9auth.c

@@ -79,7 +79,7 @@ authCheck(Fcall* t, Fid* fid, Fs* fsys)
 		 * If no authentication is asked for, allow
 		 * "none" provided the connection has already
 		 * been authenticatated.
-		 * 
+		 *
 		 * The console is allowed to attach without
 		 * authentication.
 		 */

+ 23 - 16
sys/src/cmd/fossil/9fsys.c

@@ -187,7 +187,7 @@ static ulong modebits[] = {
 	ModeSnapshot,
 	0
 };
-	
+
 char*
 fsysModeString(ulong mode, char *buf)
 {
@@ -675,7 +675,7 @@ fsysBlock(Fsys* fsys, int argc, char* argv[])
 		return 0;
 	}
 
-	consPrint("\t%sblock %#ux %ud %ud %.*H\n", 
+	consPrint("\t%sblock %#ux %ud %ud %.*H\n",
 		argc==4 ? "old: " : "", addr, offset, count, count, b->data+offset);
 
 	if(argc == 4){
@@ -702,7 +702,7 @@ fsysBlock(Fsys* fsys, int argc, char* argv[])
 			buf[i>>1] |= c;
 		}
 		memmove(b->data+offset, buf, count);
-		consPrint("\tnew: block %#ux %ud %ud %.*H\n", 
+		consPrint("\tnew: block %#ux %ud %ud %.*H\n",
 			addr, offset, count, count, b->data+offset);
 		blockDirty(b);
 	}
@@ -929,7 +929,7 @@ fsysEsearch1(File* f, char* s, u32int elo)
 
 	return n;
 }
-			
+
 static int
 fsysEsearch(Fs* fs, char* path, u32int elo)
 {
@@ -996,7 +996,7 @@ fsysEpoch(Fsys* fsys, int argc, char* argv[])
 	 * There's a small race here -- a new snapshot with epoch < low might
 	 * get introduced now that we unlocked fs->elk.  Low has to
 	 * be <= fs->ehi.  Of course, in order for this to happen low has
-	 * to be equal to the current fs->ehi _and_ a snapshot has to 
+	 * to be equal to the current fs->ehi _and_ a snapshot has to
 	 * run right now.  This is a small enough window that I don't care.
 	 */
 	if(n != 0 && !force){
@@ -1074,7 +1074,7 @@ fsysCreate(Fsys* fsys, int argc, char* argv[])
 	}
 
 	if(strcmp(de.gid, argv[2]) != 0){
-		vtMemFree(de.gid);		
+		vtMemFree(de.gid);
 		de.gid = vtStrDup(argv[2]);
 		if(!fileSetDir(file, &de, argv[1])){
 			vtSetError("wstat failed after create: %R");
@@ -1088,7 +1088,7 @@ out2:
 out1:
 	fileDecRef(file);
 out:
-	vtMemFree(path);	
+	vtMemFree(path);
 	vtRUnlock(fsys->fs->elk);
 
 	return r;
@@ -1271,13 +1271,16 @@ fsysVenti(char* name, int argc, char* argv[])
 
 	/* already open: do a redial */
 	if(fsys->fs != nil){
+		if(fsys->session == nil){
+			vtSetError("file system was opened with -V");
+			r = 0;
+			goto out;
+		}
 		r = 1;
 		if(!vtRedial(fsys->session, host)
 		|| !vtConnect(fsys->session, 0))
 			r = 0;
-		vtUnlock(fsys->lock);
-		fsysPut(fsys);
-		return r;
+		goto out;
 	}
 
 	/* not yet open: try to dial */
@@ -1287,6 +1290,7 @@ fsysVenti(char* name, int argc, char* argv[])
 	if((fsys->session = vtDial(host, 0)) == nil
 	|| !vtConnect(fsys->session, 0))
 		r = 0;
+out:
 	vtUnlock(fsys->lock);
 	fsysPut(fsys);
 	return r;
@@ -1298,11 +1302,11 @@ fsysOpen(char* name, int argc, char* argv[])
 	char *p, *host;
 	Fsys *fsys;
 	long ncache;
-	int noauth, noperm, rflag, wstatallow;
-	char *usage = "usage: fsys name open [-APWr] [-c ncache]";
+	int noauth, noventi, noperm, rflag, wstatallow;
+	char *usage = "usage: fsys name open [-APVWr] [-c ncache]";
 
 	ncache = 1000;
-	noauth = noperm = wstatallow = 0;
+	noauth = noperm = wstatallow = noventi = 0;
 	rflag = OReadWrite;
 
 	ARGBEGIN{
@@ -1314,6 +1318,9 @@ fsysOpen(char* name, int argc, char* argv[])
 	case 'P':
 		noperm = 1;
 		break;
+	case 'V':
+		noventi = 1;
+		break;
 	case 'W':
 		wstatallow = 1;
 		break;
@@ -1349,7 +1356,7 @@ fsysOpen(char* name, int argc, char* argv[])
 		else
 			host = nil;
 		fsys->session = vtDial(host, 1);
-		if(!vtConnect(fsys->session, nil))
+		if(!vtConnect(fsys->session, nil) && !noventi)
 			fprint(2, "warning: connecting to venti: %R\n");
 	}
 	if((fsys->fs = fsOpen(fsys->dev, fsys->session, ncache, rflag)) == nil){
@@ -1468,14 +1475,14 @@ static struct {
 	{ "clri",	fsysClri, },
 	{ "clrp",	fsysClrp, },
 	{ "create",	fsysCreate, },
-	{ "df",	fsysDf, },
+	{ "df",		fsysDf, },
 	{ "epoch",	fsysEpoch, },
 	{ "halt",	fsysHalt, },
 	{ "label",	fsysLabel, },
 	{ "remove",	fsysRemove, },
 	{ "snap",	fsysSnap, },
 	{ "snaptime",	fsysSnapTime, },
-	{ "snapclean", fsysSnapClean, },
+	{ "snapclean",	fsysSnapClean, },
 	{ "stat",	fsysStat, },
 	{ "sync",	fsysSync, },
 	{ "unhalt",	fsysUnhalt, },

+ 2 - 2
sys/src/cmd/fossil/9p.c

@@ -293,7 +293,7 @@ rTwstat(Msg* m)
 	/*
 	 * Check for permission to change group, must be
 	 * either owner and in new group or leader of both groups.
-	 * If gid is nil here then 
+	 * If gid is nil here then
 	 */
 	if(strcmp(gid, de.gid) != 0){
 		if(!fsysWstatAllow(fid->fsys)
@@ -501,7 +501,7 @@ rTwrite(Msg* m)
 		n = fileWrite(fid->file, m->t.data, count, m->t.offset, fid->uid);
 	if(n < 0)
 		goto error;
-	
+
 
 	m->r.count = n;
 

+ 2 - 2
sys/src/cmd/fossil/9proc.c

@@ -335,7 +335,7 @@ msgProc(void*)
 			else
 				e = "Tversion aborted";
 		}
-		else if(con->state != ConUp)	
+		else if(con->state != ConUp)
 			e = "connection not ready";
 		vtUnlock(con->lock);
 
@@ -769,7 +769,7 @@ cmdWho(int argc, char* argv[])
 	}
 	vtRUnlock(cbox.clock);
 	return 1;
-}	
+}
 
 void
 msgInit(void)

+ 1 - 1
sys/src/cmd/fossil/9user.c

@@ -548,7 +548,7 @@ uboxInit(char* users, int len)
 			comment = 1;
 		blank = 0;
 		if(!comment)
-			*p++ = *q;	
+			*p++ = *q;
 	}
 	*p = '\0';
 

+ 1 - 1
sys/src/cmd/fossil/Ccmd.c

@@ -413,7 +413,7 @@ cmdInit(void)
 		close(cbox.confd[1]);
 		cbox.confd[0] = cbox.confd[1] = -1;
 		return 0;
-		
+
 	}
 	cbox.con->isconsole = 1;
 

+ 3 - 3
sys/src/cmd/fossil/archive.c

@@ -88,11 +88,11 @@ ventiSend(Arch *a, Block *b, uchar *data)
 	if(!vtSync(a->z))
 		return 0;
 	return 1;
-}	
+}
 
 /*
  * parameters for recursion; there are so many,
- * and some only change occasionally.  this is 
+ * and some only change occasionally.  this is
  * easier than spelling things out at each call.
  */
 typedef struct Param Param;
@@ -365,7 +365,7 @@ sleep(10*1000);	/* window of opportunity to provoke races */
 		p.dsize = 3*VtEntrySize;	/* root has three Entries */
 		p.c = a->c;
 		p.a = a;
-	
+
 		ret = archWalk(&p, addr, BtDir, RootTag);
 		switch(ret){
 		default:

+ 30 - 30
sys/src/cmd/fossil/cache.c

@@ -75,7 +75,7 @@ struct BList {
 	u32int tag;
 	u32int epoch;
 	u32int vers;
-	
+
 	/* for roll back */
 	int index;			/* -1 indicates not valid */
 	union {
@@ -137,7 +137,7 @@ int vtType[BtMax] = {
 };
 
 /*
- * Allocate the memory cache. 
+ * Allocate the memory cache.
  */
 Cache *
 cacheAlloc(Disk *disk, VtSession *z, ulong nblocks, int mode)
@@ -267,7 +267,7 @@ cacheFree(Cache *c)
 
 static void
 cacheDump(Cache *c)
-{	
+{
 	int i;
 	Block *b;
 
@@ -364,7 +364,7 @@ cacheBumpBlock(Cache *c)
 		b->prev = nil;
 	}
 
- 	
+
 if(0)fprint(2, "droping %d:%x:%V\n", b->part, b->addr, b->score);
 	/* set block to a reasonable state */
 	b->ref = 1;
@@ -422,7 +422,7 @@ _cacheLocalLookup(Cache *c, int part, u32int addr, u32int vers,
 			abort();
 		case BioEmpty:
 		case BioLabel:
-		case BioClean:	
+		case BioClean:
 		case BioDirty:
 			if(b->vers != vers){
 				blockPut(b);
@@ -481,7 +481,7 @@ fprint(2, "_cacheLocal want epoch %ud got %ud\n", epoch, b->l.epoch);
 		b->ref++;
 		break;
 	}
-			
+
 	if(b == nil){
 		b = cacheBumpBlock(c);
 
@@ -503,7 +503,7 @@ fprint(2, "_cacheLocal want epoch %ud got %ud\n", epoch, b->l.epoch);
 	 * BUG: what if the epoch changes right here?
 	 * In the worst case, we could end up in some weird
 	 * lock loop, because the block we want no longer exists,
-	 * and instead we're trying to lock a block we have no 
+	 * and instead we're trying to lock a block we have no
 	 * business grabbing.
 	 *
 	 * For now, I'm not going to worry about it.
@@ -661,7 +661,7 @@ if(0)fprint(2, "cacheGlobal %V %d\n", score, type);
 		}
 		vtZeroExtend(vtType[type], b->data, n, c->size);
 		blockSetIOState(b, BioClean);
-		return b;	
+		return b;
 	case BioClean:
 		return b;
 	case BioVentiError:
@@ -932,7 +932,7 @@ if(0)fprint(2, "blockPut: %d: %d %x %d %s\n", getpid(), b->part, b->addr, c->nhe
 	 * b->nlock should probably stay at zero while
 	 * the block is unlocked, but diskThread and vtSleep
 	 * conspire to assume that they can just vtLock(b->lk); blockPut(b),
-	 * so we have to keep b->nlock set to 1 even 
+	 * so we have to keep b->nlock set to 1 even
 	 * when the block is unlocked.
 	 */
 	assert(b->nlock == 0);
@@ -990,7 +990,7 @@ blockCleanup(Block *b, u32int epoch)
 	bwatchReset(b->score);
 
 	blockSetIOState(b, BioClean);
-	
+
 	/* do not recursively free directories */
 	if(type == BtData || type == BtDir)
 		return;
@@ -1091,7 +1091,7 @@ blistAlloc(Block *b)
 		assert(b->iostate == BioClean);
 		return nil;
 	}
-		
+
 	/*
 	 * Easy: maybe there's a free list left.
 	 */
@@ -1162,7 +1162,7 @@ blockFlush(Block *b)
 //fprint(2, "blockFlush %p\n", b);
 
 	c = b->c;
-	
+
 	first = 1;
 	pp = &b->prior;
 	for(p=*pp; p; p=*pp){
@@ -1218,7 +1218,7 @@ blockDependency(Block *b, Block *bb, int index, uchar *score, Entry *e)
 	/*
 	 * Dependencies for blocks containing Entry structures
 	 * or scores must always be explained.  The problem with
-	 * only explaining some of them is this.  Suppose we have two 
+	 * only explaining some of them is this.  Suppose we have two
 	 * dependencies for the same field, the first explained
 	 * and the second not.  We try to write the block when the first
 	 * dependency is not written but the second is.  We will roll back
@@ -1235,7 +1235,7 @@ blockDependency(Block *b, Block *bb, int index, uchar *score, Entry *e)
 
 	p = blistAlloc(bb);
 	if(p == nil)
-		return;	
+		return;
 
 if(0)fprint(2, "%d:%x:%d depends on %d:%x:%d\n", b->part, b->addr, b->l.type, bb->part, bb->addr, bb->l.type);
 
@@ -1298,7 +1298,7 @@ blockDirty(Block *b)
 
 /*
  * Block b once pointed at the block bb at addr/type/tag, but no longer does.
- * 
+ *
  * The file system maintains the following invariants (i-iv checked by flchk):
  *
  * (i) b.e in [bb.e, bb.eClose)
@@ -1312,7 +1312,7 @@ blockDirty(Block *b)
  *
  * Condition (i) lets us reclaim blocks once the low epoch is greater
  * than epochClose.
- * 
+ *
  * If the condition in (iii) is satisfied, then this is the only pointer to bb,
  * so bb can be reclaimed once b has been written to disk.  blockRemoveLink
  * checks !(b.state&Copied) as an optimization.  UnlinkBlock and blockCleanup
@@ -1350,11 +1350,11 @@ blockRemoveLink(Block *b, u32int addr, int type, u32int tag)
 	 * Because bl != nil, we know b is dirty.
 	 * (Linking b->uhead onto a clean block is
 	 * counterproductive, since we only look at
-	 * b->uhead when a block transitions from 
+	 * b->uhead when a block transitions from
 	 * dirty to clean.)
 	 */
 	assert(b->iostate == BioDirty);
-	
+
 	bl->part = PartData;
 	bl->addr = addr;
 	bl->type = type;
@@ -1362,7 +1362,7 @@ blockRemoveLink(Block *b, u32int addr, int type, u32int tag)
 	bl->epoch = b->l.epoch;
 	if(b->uhead == nil)
 		b->uhead = bl;
-	else 
+	else
 		b->utail->next = bl;
 	b->utail = bl;
 	bl->next = nil;
@@ -1411,9 +1411,9 @@ blockSetLabel(Block *b, Label *l)
 	/*
 	 * If we're allocating the block, make sure the label (bl)
 	 * goes to disk before the data block (b) itself.  This is to help
-	 * the blocks that in turn depend on b. 
+	 * the blocks that in turn depend on b.
 	 *
-	 * Suppose bx depends on (must be written out after) b.  
+	 * Suppose bx depends on (must be written out after) b.
 	 * Once we write b we'll think it's safe to write bx.
 	 * Bx can't get at b unless it has a valid label, though.
 	 *
@@ -1450,7 +1450,7 @@ blockRollback(Block *b, uchar *buf)
 	/* easy case */
 	if(b->prior == nil)
 		return b->data;
-	
+
 	memmove(buf, b->data, b->c->size);
 	for(p=b->prior; p; p=p->next){
 		/*
@@ -1479,9 +1479,9 @@ blockRollback(Block *b, uchar *buf)
 }
 
 /*
- * Try to write block b. 
+ * Try to write block b.
  * If b depends on other blocks:
- * 
+ *
  *	If the block has been written out, remove the dependency.
  *	If the dependency is replaced by a more recent dependency,
  *		throw it out.
@@ -1526,7 +1526,7 @@ blockWrite(Block *b)
 
 		/*
 		 * same version of block is still in cache.
-		 * 
+		 *
 		 * the assertion is true because the block still has version p->vers,
 		 * which means it hasn't been written out since we last saw it.
 		 */
@@ -1574,7 +1574,7 @@ blockSetIOState(Block *b, int iostate)
 	BList *p, *q;
 
 if(0) fprint(2, "iostate part=%d addr=%x %s->%s\n", b->part, b->addr, bioStr(b->iostate), bioStr(iostate));
-	
+
 	c = b->c;
 
 	dowakeup = 0;
@@ -1776,7 +1776,7 @@ upHeap(int i, Block *b)
 	u32int now;
 	int p;
 	Cache *c;
-	
+
 	c = b->c;
 	now = c->now;
 	for(; i != 0; i = p){
@@ -1800,7 +1800,7 @@ downHeap(int i, Block *b)
 	u32int now;
 	int k;
 	Cache *c;
-	
+
 	c = b->c;
 	now = c->now;
 	for(; ; i = k){
@@ -1984,14 +1984,14 @@ flushFill(Cache *c)
 		c->ndirty = ndirty;
 	}
 	vtUnlock(c->lk);
-	
+
 	c->bw = p - c->baddr;
 	qsort(c->baddr, c->bw, sizeof(BAddr), baddrCmp);
 }
 
 /*
  * This is not thread safe, i.e. it can't be called from multiple threads.
- * 
+ *
  * It's okay how we use it, because it only gets called in
  * the flushThread.  And cacheFree, but only after
  * cacheFree has killed off the flushThread.

+ 4 - 4
sys/src/cmd/fossil/dat.h

@@ -114,7 +114,7 @@ struct Source {
 	VtLock *lk;
 	int ref;
 	/*
-	 * epoch for the source 
+	 * epoch for the source
 	 * for ReadWrite sources, epoch is used to lazily notice
 	 * sources that must be split from the snapshots.
 	 * for ReadOnly sources, the epoch represents the minimum epoch
@@ -184,7 +184,7 @@ enum {
  * Transitions
  *	Archiver at generation g
  *	Mutator at generation h
- *	
+ *
  *	Want to modify a block
  *		Venti: create new Active(h)
  *		Active(x): x == h: do nothing
@@ -205,7 +205,7 @@ enum {
  *
  */
 
-/* 
+/*
  * block types
  * more regular than Venti block types
  * bit 3 -> block or data block
@@ -246,7 +246,7 @@ struct Block {
 	ulong	pc;		/* pc that fetched this block from the cache */
 
 	VtLock *lk;
-	
+
 	int 	part;
 	u32int	addr;
 	uchar	score[VtScoreSize];	/* score */

+ 3 - 3
sys/src/cmd/fossil/disk.c

@@ -34,7 +34,7 @@ diskAlloc(int fd)
 	u8int buf[HeaderSize];
 	Header h;
 	Disk *disk;
-	
+
 	if(pread(fd, buf, HeaderSize, HeaderOffset) < HeaderSize){
 		vtSetError("short read: %r");
 		vtOSError();
@@ -191,7 +191,7 @@ diskQueue(Disk *disk, Block *b)
 			break;
 		bp = &bb->ionext;
 	}
-	b->ionext = bb;	
+	b->ionext = bb;
 	*bp = b;
 	if(disk->nqueue == 0)
 		vtWakeup(disk->starve);
@@ -320,7 +320,7 @@ fprint(2, "diskWriteRaw failed: date=%s part=%d addr=%ux: %r\n", ctime(times(0))
 				blockSetIOState(b, BioDirty);
 			break;
 		}
-		
+
 		blockPut(b);		/* remove extra reference, unlock */
 		vtLock(disk->lk);
 		disk->nqueue--;

+ 25 - 22
sys/src/cmd/fossil/file.c

@@ -62,10 +62,10 @@ static void
 fileFree(File *f)
 {
 	sourceClose(f->source);
-	vtLockFree(f->lk);	
+	vtLockFree(f->lk);
 	sourceClose(f->msource);
 	deCleanup(&f->dir);
-	
+
 	memset(f, ~0, sizeof(File));
 	vtMemFree(f);
 }
@@ -108,7 +108,7 @@ dirLookup(File *f, char *elem)
 			ff->mode = f->mode;
 			return ff;
 		}
-		
+
 		blockPut(b);
 		b = nil;
 	}
@@ -191,7 +191,7 @@ Err:
 		sourceClose(r2);
 	if(mr)
 		fileFree(mr);
-	if(root)		
+	if(root)
 		fileFree(root);
 	sourceUnlock(r);
 
@@ -274,7 +274,7 @@ _fileWalk(File *f, char *elem, int partial)
 		 * Usually the sources can't be opened, hence we won't even bother.
 		 * Be VERY careful with the returned file.  If you hand it to a routine
 		 * expecting ff->source and/or ff->msource to be non-nil, we're
-		 * likely to dereference nil.  FileClri should be the only routine 
+		 * likely to dereference nil.  FileClri should be the only routine
 		 * setting partial.
 		 */
 		ff->partial = 1;
@@ -692,7 +692,7 @@ fileSetDir(File *f, DirEntry *dir, char *uid)
 				goto Err;
 			}
 		}
-	
+
 		ff = dirLookup(f->up, dir->elem);
 		if(ff != nil){
 			fileDecRef(ff);
@@ -759,7 +759,7 @@ Err:
 
 int
 fileSetQidSpace(File *f, u64int offset, u64int max)
-{	
+{
 	int ret;
 
 	if(!fileLock(f))
@@ -786,7 +786,7 @@ ulong
 fileGetMcount(File *f)
 {
 	ulong mcount;
-	
+
 	fileMetaLock(f);
 	mcount = f->dir.mcount;
 	fileMetaUnlock(f);
@@ -797,7 +797,7 @@ ulong
 fileGetMode(File *f)
 {
 	ulong mode;
-	
+
 	fileMetaLock(f);
 	mode = f->dir.mode;
 	fileMetaUnlock(f);
@@ -896,6 +896,9 @@ fileMetaFlush2(File *f, char *oelem)
 
 	if(!sourceLock(fp->msource, -1))
 		return 0;
+	/* can happen if source is clri'ed out from under us */
+	if(f->boff == NilBlock)
+		goto Err1;
 	b = sourceBlock(fp->msource, f->boff, OReadWrite);
 	if(b == nil)
 		goto Err1;
@@ -915,7 +918,7 @@ if(0)fprint(2, "old size %d new size %d\n", me.size, n);
 			mbSearch(&mb, f->dir.elem, &i, &me2);
 		dePack(&f->dir, &me);
 		mbInsert(&mb, i, &me);
-		mbPack(&mb);	
+		mbPack(&mb);
 		blockDirty(b);
 		blockPut(b);
 		sourceUnlock(fp->msource);
@@ -936,17 +939,17 @@ if(0)fprint(2, "old size %d new size %d\n", me.size, n);
 	boff = fileMetaAlloc(fp, &f->dir, f->boff+1);
 	if(boff == NilBlock){
 		/* mbResize might have modified block */
-		mbPack(&mb);	
+		mbPack(&mb);
 		blockDirty(b);
 		goto Err;
-	}	
+	}
 fprint(2, "fileMetaFlush moving entry from %ud -> %ud\n", f->boff, boff);
 	f->boff = boff;
 
 	/* make sure deletion goes to disk after new entry */
 	bb = sourceBlock(fp->msource, f->boff, OReadWrite);
 	mbDelete(&mb, i);
-	mbPack(&mb);	
+	mbPack(&mb);
 	blockDependency(b, bb, -1, nil, nil);
 	blockPut(bb);
 	blockDirty(b);
@@ -1000,7 +1003,7 @@ fprint(2, "S\n");
 
 	blockDirty(b);
 	blockPut(b);
-	
+
 	f->removed = 1;
 	f->boff = NilBlock;
 	f->dirty = 0;
@@ -1066,7 +1069,7 @@ fileRemove(File *f, char *uid)
 		goto Err1;
 	if(fileIsDir(f) && !fileCheckEmpty(f))
 		goto Err;
-		
+
 	for(ff=f->down; ff; ff=ff->next)
 		assert(ff->removed);
 
@@ -1081,9 +1084,9 @@ fileRemove(File *f, char *uid)
 
 	if(!fileMetaRemove(f, uid))
 		return 0;
-	
+
 	return 1;
-		
+
 Err:
 	sourceUnlock(f->source);
 	if(f->msource)
@@ -1132,7 +1135,7 @@ fileIncRef(File *vf)
 	return vf;
 }
 
-int 
+int
 fileDecRef(File *f)
 {
 	File *p, *q, **qq;
@@ -1222,14 +1225,14 @@ dirEntrySize(Source *s, ulong elem, ulong gen, uvlong *size)
 		goto Err;
 	if(!entryUnpack(&e, b->data, elem))
 		goto Err;
-	
+
 	/* hanging entries are returned as zero size */
 	if(!(e.flags & VtEntryActive) || e.gen != gen)
 		*size = 0;
 	else
 		*size = e.size;
 	blockPut(b);
-	return 1;	
+	return 1;
 
 Err:
 	blockPut(b);
@@ -1317,7 +1320,7 @@ deeRead(DirEntryEnum *dee, DirEntry *de)
 			goto Return;
 		}
 	}
-	
+
 	memmove(de, dee->buf + dee->i, sizeof(DirEntry));
 	dee->i++;
 	ret = 1;
@@ -1424,7 +1427,7 @@ fileMetaAlloc(File *f, DirEntry *dir, u32int start)
 		blockDependency(b, bb, -1, nil, nil);
 		blockPut(bb);
 	}
-	
+
 	blockDirty(b);
 	blockPut(b);
 	return bo;

+ 8 - 6
sys/src/cmd/fossil/flchk.c

@@ -54,6 +54,8 @@ main(int argc, char *argv[])
 		usage();
 	case 'c':
 		csize = atoi(ARGF());
+		if(csize <= 0)
+			usage();
 		break;
 	case 'd':
 		dumpblocks = 1;
@@ -289,7 +291,7 @@ chkEpoch(u32int epoch)
 	Block *b;
 
 	print("chkEpoch %ud\n", epoch);
-	
+
 	/* find root block */
 	for(a=0; a<nblocks; a++){
 		if(!readLabel(&l, (a+hint)%nblocks)){
@@ -394,7 +396,7 @@ chkFree(void)
 
 static Source *
 openSource(Source *s, char *name, uchar *bm, u32int offset, u32int gen, int dir)
-{	
+{
 	Source *r;
 
 	if(getBit(bm, offset)){
@@ -442,7 +444,7 @@ offsetCmp(void *s0, void *s1)
 	return 0;
 }
 
-/* 
+/*
  * Check that MetaBlock has reasonable header, sorted entries,
  */
 int
@@ -521,7 +523,7 @@ chkDir(char *name, Source *source, Source *meta)
 	}
 
 	bm = vtMemAllocZ(sourceGetDirSize(source)/8 + 1);
-	
+
 	nb = (sourceGetSize(meta) + meta->dsize - 1)/meta->dsize;
 	for(o=0; o<nb; o++){
 		b = sourceBlock(meta, o, OReadOnly);
@@ -576,7 +578,7 @@ if(0)fprint(2, "source %V:%d block %d addr %d\n", source->score, source->offset,
 				free(nn);
 				continue;
 			}
-			
+
 			chkDir(nn, r, mr);
 
 			sourceClose(mr);
@@ -605,7 +607,7 @@ if(0)fprint(2, "source %V:%d block %d addr %d\n", source->score, source->offset,
 		}
 		sourceClose(r);
 	}
-	
+
 	sourceUnlock(source);
 	sourceUnlock(meta);
 	vtMemFree(bm);

+ 9 - 9
sys/src/cmd/fossil/flfmt.c

@@ -48,7 +48,7 @@ main(int argc, char *argv[])
 {
 	int fd, force;
 	Header h;
-	ulong bn;	
+	ulong bn;
 	Entry e;
 	char *label = "vfs";
 	char *host = nil;
@@ -88,7 +88,7 @@ main(int argc, char *argv[])
 
 	if(argc != 1)
 		usage();
-		
+
 	vtAttach();
 
 	fmtinstall('V', scoreFmt);
@@ -110,7 +110,7 @@ main(int argc, char *argv[])
 	if((d = dirfstat(fd)) == nil)
 		vtFatal("dirfstat: %r");
 
-	if(d->type == 'M' && !force 
+	if(d->type == 'M' && !force
 	&& !confirm("fs file is mounted via devmnt (is not a kernel device); are you sure?"))
 		goto Out;
 
@@ -184,11 +184,11 @@ partition(int fd, int bsize, Header *h)
 	lpb = bsize/LabelSize;
 
 	nblock = fdsize(fd)/bsize;
-	
+
 	/* sanity check */
 	if(nblock < (HeaderOffset*10)/bsize)
 		vtFatal("file too small");
-	
+
 	h->super = (HeaderOffset + 2*bsize)/bsize;
 	h->label = h->super + 1;
 	ndata = ((u64int)lpb)*(nblock - h->label)/(lpb+1);
@@ -292,7 +292,7 @@ rootInit(Entry *e)
 	entryInit(e);
 	e->flags |= VtEntryDir;
 	entryPack(e, buf, 0);
-	
+
 	entryInit(e);
 	entryPack(e, buf, 1);
 
@@ -313,7 +313,7 @@ rootInit(Entry *e)
 	return addr;
 }
 
-	
+
 static u32int
 blockAlloc(int type, u32int tag)
 {
@@ -347,7 +347,7 @@ superInit(char *label, u32int root, uchar score[VtScoreSize])
 	s.epochLow = 1;
 	s.epochHigh = 1;
 	s.qid = qid;
-	s.active = root;	
+	s.active = root;
 	s.next = NilBlock;
 	s.current = NilBlock;
 	strecpy(s.name, s.name+sizeof(s.name), label);
@@ -544,7 +544,7 @@ parseScore(uchar *score, char *buf)
 
 		if((i & 1) == 0)
 			c <<= 4;
-	
+
 		score[i>>1] |= c;
 	}
 	return 1;

+ 1 - 1
sys/src/cmd/fossil/fossil.c

@@ -25,7 +25,7 @@ readCmdPart(char *file, char ***pcmd, int *pncmd)
 	int i, fd, n;
 	char **cmd;
 	int ncmd;
-	
+
 	cmd = *pcmd;
 	ncmd = *pncmd;
 

+ 9 - 9
sys/src/cmd/fossil/fs.c

@@ -35,7 +35,7 @@ fsOpen(char *file, VtSession *z, long ncache, int mode)
 		return nil;
 	}
 
-	bwatchInit();	
+	bwatchInit();
 	disk = diskAlloc(fd);
 	if(disk == nil){
 		vtSetError("diskAlloc: %R");
@@ -48,7 +48,7 @@ fsOpen(char *file, VtSession *z, long ncache, int mode)
 	fs->blockSize = diskBlockSize(disk);
 	fs->elk = vtLockAlloc();
 	fs->cache = cacheAlloc(disk, z, ncache, mode);
-	if(mode == OReadWrite)
+	if(mode == OReadWrite && z)
 		fs->arch = archInit(fs->cache, disk, fs, z);
 	fs->z = z;
 
@@ -235,7 +235,7 @@ fileOpenSnapshot(Fs *fs, int doarchive)
 	Tm now;
 
 	if(doarchive){
-		/* 
+		/*
 		 * a snapshot intended to be archived to venti.
 		 */
 		dir = fileOpen(fs, "/archive");
@@ -443,11 +443,11 @@ bumpEpoch(Fs *fs, int doarchive)
 	 * We force the super block to disk so that super.epochHigh gets updated.
 	 * Otherwise, if we crash and come back, we might incorrectly treat as active
 	 * some of the blocks that making up the snapshot we just created.
-	 * Basically every block in the active file system and all the blocks in 
+	 * Basically every block in the active file system and all the blocks in
 	 * the recently-created snapshot depend on the super block now.
 	 * Rather than record all those dependencies, we just force the block to disk.
 	 *
-	 * Note that blockWrite might actually (will probably) send a slightly outdated 
+	 * Note that blockWrite might actually (will probably) send a slightly outdated
 	 * super.active to disk.  It will be the address of the most recent root that has
 	 * gone to disk.
 	 */
@@ -478,7 +478,7 @@ int
 fsSnapshot(Fs *fs, int doarchive)
 {
 	File *src, *dst;
-	
+
 	assert(fs->mode == OReadWrite);
 
 	dst = nil;
@@ -504,11 +504,11 @@ fsSnapshot(Fs *fs, int doarchive)
 	 * It is important that we maintain the invariant that:
 	 *	if both b and bb are marked as Active with epoch e
 	 *	and b points at bb, then no other pointers to bb exist.
-	 * 
+	 *
 	 * The archiver uses this property to aggressively reclaim
 	 * such blocks once they have been stored on Venti, and
 	 * blockCleanup knows about this property as well.
-	 * 
+	 *
 	 * Let's say src->source is block sb, and src->msource is block
 	 * mb.  Let's also say that block b holds the Entry structures for
 	 * both src->source and src->msource (their Entry structures might
@@ -524,7 +524,7 @@ fsSnapshot(Fs *fs, int doarchive)
 	 * pointers to sb and mb in new Entries corresponding to dst,
 	 * which breaks the invariant.  Thus we need to do something
 	 * about b.  Specifically, we bump the file system's epoch and
-	 * then rewalk the path from the root down to and including b.  
+	 * then rewalk the path from the root down to and including b.
 	 * This will copy-on-write as we walk, so now the state will be:
 	 *
 	 *	b	Snap w/ epoch e, holds ptrs to sb and mb.

+ 1 - 1
sys/src/cmd/fossil/pack.c

@@ -113,7 +113,7 @@ localToGlobal(u32int addr, uchar score[VtScoreSize])
 	memset(score, 0, VtScoreSize-4);
 	U32PUT(score+VtScoreSize-4, addr);
 }
-	
+
 void
 entryPack(Entry *e, uchar *p, int index)
 {

+ 3 - 3
sys/src/cmd/fossil/periodic.c

@@ -29,10 +29,10 @@ periodicAlloc(void (*f)(void*), void *a, int msec)
 	vtThread(periodicThread, p);
 	return p;
 }
-	
+
 void
 periodicKill(Periodic *p)
-{	
+{
 	if(p == nil)
 		return;
 	vtLock(p->lk);
@@ -62,7 +62,7 @@ periodicThread(void *a)
 		/* skip missed */
 		while(t <= ct)
 			t += p->msec;
-		
+
 		ts = t - ct;
 		if(ts > 1000)
 			ts = 1000;

+ 7 - 7
sys/src/cmd/fossil/source.c

@@ -110,7 +110,7 @@ sourceAlloc(Fs *fs, Block *b, Source *p, u32int offset, int mode)
 Bad:
 	vtSetError(EBadEntry);
 	return nil;
-	
+
 }
 
 Source *
@@ -170,7 +170,7 @@ sourceCreate(Source *r, int dsize, int dir, u32int offset)
 	int epb;
 	int psize;
 	Source *rr;
- 
+
 	assert(sourceIsLocked(r));
 
 	if(!r->dir){
@@ -271,7 +271,7 @@ sourceKill(Source *r, int doremove)
 			e.gen++;
 		e.dsize = 0;
 		e.psize = 0;
-		e.flags = 0;	
+		e.flags = 0;
 	}else{
 		e.flags &= ~VtEntryLocal;
 	}
@@ -591,7 +591,7 @@ sourceGrowDepth(Source *r, Block *p, Entry *e, int depth)
 			break;
 //fprint(2, "alloc %lux grow %V\n", bb->addr, b->score);
 		memmove(bb->data, b->score, VtScoreSize);
-		memmove(e->score, bb->score, VtScoreSize);	
+		memmove(e->score, bb->score, VtScoreSize);
 		e->depth++;
 		type++;
 		e->tag = tag;
@@ -727,7 +727,7 @@ sourceBlock(Source *r, ulong bn, int mode)
 			vtSetError(EBadAddr);
 			goto Err;
 		}
-		if(!sourceGrowDepth(r, b, &e, i)) 
+		if(!sourceGrowDepth(r, b, &e, i))
 			goto Err;
 	}
 
@@ -790,7 +790,7 @@ sourceLoadBlock(Source *r, int mode)
 		assert(r->mode == OReadWrite);
 		/*
 		 * This needn't be true -- we might bump the low epoch
-		 * to reclaim some old blocks, but since this score is 
+		 * to reclaim some old blocks, but since this score is
 		 * OReadWrite, the blocks must all still be open, so none
 		 * are reclaimed.  Thus it's okay that the epoch is so low.
 		 * Proceed.
@@ -956,7 +956,7 @@ sizeToDepth(uvlong s, int psize, int dsize)
 {
 	int np;
 	int d;
-	
+
 	/* determine pointer depth */
 	np = psize/VtScoreSize;
 	s = (s + dsize - 1)/dsize;

+ 26 - 26
sys/src/cmd/fossil/vac.c

@@ -39,7 +39,7 @@ stringUnpack(char **s, uchar **p, int *n)
 
 	if(*n < 2)
 		return 0;
-	
+
 	nn = U16GET(*p);
 	*p += 2;
 	*n -= 2;
@@ -87,7 +87,7 @@ if(0)fprint(2, "mbSearch %s\n", elem);
 			*ri = i;
 			return 1;
 		}
-	
+
 		if(x < 0)
 			b = i+1;
 		else /* x > 0 */
@@ -95,7 +95,7 @@ if(0)fprint(2, "mbSearch %s\n", elem);
 	}
 
 	assert(b == t);
-	
+
 	*ri = b;	/* b is the index to insert this entry */
 	memset(me, 0, sizeof(*me));
 
@@ -118,7 +118,7 @@ mbInit(MetaBlock *mb, uchar *p, int n, int ne)
 
 int
 mbUnpack(MetaBlock *mb, uchar *p, int n)
-{	
+{
 	u32int magic;
 	int i;
 	int eo, en, omin;
@@ -147,7 +147,7 @@ mbUnpack(MetaBlock *mb, uchar *p, int n)
 	if(n < omin)
 		goto Err;
 
-	
+
 	p += MetaHeaderSize;
 
 	/* check the index table - ensures that meUnpack and meCmp never fail */
@@ -297,7 +297,7 @@ meCmp(MetaEntry *me, char *s)
 	p += 6;
 	n = U16GET(p);
 	p += 2;
-	
+
 	if(n > me->size - 8)
 		n = me->size - 8;
 
@@ -336,7 +336,7 @@ meCmpOld(MetaEntry *me, char *s)
 	p += 6;
 	n = U16GET(p);
 	p += 2;
-	
+
 	if(n > me->size - 8)
 		n = me->size - 8;
 
@@ -422,7 +422,7 @@ mbCompact(MetaBlock *mb, MetaChunk *mc)
 	int oo, o, n, i;
 
 	oo = MetaHeaderSize + mb->maxindex*MetaIndexSize;
-	
+
 	for(i=0; i<mb->nindex; i++){
 		o = mc[i].offset;
 		n = mc[i].size;
@@ -487,7 +487,7 @@ int
 deSize(DirEntry *dir)
 {
 	int n;
-	
+
 	/* constant part */
 
 	n = 	4 +	/* magic */
@@ -527,7 +527,7 @@ dePack(DirEntry *dir, MetaEntry *me)
 	ulong t32;
 
 	p = me->p;
-	
+
 	U32PUT(p, DirMagic);
 	U16PUT(p+4, 9);		/* version */
 	p += 6;
@@ -544,7 +544,7 @@ dePack(DirEntry *dir, MetaEntry *me)
 	p += stringPack(dir->uid, p);
 	p += stringPack(dir->gid, p);
 	p += stringPack(dir->mid, p);
-	
+
 	U32PUT(p, dir->mtime);
 	U32PUT(p+4, dir->mcount);
 	U32PUT(p+8, dir->ctime);
@@ -570,20 +570,20 @@ deUnpack(DirEntry *dir, MetaEntry *me)
 {
 	int t, nn, n, version;
 	uchar *p;
-	
+
 	p = me->p;
 	n = me->size;
 
 	memset(dir, 0, sizeof(DirEntry));
 
-if(0)print("vdUnpack\n");
+if(0)print("deUnpack\n");
 	/* magic */
 	if(n < 4 || U32GET(p) != DirMagic)
 		goto Err;
 	p += 4;
 	n -= 4;
 
-if(0)print("vdUnpack: got magic\n");
+if(0)print("deUnpack: got magic\n");
 	/* version */
 	if(n < 2)
 		goto Err;
@@ -591,15 +591,15 @@ if(0)print("vdUnpack: got magic\n");
 	if(version < 7 || version > 9)
 		goto Err;
 	p += 2;
-	n -= 2;	
+	n -= 2;
 
-if(0)print("vdUnpack: got version\n");
+if(0)print("deUnpack: got version\n");
 
 	/* elem */
 	if(!stringUnpack(&dir->elem, &p, &n))
 		goto Err;
 
-if(0)print("vdUnpack: got elem\n");
+if(0)print("deUnpack: got elem\n");
 
 	/* entry  */
 	if(n < 4)
@@ -608,7 +608,7 @@ if(0)print("vdUnpack: got elem\n");
 	p += 4;
 	n -= 4;
 
-if(0)print("vdUnpack: got entry\n");
+if(0)print("deUnpack: got entry\n");
 
 	if(version < 9){
 		dir->gen = 0;
@@ -624,7 +624,7 @@ if(0)print("vdUnpack: got entry\n");
 		n -= 3*4;
 	}
 
-if(0)print("vdUnpack: got gen etc\n");
+if(0)print("deUnpack: got gen etc\n");
 
 	/* size is gotten from VtEntry */
 	dir->size = 0;
@@ -636,7 +636,7 @@ if(0)print("vdUnpack: got gen etc\n");
 	p += 8;
 	n -= 8;
 
-if(0)print("vdUnpack: got qid\n");
+if(0)print("deUnpack: got qid\n");
 	/* skip replacement */
 	if(version == 7){
 		if(n < VtScoreSize)
@@ -644,7 +644,7 @@ if(0)print("vdUnpack: got qid\n");
 		p += VtScoreSize;
 		n -= VtScoreSize;
 	}
-	
+
 	/* uid */
 	if(!stringUnpack(&dir->uid, &p, &n))
 		goto Err;
@@ -657,7 +657,7 @@ if(0)print("vdUnpack: got qid\n");
 	if(!stringUnpack(&dir->mid, &p, &n))
 		goto Err;
 
-if(0)print("vdUnpack: got ids\n");
+if(0)print("deUnpack: got ids\n");
 	if(n < 5*4)
 		goto Err;
 	dir->mtime = U32GET(p);
@@ -668,7 +668,7 @@ if(0)print("vdUnpack: got ids\n");
 	p += 5*4;
 	n -= 5*4;
 
-if(0)print("vdUnpack: got times\n");
+if(0)print("deUnpack: got times\n");
 	/* optional meta data */
 	while(n > 0){
 		if(n < 3)
@@ -708,15 +708,15 @@ if(0)print("vdUnpack: got times\n");
 		p += nn;
 		n -= nn;
 	}
-if(0)print("vdUnpack: got options\n");
+if(0)print("deUnpack: got options\n");
 
 	if(p != me->p + me->size)
 		goto Err;
 
-if(0)print("vdUnpack: correct size\n");
+if(0)print("deUnpack: correct size\n");
 	return 1;
 Err:
-if(0)print("vdUnpack: XXXXXXXXXXXX EbadMeta\n");
+if(0)print("deUnpack: XXXXXXXXXXXX EBadMeta\n");
 	vtSetError(EBadMeta);
 	deCleanup(dir);
 	return 0;

+ 2 - 2
sys/src/cmd/fossil/vac.h

@@ -14,7 +14,7 @@ enum {
  * Mode bits
  */
 enum {
-	ModeOtherExec = (1<<0),		
+	ModeOtherExec = (1<<0),
 	ModeOtherWrite = (1<<1),
 	ModeOtherRead = (1<<2),
 	ModeGroupExec = (1<<3),
@@ -53,7 +53,7 @@ struct DirEntry {
 	ulong mgen;		/* generation of meta entry */
 	uvlong size;		/* size of file */
 	uvlong qid;		/* unique file id */
-	
+
 	char *uid;		/* owner id */
 	char *gid;		/* group id */
 	char *mid;		/* last modified by */