Browse Source

Plan 9 from Bell Labs 2008-03-09

David du Colombier 16 years ago
parent
commit
e3392f0cf6

+ 8 - 8
dist/replica/_plan9.db

@@ -172,7 +172,7 @@
 386/bin/calendar - 775 sys sys 1200262736 79060
 386/bin/cat - 775 sys sys 1148500611 37482
 386/bin/cb - 775 sys sys 1168402293 77628
-386/bin/cdfs - 775 sys sys 1179372081 166023
+386/bin/cdfs - 775 sys sys 1205008816 166835
 386/bin/cec - 775 sys sys 1193714267 75896
 386/bin/cfs - 775 sys sys 1190863294 130565
 386/bin/chgrp - 775 sys sys 1168402294 59522
@@ -7729,7 +7729,7 @@ sys/man/4/dossrv - 664 sys sys 1196638943 4334
 sys/man/4/execnet - 664 sys sys 1196638943 1069
 sys/man/4/exportfs - 664 sys sys 1196638943 4655
 sys/man/4/ext2srv - 664 sys sys 1196638943 2409
-sys/man/4/factotum - 664 sys sys 1196638943 14843
+sys/man/4/factotum - 664 sys sys 1205008879 14844
 sys/man/4/fossil - 664 sys sys 1196638943 9592
 sys/man/4/fs - 664 sys sys 1196638943 3441
 sys/man/4/ftpfs - 664 sys sys 1196638943 4895
@@ -7837,7 +7837,7 @@ sys/man/8/boot - 664 sys sys 1196638946 8331
 sys/man/8/booting - 664 sys sys 1196638946 4136
 sys/man/8/cec - 664 sys sys 1196638946 1929
 sys/man/8/cpurc - 664 sys sys 1196638946 1522
-sys/man/8/cron - 664 sys sys 1196638946 1867
+sys/man/8/cron - 664 sys sys 1205008447 1959
 sys/man/8/dhcpd - 664 sys sys 1196638946 5575
 sys/man/8/diskparts - 664 sys sys 1196638946 696
 sys/man/8/disksim - 664 sys sys 1196638946 1700
@@ -8264,8 +8264,8 @@ sys/src/9/port/latin1.c - 664 sys sys 1015278339 1418
 sys/src/9/port/latin1.h - 664 sys sys 1184794985 3575
 sys/src/9/port/lib.h - 664 sys sys 1131289913 6040
 sys/src/9/port/log.c - 664 sys sys 1014931175 2860
-sys/src/9/port/master - 664 sys sys 1140695116 490
-sys/src/9/port/master.local - 664 sys sys 1063856961 130
+sys/src/9/port/master - 664 sys sys 1205009260 507
+sys/src/9/port/master.local - 664 sys sys 1205009250 117
 sys/src/9/port/mkbootrules - 775 sys sys 1055700518 923
 sys/src/9/port/mkdevc - 775 sys sys 1173287346 4203
 sys/src/9/port/mkdevlist - 775 sys sys 1173287347 612
@@ -9623,7 +9623,7 @@ sys/src/cmd/auth/changeuser.c - 664 sys sys 1155994851 2949
 sys/src/cmd/auth/convbio.c - 664 sys sys 1015008432 2212
 sys/src/cmd/auth/convkeys.c - 664 sys sys 1204007234 2707
 sys/src/cmd/auth/convkeys2.c - 664 sys sys 1155994849 2444
-sys/src/cmd/auth/cron.c - 664 sys sys 1186599442 12315
+sys/src/cmd/auth/cron.c - 664 sys sys 1205008495 13189
 sys/src/cmd/auth/debug.c - 664 sys sys 1204007269 8034
 sys/src/cmd/auth/disable - 775 sys sys 1015008431 146
 sys/src/cmd/auth/enable - 775 sys sys 1015008430 134
@@ -13390,7 +13390,7 @@ sys/src/cmd/scuzz/changer.c - 664 sys sys 944961084 1137
 sys/src/cmd/scuzz/mkfile - 664 sys sys 1032060571 231
 sys/src/cmd/scuzz/mo.words - 664 sys sys 1177702138 1262
 sys/src/cmd/scuzz/scsireq.c - 664 sys sys 1181436637 13594
-sys/src/cmd/scuzz/scsireq.h - 664 sys sys 1181435455 6692
+sys/src/cmd/scuzz/scsireq.h - 664 sys sys 1204949623 6861
 sys/src/cmd/scuzz/scuzz.c - 664 sys sys 1181436627 38286
 sys/src/cmd/scuzz/sense.c - 664 sys sys 1177702138 5680
 sys/src/cmd/sed.c - 664 sys sys 1182465504 26844
@@ -15869,4 +15869,4 @@ 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/scuzz/scsireq.h - 664 sys sys 1204949623 6861
+386/bin/auth/cron - 775 sys sys 1205035791 141213

+ 7 - 7
dist/replica/plan9.db

@@ -48,7 +48,7 @@
 386/bin/auth/changeuser - 775 sys sys 1178568246 96020
 386/bin/auth/convkeys - 775 sys sys 1204057806 87642
 386/bin/auth/convkeys2 - 775 sys sys 1203712994 87421
-386/bin/auth/cron - 775 sys sys 1188446828 140446
+386/bin/auth/cron - 775 sys sys 1205035791 141213
 386/bin/auth/debug - 775 sys sys 1204057810 101408
 386/bin/auth/disable - 775 sys sys 1020319057 146
 386/bin/auth/enable - 775 sys sys 1020319057 134
@@ -172,7 +172,7 @@
 386/bin/calendar - 775 sys sys 1200262736 79060
 386/bin/cat - 775 sys sys 1148500611 37482
 386/bin/cb - 775 sys sys 1168402293 77628
-386/bin/cdfs - 775 sys sys 1179372081 166023
+386/bin/cdfs - 775 sys sys 1205008816 166835
 386/bin/cec - 775 sys sys 1193714267 75896
 386/bin/cfs - 775 sys sys 1190863294 130565
 386/bin/chgrp - 775 sys sys 1168402294 59522
@@ -7729,7 +7729,7 @@ sys/man/4/dossrv - 664 sys sys 1196638943 4334
 sys/man/4/execnet - 664 sys sys 1196638943 1069
 sys/man/4/exportfs - 664 sys sys 1196638943 4655
 sys/man/4/ext2srv - 664 sys sys 1196638943 2409
-sys/man/4/factotum - 664 sys sys 1196638943 14843
+sys/man/4/factotum - 664 sys sys 1205008879 14844
 sys/man/4/fossil - 664 sys sys 1196638943 9592
 sys/man/4/fs - 664 sys sys 1196638943 3441
 sys/man/4/ftpfs - 664 sys sys 1196638943 4895
@@ -7837,7 +7837,7 @@ sys/man/8/boot - 664 sys sys 1196638946 8331
 sys/man/8/booting - 664 sys sys 1196638946 4136
 sys/man/8/cec - 664 sys sys 1196638946 1929
 sys/man/8/cpurc - 664 sys sys 1196638946 1522
-sys/man/8/cron - 664 sys sys 1196638946 1867
+sys/man/8/cron - 664 sys sys 1205008447 1959
 sys/man/8/dhcpd - 664 sys sys 1196638946 5575
 sys/man/8/diskparts - 664 sys sys 1196638946 696
 sys/man/8/disksim - 664 sys sys 1196638946 1700
@@ -8264,8 +8264,8 @@ sys/src/9/port/latin1.c - 664 sys sys 1015278339 1418
 sys/src/9/port/latin1.h - 664 sys sys 1184794985 3575
 sys/src/9/port/lib.h - 664 sys sys 1131289913 6040
 sys/src/9/port/log.c - 664 sys sys 1014931175 2860
-sys/src/9/port/master - 664 sys sys 1140695116 490
-sys/src/9/port/master.local - 664 sys sys 1063856961 130
+sys/src/9/port/master - 664 sys sys 1205009260 507
+sys/src/9/port/master.local - 664 sys sys 1205009250 117
 sys/src/9/port/mkbootrules - 775 sys sys 1055700518 923
 sys/src/9/port/mkdevc - 775 sys sys 1173287346 4203
 sys/src/9/port/mkdevlist - 775 sys sys 1173287347 612
@@ -9623,7 +9623,7 @@ sys/src/cmd/auth/changeuser.c - 664 sys sys 1155994851 2949
 sys/src/cmd/auth/convbio.c - 664 sys sys 1015008432 2212
 sys/src/cmd/auth/convkeys.c - 664 sys sys 1204007234 2707
 sys/src/cmd/auth/convkeys2.c - 664 sys sys 1155994849 2444
-sys/src/cmd/auth/cron.c - 664 sys sys 1186599442 12315
+sys/src/cmd/auth/cron.c - 664 sys sys 1205008495 13189
 sys/src/cmd/auth/debug.c - 664 sys sys 1204007269 8034
 sys/src/cmd/auth/disable - 775 sys sys 1015008431 146
 sys/src/cmd/auth/enable - 775 sys sys 1015008430 134

+ 7 - 0
dist/replica/plan9.log

@@ -18721,3 +18721,10 @@
 1204939804 0 c sys/src/cmd/cdfs/mmc.c - 664 sys sys 1204938193 20926
 1204948803 0 c 386/bin/9660srv - 775 sys sys 1204948766 104897
 1204950604 0 c sys/src/cmd/scuzz/scsireq.h - 664 sys sys 1204949623 6861
+1205008205 0 c sys/man/8/cron - 664 sys sys 1205008447 1959
+1205008205 1 c sys/src/cmd/auth/cron.c - 664 sys sys 1205008495 13189
+1205010004 0 c 386/bin/cdfs - 775 sys sys 1205008816 166835
+1205010004 1 c sys/man/4/factotum - 664 sys sys 1205008879 14844
+1205010004 2 c sys/src/9/port/master - 664 sys sys 1205009260 507
+1205010004 3 c sys/src/9/port/master.local - 664 sys sys 1205009250 117
+1205037004 0 c 386/bin/auth/cron - 775 sys sys 1205035791 141213

+ 1 - 1
sys/man/4/factotum

@@ -440,7 +440,7 @@ The pair must remain unchanged
 .SS "Control and Key Management
 .PP
 A number of messages can be written to the control file.
-The mesages are:
+The messages are:
 .TP
 .B "key \fIattribute-value-list\fP
 add a new key.  This will replace any old key whose

+ 7 - 0
sys/man/8/cron

@@ -114,6 +114,13 @@ Here is the job that mails system news.
 15 8-17, 21 ***	helix	/mail/lib/mailnews
 %
 .EE
+.SH FILES
+.TF /cron/lock
+.TP
+.B /cron/lock
+lock file to prevent multiple
+.IR cron s
+running
 .SH SOURCE
 .B /sys/src/cmd/auth/cron.c
 .SH "SEE ALSO"

+ 4 - 2
sys/src/9/port/master

@@ -5,10 +5,10 @@ $	pnp
 A	audio
 A	uda1341
 B	bridge
-C	ce
 D	ssl
 E	sdp
 F	flash
+F	tinyfs
 I	ip
 K	kprof
 L	lpt
@@ -42,8 +42,11 @@ v	vga
 w	wd
 y	i82365
 y	pcmcia
+z	mntstats
 |	pipe
 ¤	cap
+æ	aoe
+Ι	kbin
 κ	kbmap
 
 α	local use
@@ -55,4 +58,3 @@ y	pcmcia
 η	local use
 θ	local use
 ι	local use
-κ	local use

+ 0 - 1
sys/src/9/port/master.local

@@ -7,4 +7,3 @@
 η	local use
 θ	local use
 ι	local use
-κ	local use

+ 56 - 6
sys/src/cmd/auth/cron.c

@@ -85,6 +85,7 @@ sleepuntil(ulong tm)
 }
 
 #pragma varargck	argpos clog 1
+#pragma varargck	argpos fatal 1
 
 static void
 clog(char *fmt, ...)
@@ -98,6 +99,49 @@ clog(char *fmt, ...)
 	syslog(0, CRONLOG, msg);
 }
 
+static void
+fatal(char *fmt, ...)
+{
+	char msg[256];
+	va_list arg;
+
+	va_start(arg, fmt);
+	vseprint(msg, msg + sizeof msg, fmt, arg);
+	va_end(arg);
+	clog("%s", msg);
+	error("%s", msg);
+}
+
+static int
+openlock(char *file)
+{
+	return create(file, ORDWR, 0600);
+}
+
+static int
+mklock(char *file)
+{
+	int fd;
+	Dir *dir;
+
+	fd = openlock(file);
+	if (fd < 0)
+		return -1;
+
+	/* make it a lock file if it wasn't */
+	dir = dirfstat(fd);
+	if (dir == nil)
+		error("%s vanished: %r", file);
+	dir->mode |= DMEXCL;
+	dir->qid.type |= QTEXCL;
+	dirfwstat(fd, dir);
+	free(dir);
+
+	/* reopen in case it wasn't a lock file at last open */
+	close(fd);
+	return openlock(file);
+}
+
 void
 main(int argc, char *argv[])
 {
@@ -105,7 +149,7 @@ main(int argc, char *argv[])
 	Tm tm;
 	Time t;
 	ulong now, last;		/* in seconds */
-	int i;
+	int i, lock;
 
 	debug = 0;
 	ARGBEGIN{
@@ -125,11 +169,14 @@ main(int argc, char *argv[])
 		exits(0);
 	}
 
+	lock = mklock("/cron/lock");
+	if (lock < 0)
+		fatal("cron already running: %r");
 	initcap();
 
 	switch(fork()){
 	case -1:
-		error("can't fork");
+		fatal("can't fork");
 	case 0:
 		break;
 	default:
@@ -175,6 +222,8 @@ main(int argc, char *argv[])
 					&& j->time.mon & t.mon)
 						rexec(&users[i], j);
 		}
+		seek(lock, 0, 0);
+		write(lock, "x", 1);	/* keep the lock alive */
 		/*
 		 * if we're not at next minute yet, sleep until a second past
 		 * (to allow for sleep intervals being approximate),
@@ -221,10 +270,11 @@ readalljobs(void)
 
 	fd = open("/cron", OREAD);
 	if(fd < 0)
-		error("can't open /cron\n");
+		fatal("can't open /cron\n");
 	while((n = dirread(fd, &d)) > 0){
 		for(i = 0; i < n; i++){
-			if(strcmp(d[i].name, "log") == 0)
+			if(strcmp(d[i].name, "log") == 0 ||
+			    !(d[i].qid.type & QTDIR))
 				continue;
 			if(strcmp(d[i].name, d[i].uid) != 0){
 				syslog(1, CRONLOG, "cron for %s owned by %s\n",
@@ -572,7 +622,7 @@ emalloc(ulong n)
 
 	if(p = mallocz(n, 1))
 		return p;
-	error("out of memory");
+	fatal("out of memory");
 	return 0;
 }
 
@@ -581,7 +631,7 @@ erealloc(void *p, ulong n)
 {
 	if(p = realloc(p, n))
 		return p;
-	error("out of memory");
+	fatal("out of memory");
 	return 0;
 }