Browse Source

Plan 9 from Bell Labs 2013-07-13

David du Colombier 10 years ago
parent
commit
3614ae8b21

+ 1 - 0
sys/games/lib/fortunes

@@ -4312,3 +4312,4 @@ To maintain backward compatibility, the relationships between the many options a
 qemu: could not open serial device 'dev': Success
 DSM Terminator [ ABORT ] Finished [ 0 request(s) + 0 call(s) distributed in 5ms]
 Microsoft Office PowerPoint has encountered a problem and cannot exit.  We are sorry for the inconvenience.
+dd: argument 18446744073709551615 out of range

+ 0 - 3
sys/lib/backup/backup

@@ -1,9 +1,6 @@
 #!/bin/rc
 # backup [-np] [-d dev] [-s set] - backup venti arenas to disc set using dev
 #	and record that.  also print recent fossil dump scores.
-#
-# it would be good to have some way to cope with truncated tracks left
-# by write errors causing fewer tracks than expected to fit on a disc.
 
 rfork ne
 cd /sys/lib/backup

+ 2 - 2
sys/lib/backup/mkfile

@@ -1,6 +1,6 @@
+backup:V:
+	./backup
 clean:V:
 	rm -f index
 setup:V:
 	mkdir set1
-backup:V:
-	./backup

+ 4 - 1
sys/src/9/port/allocb.c

@@ -65,9 +65,12 @@ allocb(int size)
 	if(up == nil)
 		panic("allocb without up: %#p", getcallerpc(&size));
 	if((b = _allocb(size)) == nil){
+		splhi();
 		xsummary();
 		mallocsummary();
-		panic("allocb: no memory for %d bytes", size);
+		delay(500);
+		panic("allocb: no memory for %d bytes; caller %#p", size,
+			getcallerpc(&size));
 	}
 	setmalloctag(b, getcallerpc(&size));
 

+ 12 - 1
sys/src/9/port/devaoe.c

@@ -2411,7 +2411,18 @@ removeaoedev(Aoedev *d)
 				break;
 	qlock(d);
 	d->flag &= ~Dup;
-	newvers(d);
+
+	/*
+	 * Changing the version number is, strictly speaking, correct,
+ 	 * but doing so means that deleting a LUN that is not in use
+	 * invalidates all other LUNs too.  If your file server has
+	 * venti arenas or fossil file systems on 1.0, and you delete 1.1,
+	 * since you no longer need it, 1.0 will become inaccessible to your
+	 * file server, which will eventually panic.  Note that newdev()
+	 * does not change the version number.
+	 */
+	// newvers(d);
+
 	d->ndl = 0;
 	qunlock(d);
 	for(i = 0; i < d->nframes; i++)

+ 26 - 7
sys/src/9/port/devfs.c

@@ -84,6 +84,7 @@ struct Fsdev
 	vlong	size;		/* min(inner[X].isize) */
 	vlong	start;		/* start address (for Fpart) */
 	uint	ndevs;		/* number of inner devices */
+	int	perm;		/* minimum of inner device perms */
 	Inner	*inner[Ndevs];	/* inner devices */
 };
 
@@ -104,9 +105,11 @@ static Tree fstree;		/* The main "fs" tree. Never goes away */
 static Tree *trees[Ntrees];	/* internal representation of config */
 static int ntrees;		/* max number of trees */
 static int qidvers;
+
 static char *disk;		/* default tree name used */
 static char *source;		/* default inner device used */
 static int sectorsz = Sectorsz;	/* default sector size */
+
 static char confstr[Maxconf];	/* textual configuration */
 
 static int debug;
@@ -502,16 +505,21 @@ parsename(char *name, char *disk, char **tree, char **dev)
 	validname(*dev, 0);
 }
 
-static vlong
-getlen(Chan *c)
+static int
+getattrs(Chan *c, vlong *lenp, int *permp)
 {
 	uchar	buf[128];	/* old DIRLEN plus a little should be plenty */
 	Dir	d;
 	long	l;
 
+	*lenp = 0;
+	*permp = 0;
 	l = devtab[c->type]->stat(c, buf, sizeof buf);
-	convM2D(buf, l, &d, nil);
-	return d.length;
+	if (l >= 0 && convM2D(buf, l, &d, nil) > 0) {
+		*lenp = d.length;
+		*permp = d.mode & 0777;
+	}
+	return l;
 }
 
 /*
@@ -526,6 +534,7 @@ static void
 mconfig(char* a, long n)
 {
 	int	i;
+	int	*iperm;
 	vlong	size, start;
 	vlong	*ilen;
 	char	*tname, *dname, *fakef[4];
@@ -547,6 +556,7 @@ mconfig(char* a, long n)
 	cb = nil;
 	idev = nil;
 	ilen = nil;
+	iperm = nil;
 
 	if(waserror()){
 		free(cb);
@@ -622,14 +632,17 @@ Fail:
 			mdeldev(mp);
 		free(idev);
 		free(ilen);
+		free(iperm);
 		free(cb);
 		nexterror();
 	}
+	/* record names, lengths and perms of all named files */
 	idev = smalloc(sizeof(Chan*) * Ndevs);
 	ilen = smalloc(sizeof(vlong) * Ndevs);
+	iperm = smalloc(sizeof(int) * Ndevs);
 	for(i = 1; i < cb->nf; i++){
 		idev[i-1] = namec(cb->f[i], Aopen, ORDWR, 0);
-		ilen[i-1] = getlen(idev[i-1]);
+		getattrs(idev[i-1], &ilen[i-1], &iperm[i-1]);
 	}
 	poperror();
 	runlock(&lck);
@@ -657,11 +670,13 @@ Fail:
 		error(Enomem);
 	}
 
+	/* construct mp from iname, idev and iperm arrays */
 	mp->type = ct->index;
 	if(mp->type == Fpart){
 		mp->start = start * sectorsz;
 		mp->size = size * sectorsz;
 	}
+	mp->perm = 0666;
 	for(i = 1; i < cb->nf; i++){
 		inprv = mp->inner[i-1] = mallocz(sizeof(Inner), 1);
 		if(inprv == nil)
@@ -670,6 +685,8 @@ Fail:
 		kstrdup(&inprv->iname, cb->f[i]);
 		inprv->idev = idev[i-1];
 		idev[i-1] = nil;
+		/* use the most restrictive of the inner permissions */
+		mp->perm &= iperm[i-1];
 	}
 	setdsize(mp, ilen);
 
@@ -677,6 +694,7 @@ Fail:
 	wunlock(&lck);
 	free(idev);
 	free(ilen);
+	free(iperm);
 	free(cb);
 }
 
@@ -796,7 +814,7 @@ mgen(Chan *c, char*, Dirtab*, int, int i, Dir *dp)
 		qid.type = QTFILE;
 		qid.vers = mp->vers;
 		qid.path = mkpath(treeno, Qfirst+i);
-		devdir(c, qid, mp->name, mp->size, eve, 0664, dp);
+		devdir(c, qid, mp->name, mp->size, eve, mp->perm, dp);
 		return 1;
 	}
 
@@ -867,7 +885,7 @@ mstat(Chan *c, uchar *db, int n)
 			mp = getdev(t, path2devno(p) - Qfirst, Mustexist);
 			q = c->qid;
 			q.vers = mp->vers;
-			devdir(c, q, mp->name, mp->size, eve, 0664, &d);
+			devdir(c, q, mp->name, mp->size, eve, mp->perm, &d);
 		}
 	}
 	n = convD2M(&d, db, n);
@@ -897,6 +915,7 @@ mopen(Chan *c, int omode)
 		mp = path2dev(q);
 		if(mp->gone)
 			error(Egone);
+		devpermcheck(eve, mp->perm, omode);
 		incref(mp);
 		poperror();
 		runlock(&lck);

+ 3 - 0
sys/src/9/port/portdat.h

@@ -89,6 +89,9 @@ typedef int    Devgen(Chan*, char*, Dirtab*, int, int, Dir*);
 #ifndef STAGESIZE
 #define STAGESIZE 64
 #endif
+#ifndef MAXBY2PG
+#define MAXBY2PG BY2PG		/* rounding for UTZERO in executables */
+#endif
 
 struct Ref
 {

+ 0 - 7
sys/src/9/port/proc.c

@@ -1378,13 +1378,6 @@ kproc(char *name, void (*func)(void *), void *arg)
 	memset(p->time, 0, sizeof(p->time));
 	p->time[TReal] = MACHP(0)->ticks;
 	ready(p);
-	/*
-	 *  since the bss/data segments are now shareable,
-	 *  any mmu info about this process is now stale
-	 *  and has to be discarded.
-	 */
-	p->newtlb = 1;
-	flushmmu();
 }
 
 /*

+ 1 - 1
sys/src/9/port/rebootcmd.c

@@ -82,7 +82,7 @@ rebootcmd(int argc, char *argv[])
 		error(Ebadexec);
 
 	/* round text out to page boundary */
-	rtext = PGROUND(entry+text)-entry;
+	rtext = ROUNDUP(entry+text, MAXBY2PG) - entry;
 	size = rtext + data;
 	p = malloc(size);
 	if(p == nil)