Browse Source

Plan 9 from Bell Labs 2008-02-12

David du Colombier 13 years ago
parent
commit
d4b5a49b4a

+ 11 - 12
dist/replica/_plan9.db

@@ -486,7 +486,7 @@
 386/bin/usb/disk - 775 sys sys 1202272000 187347
 386/bin/usb/usbaudio - 775 sys sys 1202272003 188183
 386/bin/usb/usbd - 775 sys sys 1202272005 131144
-386/bin/usb/usbmouse - 775 sys sys 1202272007 109417
+386/bin/usb/usbmouse - 775 sys sys 1202760908 128469
 386/bin/usb/usbprint - 775 sys sys 1196537245 314
 386/bin/usb/usbprobe - 775 sys sys 1196537245 173
 386/bin/vac - 775 sys sys 1196742539 171330
@@ -5639,7 +5639,7 @@ rc/bin/umem - 775 sys sys 1190076661 547
 rc/bin/uncompress - 775 sys sys 1158798931 30
 rc/bin/ups - 775 sys sys 1091021981 806
 rc/bin/uptime - 775 sys sys 1074730712 234
-rc/bin/usbfat: - 775 sys sys 1202320226 716
+rc/bin/usbfat: - 775 sys sys 1202773132 818
 rc/bin/usbstart - 775 sys sys 1044894155 81
 rc/bin/usps - 775 sys sys 1016826030 450
 rc/bin/vwhois - 775 sys sys 1106409971 445
@@ -12819,20 +12819,20 @@ sys/src/cmd/mv.c - 664 sys sys 1163029439 4682
 sys/src/cmd/ndb - 20000000775 sys sys 1080135004 0
 sys/src/cmd/ndb/convDNS2M.c - 664 sys sys 1194216289 7061
 sys/src/cmd/ndb/convM2DNS.c - 664 sys sys 1194216290 11959
-sys/src/cmd/ndb/cs.c - 664 sys sys 1188515063 32892
+sys/src/cmd/ndb/cs.c - 664 sys sys 1202761086 32962
 sys/src/cmd/ndb/csquery.c - 664 sys sys 1174626119 1073
 sys/src/cmd/ndb/dblookup.c - 664 sys sys 1201927753 25262
-sys/src/cmd/ndb/dn.c - 664 sys sys 1201927830 37758
+sys/src/cmd/ndb/dn.c - 664 sys sys 1202761157 37770
 sys/src/cmd/ndb/dnarea.c - 664 sys sys 1175664421 2519
-sys/src/cmd/ndb/dnnotify.c - 664 sys sys 1197930912 3278
-sys/src/cmd/ndb/dnresolve.c - 664 sys sys 1201499792 35562
-sys/src/cmd/ndb/dns.c - 664 sys sys 1201927800 17679
-sys/src/cmd/ndb/dns.h - 664 sys sys 1201927786 11915
+sys/src/cmd/ndb/dnnotify.c - 664 sys sys 1202761157 3249
+sys/src/cmd/ndb/dnresolve.c - 664 sys sys 1202761187 35667
+sys/src/cmd/ndb/dns.c - 664 sys sys 1202761244 17972
+sys/src/cmd/ndb/dns.h - 664 sys sys 1202761152 11969
 sys/src/cmd/ndb/dnsdebug.c - 664 sys sys 1194216583 8790
 sys/src/cmd/ndb/dnserver.c - 664 sys sys 1198183920 4630
 sys/src/cmd/ndb/dnsquery.c - 664 sys sys 1185315254 2507
-sys/src/cmd/ndb/dnstcp.c - 664 sys sys 1196688268 7513
-sys/src/cmd/ndb/dnudpserver.c - 664 sys sys 1200463045 5727
+sys/src/cmd/ndb/dnstcp.c - 664 sys sys 1202761262 7535
+sys/src/cmd/ndb/dnudpserver.c - 664 sys sys 1202761274 5828
 sys/src/cmd/ndb/ipquery.c - 664 sys sys 1124711423 773
 sys/src/cmd/ndb/mkdb.c - 664 sys sys 957402054 2886
 sys/src/cmd/ndb/mkfile - 664 sys sys 1174623575 1984
@@ -14278,7 +14278,7 @@ sys/src/cmd/usb/lib/usb.h - 664 sys sys 1165044715 7066
 sys/src/cmd/usb/lib/util.c - 664 sys sys 1091204978 523
 sys/src/cmd/usb/misc - 20000000775 sys sys 1091282306 0
 sys/src/cmd/usb/misc/mkfile - 664 sys sys 1167255850 374
-sys/src/cmd/usb/misc/usbmouse.c - 664 sys sys 1202255573 3768
+sys/src/cmd/usb/misc/usbmouse.c - 664 sys sys 1202702762 4804
 sys/src/cmd/usb/misc/usbprint - 775 sys sys 1167253831 314
 sys/src/cmd/usb/misc/usbprobe - 775 sys sys 1167253836 173
 sys/src/cmd/usb/mkfile - 664 sys sys 1193181446 361
@@ -15860,4 +15860,3 @@ usr/glenda/lib/profile - 664 glenda glenda 1105128663 890
 usr/glenda/readme.acme - 664 glenda glenda 1019860628 4753
 usr/glenda/readme.rio - 664 glenda glenda 1019860628 6370
 usr/glenda/tmp - 20000000775 glenda glenda 1018802620 0
-sys/src/cmd/usb/misc/usbmouse.c - 664 sys sys 1202702762 4804

+ 10 - 10
dist/replica/plan9.db

@@ -486,7 +486,7 @@
 386/bin/usb/disk - 775 sys sys 1202272000 187347
 386/bin/usb/usbaudio - 775 sys sys 1202272003 188183
 386/bin/usb/usbd - 775 sys sys 1202272005 131144
-386/bin/usb/usbmouse - 775 sys sys 1202272007 109417
+386/bin/usb/usbmouse - 775 sys sys 1202760908 128469
 386/bin/usb/usbprint - 775 sys sys 1196537245 314
 386/bin/usb/usbprobe - 775 sys sys 1196537245 173
 386/bin/vac - 775 sys sys 1196742539 171330
@@ -5639,7 +5639,7 @@ rc/bin/umem - 775 sys sys 1190076661 547
 rc/bin/uncompress - 775 sys sys 1158798931 30
 rc/bin/ups - 775 sys sys 1091021981 806
 rc/bin/uptime - 775 sys sys 1074730712 234
-rc/bin/usbfat: - 775 sys sys 1202320226 716
+rc/bin/usbfat: - 775 sys sys 1202773132 818
 rc/bin/usbstart - 775 sys sys 1044894155 81
 rc/bin/usps - 775 sys sys 1016826030 450
 rc/bin/vwhois - 775 sys sys 1106409971 445
@@ -12819,20 +12819,20 @@ sys/src/cmd/mv.c - 664 sys sys 1163029439 4682
 sys/src/cmd/ndb - 20000000775 sys sys 1080135004 0
 sys/src/cmd/ndb/convDNS2M.c - 664 sys sys 1194216289 7061
 sys/src/cmd/ndb/convM2DNS.c - 664 sys sys 1194216290 11959
-sys/src/cmd/ndb/cs.c - 664 sys sys 1188515063 32892
+sys/src/cmd/ndb/cs.c - 664 sys sys 1202761086 32962
 sys/src/cmd/ndb/csquery.c - 664 sys sys 1174626119 1073
 sys/src/cmd/ndb/dblookup.c - 664 sys sys 1201927753 25262
-sys/src/cmd/ndb/dn.c - 664 sys sys 1201927830 37758
+sys/src/cmd/ndb/dn.c - 664 sys sys 1202761157 37770
 sys/src/cmd/ndb/dnarea.c - 664 sys sys 1175664421 2519
-sys/src/cmd/ndb/dnnotify.c - 664 sys sys 1197930912 3278
-sys/src/cmd/ndb/dnresolve.c - 664 sys sys 1201499792 35562
-sys/src/cmd/ndb/dns.c - 664 sys sys 1201927800 17679
-sys/src/cmd/ndb/dns.h - 664 sys sys 1201927786 11915
+sys/src/cmd/ndb/dnnotify.c - 664 sys sys 1202761157 3249
+sys/src/cmd/ndb/dnresolve.c - 664 sys sys 1202761187 35667
+sys/src/cmd/ndb/dns.c - 664 sys sys 1202761244 17972
+sys/src/cmd/ndb/dns.h - 664 sys sys 1202761152 11969
 sys/src/cmd/ndb/dnsdebug.c - 664 sys sys 1194216583 8790
 sys/src/cmd/ndb/dnserver.c - 664 sys sys 1198183920 4630
 sys/src/cmd/ndb/dnsquery.c - 664 sys sys 1185315254 2507
-sys/src/cmd/ndb/dnstcp.c - 664 sys sys 1196688268 7513
-sys/src/cmd/ndb/dnudpserver.c - 664 sys sys 1200463045 5727
+sys/src/cmd/ndb/dnstcp.c - 664 sys sys 1202761262 7535
+sys/src/cmd/ndb/dnudpserver.c - 664 sys sys 1202761274 5828
 sys/src/cmd/ndb/ipquery.c - 664 sys sys 1124711423 773
 sys/src/cmd/ndb/mkdb.c - 664 sys sys 957402054 2886
 sys/src/cmd/ndb/mkfile - 664 sys sys 1174623575 1984

+ 11 - 0
dist/replica/plan9.log

@@ -18459,3 +18459,14 @@
 1202490003 0 a sys/src/9/pc/ether82598.c - 664 sys sys 1202489363 0
 1202497204 0 c sys/man/8/prep - 664 sys sys 1202496787 14211
 1202704204 0 c sys/src/cmd/usb/misc/usbmouse.c - 664 sys sys 1202702762 4804
+1202761804 0 c 386/bin/usb/usbmouse - 775 sys sys 1202760908 128469
+1202761804 1 c rc/bin/usbfat: - 775 sys sys 1202760355 810
+1202761804 2 c sys/src/cmd/ndb/cs.c - 664 sys sys 1202761086 32962
+1202761804 3 c sys/src/cmd/ndb/dn.c - 664 sys sys 1202761157 37770
+1202761804 4 c sys/src/cmd/ndb/dnnotify.c - 664 sys sys 1202761157 3249
+1202761804 5 c sys/src/cmd/ndb/dnresolve.c - 664 sys sys 1202761187 35667
+1202761804 6 c sys/src/cmd/ndb/dns.c - 664 sys sys 1202761244 17972
+1202761804 7 c sys/src/cmd/ndb/dns.h - 664 sys sys 1202761152 11969
+1202761804 8 c sys/src/cmd/ndb/dnstcp.c - 664 sys sys 1202761262 7535
+1202761804 9 c sys/src/cmd/ndb/dnudpserver.c - 664 sys sys 1202761274 5828
+1202774403 0 c rc/bin/usbfat: - 775 sys sys 1202773132 818

+ 12 - 10
rc/bin/usbfat:

@@ -4,10 +4,10 @@ rfork e
 opts=()
 while (! ~ $#* 0 && ~ $1 -*) {
 	switch ($1) {
-	case -f -l
+	case -f -l -lf -fl
 		opts=($opts $1)
 	case -*
-		echo usage: $0 '[-f] [disk [mtpt]]' >[1=2]
+		echo usage: $0 '[-fl] [disk [mtpt]]' >[1=2]
 		exit usage
 	}
 	shift
@@ -24,17 +24,19 @@ case 2
 	disk = $1
 	mtpt = $2
 case *
-	echo usage: $0 '[-f] [disk [mtpt]]' >[1=2]
+	echo usage: $0 '[-fl] [disk [mtpt]]' >[1=2]
 	exit usage
 }
 
 if (! test -e $disk)
-	usb/disk $opts
-blk = `{disk/fdisk -p $disk | awk '/^part dos / {print $3}'}
-if (~ $#blk 0 || ! ~ $blk [0-9]*) {
-	echo $0: no fdisk dos partition found... >[1=2]
-	dossrv -f $disk usbfat.$user
+	usb/disk $opts || exit 'no disk'
+if (! test -f /srv/usbfat.$user) {
+	blk = `{disk/fdisk -p $disk | awk '/^part dos / {print $3}'}
+	if (~ $#blk 0 || ! ~ $blk [0-9]*) {
+		echo $0: no fdisk dos partition found... >[1=2]
+		dossrv -f $disk usbfat.$user || exit dossrv
+	}
+	if not
+		dossrv -f $disk:$blk usbfat.$user || exit dossrv
 }
-if not
-	dossrv -f $disk:$blk usbfat.$user
 mount -c /srv/usbfat.$user $mtpt

+ 3 - 1
sys/src/cmd/ndb/cs.c

@@ -627,7 +627,7 @@ rread(Job *job, Mfile *mf)
 	int i, n, cnt;
 	long off, toff, clock;
 	Dir dir;
-	uchar buf[Maxfdata];
+	uchar buf[IOHDRSZ+Maxfdata];
 	char *err;
 
 	n = 0;
@@ -637,6 +637,7 @@ rread(Job *job, Mfile *mf)
 	if(mf->qid.type & QTDIR){
 		clock = time(0);
 		if(off == 0){
+			memset(&dir, 0, sizeof dir);
 			dir.name = "cs";
 			dir.qid.type = QTFILE;
 			dir.qid.vers = vers;
@@ -843,6 +844,7 @@ rstat(Job *job, Mfile *mf)
 	Dir dir;
 	uchar buf[IOHDRSZ+Maxfdata];
 
+	memset(&dir, 0, sizeof dir);
 	if(mf->qid.type & QTDIR){
 		dir.name = ".";
 		dir.mode = DMDIR|0555;

+ 1 - 0
sys/src/cmd/ndb/dn.c

@@ -1453,6 +1453,7 @@ slave(Request *req)
 		 * stacks, thus giving us two copies of `req', one in each
 		 * process.
 		 */
+		alarm(0);
 		longjmp(req->mret, 1);
 	}
 }

+ 3 - 6
sys/src/cmd/ndb/dnnotify.c

@@ -47,9 +47,10 @@ dnnotify(DNSmsg *reqp, DNSmsg *repp, Request *)
 static void
 ding(void*, char *msg)
 {
-	if(strstr(msg, "alarm") != nil)
+	if(strstr(msg, "alarm") != nil) {
+		stats.alarms++;
 		noted(NCONT);		/* resume with system call error */
-	else
+	} else
 		noted(NDFLT);		/* die */
 }
 
@@ -136,10 +137,6 @@ void
 notifyproc(void)
 {
 	Request req;
-//	static int already;
-
-//	if(already)
-//		return;
 
 	switch(rfork(RFPROC|RFNOTEG|RFMEM|RFNOWAIT)){
 	case -1:

+ 8 - 2
sys/src/cmd/ndb/dnresolve.c

@@ -150,7 +150,7 @@ dnresolve(char *name, int class, int type, Request *req, RR **cn, int depth,
 			rrfreelist(rrremneg(&rp));
 		}
 		if(drp != nil)
-			rrfreelist(drp);	/* was rrfree */
+			rrfreelist(drp);
 		procsetname(procname);
 		free(procname);
 		return rp;
@@ -545,6 +545,7 @@ mkreq(DN *dp, int type, uchar *buf, int flags, ushort reqno)
 		dnslog("mkreq: bogus type %d", type);
 	len = convDNS2M(&m, &buf[Udphdrsize], Maxudp);
 	rrfree(m.qd);
+	memset(&m, 0, sizeof m);		/* cause trouble */
 	return len;
 }
 
@@ -646,8 +647,12 @@ readreply(Query *qp, int medium, ushort req, uchar *ibuf, DNSmsg *mp,
 	uchar *reply;
 	uchar srcip[IPaddrlen];
 	RR *rp;
+	static int first = 1;
 
-	notify(ding);
+	if (first) {
+		first = 0;
+		notify(ding);
+	}
 
 	queryck(qp);
 	rv = 0;
@@ -1304,6 +1309,7 @@ queryns(Query *qp, int depth, uchar *ibuf, uchar *obuf, int waitsecs, int inns)
 				break;		/* timed out on this dest */
 			} else {
 				/* whoops, it was truncated! ask again via tcp */
+				freeanswers(&m);
 				rv = tcpquery(qp, &m, depth, ibuf, obuf, len,
 					waitsecs, inns, req);  /* answer in m */
 				if (rv < 0) {

+ 11 - 4
sys/src/cmd/ndb/dns.c

@@ -170,6 +170,7 @@ main(int argc, char *argv[])
 
 	if(testing)
 		mainmem->flags |= POOL_NOREUSE | POOL_ANTAGONISM;
+	mainmem->flags |= POOL_ANTAGONISM;
 	rfork(RFREND|RFNOTEG);
 
 	cfg.inside = (*mntpt == '\0' || strcmp(mntpt, "/net") == 0);
@@ -264,7 +265,7 @@ mountinit(char *service, char *mntpt)
 	switch(rfork(RFFDG|RFPROC|RFNAMEG)){
 	case 0:			/* child: hang around and (re)start main proc */
 		close(p[1]);
-		procsetname("restarter");
+		procsetname("%s restarter", mntpt);
 		break;
 	case -1:
 		abort(); /* "fork failed\n" */;
@@ -412,17 +413,20 @@ io(void)
 	 */
 	if(setjmp(req.mret))
 		putactivity(0);
-	procsetname("9p server");
+//	procsetname("9p server");
 	req.isslave = 0;
 	stop = 0;
 	while(!stop){
+		procsetname("served %d 9p; %d alarms; %d rpcs read",
+			stats.qrecvd9p, stats.alarms, stats.qrecvd9prpc);
 		n = read9pmsg(mfd[0], mdata, sizeof mdata);
 		if(n<=0){
 			dnslog("error reading 9P from %s: %r", mntpt);
 			sleep(2000);		/* don't thrash */
-			exits(0);
+			return;
 		}
 
+		stats.qrecvd9prpc++;
 		job = newjob();
 		if(convM2S(mdata, n, &job->request) != n){
 			freejob(job);
@@ -635,7 +639,7 @@ rread(Job *job, Mfile *mf)
 	ulong cnt;
 	vlong off;
 	char *err;
-	uchar buf[Maxfdata];
+	uchar buf[IOHDRSZ+Maxfdata];
 	Dir dir;
 
 	n = 0;
@@ -647,6 +651,7 @@ rread(Job *job, Mfile *mf)
 	if(mf->qid.type & QTDIR){
 		clock = time(nil);
 		if(off == 0){
+			memset(&dir, 0, sizeof dir);
 			dir.name = "dns";
 			dir.qid.type = QTFILE;
 			dir.qid.vers = vers;
@@ -707,6 +712,7 @@ rwrite(Job *job, Mfile *mf, Request *req)
 	/*
 	 *  special commands
 	 */
+	dnslog("rwrite got: %s", job->request.data);
 	if(strcmp(job->request.data, "debug")==0){
 		debug ^= 1;
 		goto send;
@@ -858,6 +864,7 @@ rstat(Job *job, Mfile *mf)
 	Dir dir;
 	uchar buf[IOHDRSZ+Maxfdata];
 
+	memset(&dir, 0, sizeof dir);
 	if(mf->qid.type & QTDIR){
 		dir.name = ".";
 		dir.mode = DMDIR|0555;

+ 2 - 0
sys/src/cmd/ndb/dns.h

@@ -391,6 +391,8 @@ typedef struct {
 	ulong	qrecvd9p;	/* query counts */
 	ulong	qrecvdudp;
 	ulong	qsent;
+	ulong	qrecvd9prpc;	/* packet count */
+	ulong	alarms;
 	/* reply times by count */
 	ulong	under10ths[3*10+2];	/* under n*0.1 seconds, n is index */
 	ulong	tmout;

+ 1 - 1
sys/src/cmd/ndb/dnstcp.c

@@ -140,7 +140,7 @@ main(int argc, char *argv[])
 				rrfreelist(repmsg.ns);
 				rrfreelist(repmsg.ar);
 			}
-		rrfreelist(reqmsg.qd);
+		rrfreelist(reqmsg.qd);		/* qd will be nil */
 		rrfreelist(reqmsg.an);
 		rrfreelist(reqmsg.ns);
 		rrfreelist(reqmsg.ar);

+ 6 - 3
sys/src/cmd/ndb/dnudpserver.c

@@ -13,9 +13,10 @@ static void	reply(int, uchar*, DNSmsg*, Request*);
 static void
 ding(void*, char *msg)
 {
-	if(strstr(msg, "alarm") != nil)
+	if(strstr(msg, "alarm") != nil) {
+		stats.alarms++;
 		noted(NCONT);		/* resume with system call error */
-	else
+	} else
 		noted(NDFLT);		/* die */
 }
 
@@ -104,7 +105,7 @@ restart:
 	while((fd = udpannounce(mntpt)) < 0)
 		sleep(5000);
 
-	procsetname("udp server");
+//	procsetname("udp server");
 	memset(&req, 0, sizeof req);
 	if(setjmp(req.mret))
 		putactivity(0);
@@ -114,6 +115,8 @@ restart:
 
 	/* loop on requests */
 	for(;; putactivity(0)){
+		procsetname("served %d udp; %d alarms",
+			stats.qrecvdudp, stats.alarms);
 		memset(&repmsg, 0, sizeof repmsg);
 		memset(&reqmsg, 0, sizeof reqmsg);