Browse Source

Plan 9 from Bell Labs 2006-11-28

David du Colombier 14 years ago
parent
commit
4100fadcf3

+ 8 - 8
dist/replica/_plan9.db

@@ -108,7 +108,7 @@
 386/bin/aux/hardcopy - 775 sys sys 1020319063 1699
 386/bin/aux/isvmware - 775 sys sys 1032486791 23997
 386/bin/aux/lines - 775 sys sys 1148500594 60810
-386/bin/aux/listen - 775 sys sys 1148500595 108351
+386/bin/aux/listen - 775 sys sys 1164659104 108897
 386/bin/aux/listen1 - 775 sys sys 1148500595 94815
 386/bin/aux/lpdaemon - 775 sys sys 1136656330 168286
 386/bin/aux/lpdsend - 775 sys sys 1136656330 155124
@@ -426,7 +426,7 @@
 386/bin/tee - 775 sys sys 1148500692 38463
 386/bin/telco - 775 sys sys 1134389878 103347
 386/bin/telnet - 775 sys sys 1162440194 80751
-386/bin/test - 775 sys sys 1155491757 70321
+386/bin/test - 775 sys sys 1164686323 70261
 386/bin/time - 775 sys sys 1148500693 61712
 386/bin/tlsclient - 775 sys sys 1162241048 198972
 386/bin/tlssrv - 775 sys sys 1162241049 199336
@@ -5549,7 +5549,7 @@ rc/bin/start - 775 sys sys 945617209 120
 rc/bin/stock - 775 sys sys 1143126371 292
 rc/bin/stop - 775 sys sys 945617209 110
 rc/bin/tel - 775 sys sys 1161209756 128
-rc/bin/termrc - 775 sys sys 1125835735 2653
+rc/bin/termrc - 775 sys sys 1164658821 2647
 rc/bin/thesaurus - 775 sys sys 1068054167 246
 rc/bin/tlsclienttunnel - 775 sys sys 1024375633 153
 rc/bin/tlssrvtunnel - 775 sys sys 1024375634 175
@@ -7392,7 +7392,7 @@ sys/man/1/tbl - 664 sys sys 944959674 4308
 sys/man/1/tcs - 664 sys sys 1143131200 2654
 sys/man/1/tee - 664 sys sys 969499886 351
 sys/man/1/tel - 664 sys sys 1161209780 1057
-sys/man/1/test - 664 sys sys 1079372544 3535
+sys/man/1/test - 664 sys sys 1164660424 3681
 sys/man/1/thesaurus - 664 sys sys 1159419920 222
 sys/man/1/time - 664 sys sys 944959673 380
 sys/man/1/touch - 664 sys sys 1018369246 461
@@ -7727,7 +7727,7 @@ sys/man/8/init - 664 sys sys 944959679 1430
 sys/man/8/ipconfig - 664 sys sys 1159419702 6170
 sys/man/8/ipserv - 664 sys sys 1095862383 4375
 sys/man/8/kfscmd - 664 sys sys 1068569797 4515
-sys/man/8/listen - 664 sys sys 1163208441 3689
+sys/man/8/listen - 664 sys sys 1164653967 3551
 sys/man/8/lp - 664 sys sys 954614702 2491
 sys/man/8/mk9660 - 664 sys sys 1104430379 3946
 sys/man/8/mkfs - 664 sys sys 1163208436 3414
@@ -8040,7 +8040,7 @@ sys/src/9/pc/screen.h - 664 sys sys 1147023549 4256
 sys/src/9/pc/sd53c8xx.c - 664 sys sys 1149280015 55135
 sys/src/9/pc/sd53c8xx.n - 664 sys sys 1131290556 12657
 sys/src/9/pc/sdata.c - 664 sys sys 1161230658 52692
-sys/src/9/pc/sdmv50xx.c - 664 sys sys 1131290638 25780
+sys/src/9/pc/sdmv50xx.c - 664 sys sys 1164645014 25841
 sys/src/9/pc/sdmylex.c - 664 sys sys 1133068062 27806
 sys/src/9/pc/sdscsi.c - 664 sys sys 1158889425 7241
 sys/src/9/pc/trap.c - 664 sys sys 1135487942 21257
@@ -9669,7 +9669,7 @@ sys/src/cmd/aux/gps/mkfile - 664 sys sys 1108397331 219
 sys/src/cmd/aux/gps/util.c - 664 sys sys 1107448815 2795
 sys/src/cmd/aux/lines.c - 664 sys sys 1015008782 546
 sys/src/cmd/aux/lis - 775 sys sys 944960794 45
-sys/src/cmd/aux/listen.c - 664 sys sys 1143759349 8150
+sys/src/cmd/aux/listen.c - 664 sys sys 1164653434 8796
 sys/src/cmd/aux/listen1.c - 664 sys sys 1143759349 2005
 sys/src/cmd/aux/mkfile - 664 sys sys 1147022848 1021
 sys/src/cmd/aux/mklatinkbd.c - 664 sys sys 953253425 3813
@@ -13427,7 +13427,7 @@ sys/src/cmd/telco/mkfile - 664 sys sys 944961290 201
 sys/src/cmd/telco/telco.c - 664 sys sys 1021579996 26253
 sys/src/cmd/telco/telcodata - 775 sys sys 944961290 95
 sys/src/cmd/telco/telcofax - 664 sys sys 944961289 30
-sys/src/cmd/test.c - 664 sys sys 1155362259 5606
+sys/src/cmd/test.c - 664 sys sys 1164660299 5754
 sys/src/cmd/time.c - 664 sys sys 1014926662 1546
 sys/src/cmd/tlsclient.c - 664 sys sys 1024375149 1631
 sys/src/cmd/tlssrv.c - 664 sys sys 1161442158 3480

+ 8 - 8
dist/replica/plan9.db

@@ -108,7 +108,7 @@
 386/bin/aux/hardcopy - 775 sys sys 1020319063 1699
 386/bin/aux/isvmware - 775 sys sys 1032486791 23997
 386/bin/aux/lines - 775 sys sys 1148500594 60810
-386/bin/aux/listen - 775 sys sys 1148500595 108351
+386/bin/aux/listen - 775 sys sys 1164659104 108897
 386/bin/aux/listen1 - 775 sys sys 1148500595 94815
 386/bin/aux/lpdaemon - 775 sys sys 1136656330 168286
 386/bin/aux/lpdsend - 775 sys sys 1136656330 155124
@@ -426,7 +426,7 @@
 386/bin/tee - 775 sys sys 1148500692 38463
 386/bin/telco - 775 sys sys 1134389878 103347
 386/bin/telnet - 775 sys sys 1162440194 80751
-386/bin/test - 775 sys sys 1155491757 70321
+386/bin/test - 775 sys sys 1164686323 70261
 386/bin/time - 775 sys sys 1148500693 61712
 386/bin/tlsclient - 775 sys sys 1162241048 198972
 386/bin/tlssrv - 775 sys sys 1162241049 199336
@@ -5549,7 +5549,7 @@ rc/bin/start - 775 sys sys 945617209 120
 rc/bin/stock - 775 sys sys 1143126371 292
 rc/bin/stop - 775 sys sys 945617209 110
 rc/bin/tel - 775 sys sys 1161209756 128
-rc/bin/termrc - 775 sys sys 1125835735 2653
+rc/bin/termrc - 775 sys sys 1164658821 2647
 rc/bin/thesaurus - 775 sys sys 1068054167 246
 rc/bin/tlsclienttunnel - 775 sys sys 1024375633 153
 rc/bin/tlssrvtunnel - 775 sys sys 1024375634 175
@@ -7392,7 +7392,7 @@ sys/man/1/tbl - 664 sys sys 944959674 4308
 sys/man/1/tcs - 664 sys sys 1143131200 2654
 sys/man/1/tee - 664 sys sys 969499886 351
 sys/man/1/tel - 664 sys sys 1161209780 1057
-sys/man/1/test - 664 sys sys 1079372544 3535
+sys/man/1/test - 664 sys sys 1164660424 3681
 sys/man/1/thesaurus - 664 sys sys 1159419920 222
 sys/man/1/time - 664 sys sys 944959673 380
 sys/man/1/touch - 664 sys sys 1018369246 461
@@ -7727,7 +7727,7 @@ sys/man/8/init - 664 sys sys 944959679 1430
 sys/man/8/ipconfig - 664 sys sys 1159419702 6170
 sys/man/8/ipserv - 664 sys sys 1095862383 4375
 sys/man/8/kfscmd - 664 sys sys 1068569797 4515
-sys/man/8/listen - 664 sys sys 1163208441 3689
+sys/man/8/listen - 664 sys sys 1164653967 3551
 sys/man/8/lp - 664 sys sys 954614702 2491
 sys/man/8/mk9660 - 664 sys sys 1104430379 3946
 sys/man/8/mkfs - 664 sys sys 1163208436 3414
@@ -8040,7 +8040,7 @@ sys/src/9/pc/screen.h - 664 sys sys 1147023549 4256
 sys/src/9/pc/sd53c8xx.c - 664 sys sys 1149280015 55135
 sys/src/9/pc/sd53c8xx.n - 664 sys sys 1131290556 12657
 sys/src/9/pc/sdata.c - 664 sys sys 1161230658 52692
-sys/src/9/pc/sdmv50xx.c - 664 sys sys 1131290638 25780
+sys/src/9/pc/sdmv50xx.c - 664 sys sys 1164645014 25841
 sys/src/9/pc/sdmylex.c - 664 sys sys 1133068062 27806
 sys/src/9/pc/sdscsi.c - 664 sys sys 1158889425 7241
 sys/src/9/pc/trap.c - 664 sys sys 1135487942 21257
@@ -9669,7 +9669,7 @@ sys/src/cmd/aux/gps/mkfile - 664 sys sys 1108397331 219
 sys/src/cmd/aux/gps/util.c - 664 sys sys 1107448815 2795
 sys/src/cmd/aux/lines.c - 664 sys sys 1015008782 546
 sys/src/cmd/aux/lis - 775 sys sys 944960794 45
-sys/src/cmd/aux/listen.c - 664 sys sys 1143759349 8150
+sys/src/cmd/aux/listen.c - 664 sys sys 1164653434 8796
 sys/src/cmd/aux/listen1.c - 664 sys sys 1143759349 2005
 sys/src/cmd/aux/mkfile - 664 sys sys 1147022848 1021
 sys/src/cmd/aux/mklatinkbd.c - 664 sys sys 953253425 3813
@@ -13427,7 +13427,7 @@ sys/src/cmd/telco/mkfile - 664 sys sys 944961290 201
 sys/src/cmd/telco/telco.c - 664 sys sys 1021579996 26253
 sys/src/cmd/telco/telcodata - 775 sys sys 944961290 95
 sys/src/cmd/telco/telcofax - 664 sys sys 944961289 30
-sys/src/cmd/test.c - 664 sys sys 1155362259 5606
+sys/src/cmd/test.c - 664 sys sys 1164660299 5754
 sys/src/cmd/time.c - 664 sys sys 1014926662 1546
 sys/src/cmd/tlsclient.c - 664 sys sys 1024375149 1631
 sys/src/cmd/tlssrv.c - 664 sys sys 1161442158 3480

+ 8 - 0
dist/replica/plan9.log

@@ -31747,3 +31747,11 @@
 1164150006 1 c sys/man/4/usb - 664 sys sys 1164149417 4643
 1164150006 2 c sys/man/4/usbd - 664 sys sys 1164149441 712
 1164150006 3 c sys/src/cmd/usb/misc/usbprint - 775 sys sys 1164149479 270
+1164645006 0 c sys/src/9/pc/sdmv50xx.c - 664 sys sys 1164645014 25841
+1164654006 0 c sys/man/8/listen - 664 sys sys 1164653967 3551
+1164654006 1 c sys/src/cmd/aux/listen.c - 664 sys sys 1164653434 8796
+1164659406 0 c 386/bin/aux/listen - 775 sys sys 1164659104 108897
+1164659406 1 c rc/bin/termrc - 775 sys sys 1164658821 2647
+1164663005 0 c sys/man/1/test - 664 sys sys 1164660424 3681
+1164663005 1 c sys/src/cmd/test.c - 664 sys sys 1164660299 5754
+1164686405 0 c 386/bin/test - 775 sys sys 1164686323 70261

+ 5 - 5
rc/bin/termrc

@@ -96,12 +96,12 @@ case NCR* 'AT&TNSX'* generic* _MP_* 'alpha apc'*
 				pipefile -dr /bin/aux/accupoint /dev/mouse
 		}
 	}
-	disk=''
-	if(test -f /dev/sd*/swap)
-		disk=`{ls /dev/sd*/swap >[2]/dev/null | sed 1q | sed 's!swap$!!'}
-	if(! ~ $disk '') {
-		swap $disk^swap >/dev/null >[2=1]
+	# start up local swapping, mount dos fat fs
+	disk=`{ls /dev/sd*/swap >[2]/dev/null}
+	if (! ~ $#disk 0) {
+		swap $disk(1) >/dev/null >[2=1]
 		dossrv
 		c:
 	}
+	rm /env/disk
 }

+ 7 - 0
sys/man/1/test

@@ -209,3 +209,10 @@ is in the current directory.
 .B /sys/src/cmd/test.c
 .SH "SEE ALSO"
 .IR rc (1) 
+.SH BUGS
+Won't complain about extraneous arguments
+since there may be arguments left unprocessed by
+short-circuit evaluation of
+.B -a
+or
+.BR -o .

+ 5 - 14
sys/man/8/listen

@@ -10,8 +10,7 @@ listen, listen1, il7, il9, il19, il565, il566, il17007, il17008, il17009, il1701
 .IR trustsrvdir ]
 .RB [ -n
 .IR namespace ]
-.RI [ net
-.RI [ name ]]
+.RI [ net ]
 .PP
 .B aux/listen1
 [
@@ -24,11 +23,7 @@ listen, listen1, il7, il9, il19, il565, il566, il17007, il17008, il17009, il1701
 ]
 .SH DESCRIPTION
 .I listen
-announces itself to a network as
-.I name
-(by default the contents of
-.BR /env/sysname )
-and listens for inbound calls to local services.
+listens on a network for inbound calls to local services.
 .I Net
 is the network protocol on which to listen, by default
 .BR /net/il .
@@ -174,18 +169,17 @@ for each incoming connection;
 the network directory is passed in the environment
 as 
 .BR $net .
-The
+Option
 .B -t
-flag
 causes
 .I listen1
 to run as the invoking user; the default
 is to become
 .B none
 before listening.
-The
+Option
 .B -v
-flag causes verbose logging on standard output.
+causes verbose logging on standard output.
 See
 .B /rc/bin/tlssrvtunnel
 for an example.
@@ -194,9 +188,6 @@ for an example.
 .TP
 .B /net/tcp
 by convention, TCP device bind point
-.TP
-.B /env/sysname
-default announced name
 .SH SOURCE
 The sources to
 .I listen

+ 2 - 0
sys/src/9/pc/sdmv50xx.c

@@ -798,6 +798,8 @@ mv50interrupt(Ureg*, void *a)
 	for(i=0; i<ctlr->ndrive; i++){
 		if(cause & (3<<(i*2+i/4))){
 			drive = &ctlr->drive[i];
+			if(drive->edma == nil)
+				continue;		/* not ready yet */
 			ilock(drive);
 			updatedrive(drive, drive->edma->iec);
 			while(ctlr->chip[i/4].arb->ic & (0x0101 << (i%4))){

+ 37 - 9
sys/src/cmd/aux/listen.c

@@ -21,7 +21,7 @@ struct Announce
 };
 
 int	readstr(char*, char*, char*, int);
-void	dolisten(char*, char*, int, char*);
+void	dolisten(char*, char*, int, char*, char*);
 void	newcall(int, char*, char*, Service*);
 int 	findserv(char*, char*, Service*, char*);
 int	getserv(char*, char*, Service*);
@@ -43,7 +43,32 @@ char *namespace;
 void
 usage(void)
 {
-	error("usage: listen [-q] [-n namespace] [-d servdir] [-t trustdir] [proto [name]]");
+	error("usage: aux/listen [-q] [-n namespace] [-d servdir] [-t trustdir] [proto]");
+}
+
+/*
+ * based on libthread's threadsetname, but drags in less library code.
+ * actually just sets the arguments displayed.
+ */
+static void
+procsetname(char *fmt, ...)
+{
+	int fd;
+	char *cmdname;
+	char buf[128];
+	va_list arg;
+
+	va_start(arg, fmt);
+	cmdname = vsmprint(fmt, arg);
+	va_end(arg);
+	if (cmdname == nil)
+		return;
+	snprint(buf, sizeof buf, "#p/%d/args", getpid());
+	if((fd = open(buf, OWRITE)) >= 0){
+		write(fd, cmdname, strlen(cmdname)+1);
+		close(fd);
+	}
+	free(cmdname);
 }
 
 void
@@ -65,16 +90,16 @@ main(int argc, char *argv[])
 
 	ARGBEGIN{
 	case 'd':
-		servdir = ARGF();
+		servdir = EARGF(usage());
 		break;
 	case 'q':
 		quiet = 1;
 		break;
 	case 't':
-		trustdir = ARGF();
+		trustdir = EARGF(usage());
 		break;
 	case 'n':
-		namespace = ARGF();
+		namespace = EARGF(usage());
 		break;
 	default:
 		usage();
@@ -98,7 +123,7 @@ main(int argc, char *argv[])
 		usage();
 	}
 
-	syslog(0, listenlog, "started");
+	syslog(0, listenlog, "started on %s", proto);
 
 	protodir = proto;
 	proto = strrchr(proto, '/');
@@ -145,6 +170,7 @@ listendir(char *protodir, char *srvdir, int trusted)
 		return;
 	}
 
+	procsetname("%s %s %s", protodir, srvdir, namespace);
 	if (!trusted)
 		becomenone();
 
@@ -172,10 +198,11 @@ listendir(char *protodir, char *srvdir, int trusted)
 				for(;;){
 					ctl = announce(a->a, dir);
 					if(ctl < 0) {
-						syslog(1, listenlog, "giving up on %s: %r", a->a);
+						syslog(1, listenlog,
+						   "giving up on %s: %r", a->a);
 						exits("ctl");
 					}
-					dolisten(proto, dir, ctl, srvdir);
+					dolisten(proto, dir, ctl, srvdir, a->a);
 					close(ctl);
 				}
 			default:
@@ -270,12 +297,13 @@ becomenone(void)
 }
 
 void
-dolisten(char *proto, char *dir, int ctl, char *srvdir)
+dolisten(char *proto, char *dir, int ctl, char *srvdir, char *dialstr)
 {
 	Service s;
 	char ndir[40];
 	int nctl, data;
 
+	procsetname("%s %s", dir, dialstr);
 	for(;;){
 		/*
 		 *  wait for a call (or an error)

+ 29 - 16
sys/src/cmd/test.c

@@ -11,6 +11,7 @@
 
 #include <u.h>
 #include <libc.h>
+
 #define EQ(a,b)	((tmp=a)==0?0:(strcmp(tmp,b)==0))
 
 int	ap;
@@ -30,7 +31,7 @@ int	isnewerthan(char *, char *);
 int	hasmode(char *, ulong);
 int	tio(char *, int);
 int	e(void), e1(void), e2(void), e3(void);
-char *nxtarg(int);
+char	*nxtarg(int);
 
 void
 main(int argc, char *argv[])
@@ -44,9 +45,14 @@ main(int argc, char *argv[])
 			synbad("] missing","");
 	}
 	argv[ac] = 0;
-	if (ac<=1) exits("usage");
+	if (ac<=1)
+		exits("usage");
 	r = e();
-	if(c = nxtarg(1))
+	/*
+	 * nice idea but short-circuit -o and -a operators may have
+	 * not consumed their right-hand sides.
+	 */
+	if(0 && (c = nxtarg(1)) != nil)
 		synbad("unexpected operator/operand: ", c);
 	exits(r?0:"false");
 }
@@ -75,27 +81,32 @@ nxtintarg(int *pans)
 }
 
 int
-e(void) {
+e(void)
+{
 	int p1;
 
 	p1 = e1();
-	if (EQ(nxtarg(1), "-o")) return(p1 || e());
+	if (EQ(nxtarg(1), "-o"))
+		return(p1 || e());
 	ap--;
 	return(p1);
 }
 
 int
-e1(void) {
+e1(void)
+{
 	int p1;
 
 	p1 = e2();
-	if (EQ(nxtarg(1), "-a")) return (p1 && e1());
+	if (EQ(nxtarg(1), "-a"))
+		return (p1 && e1());
 	ap--;
 	return(p1);
 }
 
 int
-e2(void) {
+e2(void)
+{
 	if (EQ(nxtarg(0), "!"))
 		return(!e2());
 	ap--;
@@ -103,16 +114,16 @@ e2(void) {
 }
 
 int
-e3(void) {
-	int p1;
-	char *a;
-	char *p2;
-	int int1, int2;
+e3(void)
+{
+	int p1, int1, int2;
+	char *a, *p2;
 
 	a = nxtarg(0);
 	if(EQ(a, "(")) {
 		p1 = e();
-		if(!EQ(nxtarg(0), ")")) synbad(") expected","");
+		if(!EQ(nxtarg(0), ")"))
+			synbad(") expected","");
 		return(p1);
 	}
 
@@ -224,9 +235,10 @@ localstat(char *f, Dir *dir)
 	Dir *d;
 
 	d = dirstat(f);
-	if(d == 0)
+	if(d == nil)
 		return(-1);
 	*dir = *d;
+	free(d);
 	dir->name = 0;
 	dir->uid = 0;
 	dir->gid = 0;
@@ -241,9 +253,10 @@ localfstat(int f, Dir *dir)
 	Dir *d;
 
 	d = dirfstat(f);
-	if(d == 0)
+	if(d == nil)
 		return(-1);
 	*dir = *d;
+	free(d);
 	dir->name = 0;
 	dir->uid = 0;
 	dir->gid = 0;