Browse Source

Plan 9 from Bell Labs 2003-12-14

David du Colombier 20 years ago
parent
commit
b83e703a7e

+ 19 - 17
dist/replica/plan9.db

@@ -17,7 +17,7 @@
 386/9pcdisk.gz - 664 sys sys 1040006345 703136
 386/9pcf - 775 sys sys 1068385833 2363147
 386/9pcf.gz - 664 sys sys 1064598456 862669
-386/9pxeload - 775 sys sys 1056364444 180364
+386/9pxeload - 775 sys sys 1071320501 188380
 386/_9pcdisk.gz - 664 sys sys 1039764191 695837
 386/bin - 20000000775 sys sys 1018897690 0
 386/bin/1c - 775 sys sys 1063639729 306762
@@ -502,7 +502,7 @@
 386/include/u.h - 664 sys sys 1042604326 1450
 386/include/ureg.h - 664 sys sys 944946012 523
 386/init - 775 sys sys 1064598407 98365
-386/ld.com - 775 sys sys 1057323610 64532
+386/ld.com - 775 sys sys 1071340494 65192
 386/lib - 20000000775 sys sys 1016826328 0
 386/lib/ape - 20000000775 sys sys 944969312 0
 386/lib/ape/lib9.a - 664 sys sys 1038237538 6378
@@ -5024,7 +5024,7 @@ sys/man/8/fs - 664 sys sys 1055701170 15029
 sys/man/8/fsconfig - 664 sys sys 1045501600 8142
 sys/man/8/httpd - 664 sys sys 1065640802 6426
 sys/man/8/init - 664 sys sys 944959679 1430
-sys/man/8/ipconfig - 664 sys sys 1060189415 5050
+sys/man/8/ipconfig - 664 sys sys 1071340739 6037
 sys/man/8/ipserv - 664 sys sys 1063855796 4337
 sys/man/8/kfscmd - 664 sys sys 1068569797 4515
 sys/man/8/listen - 664 sys sys 1045501609 3740
@@ -5109,7 +5109,7 @@ sys/src/9/alphapc/main.c - 664 sys sys 1039753420 13626
 sys/src/9/alphapc/mem.h - 664 sys sys 1017166326 3132
 sys/src/9/alphapc/memmove.s - 664 sys sys 1015012786 2936
 sys/src/9/alphapc/memset.s - 664 sys sys 1015012786 844
-sys/src/9/alphapc/mkfile - 664 sys sys 1071245505 2014
+sys/src/9/alphapc/mkfile - 664 sys sys 1071320227 2030
 sys/src/9/alphapc/mmu.c - 664 sys sys 1015012786 4872
 sys/src/9/alphapc/mouse.c - 664 sys sys 1015012786 25
 sys/src/9/alphapc/pci.c - 664 sys sys 1039753420 7868
@@ -5226,7 +5226,7 @@ sys/src/9/ip/nullmedium.c - 664 sys sys 1022588099 491
 sys/src/9/ip/pktmedium.c - 664 sys sys 1045063516 1355
 sys/src/9/ip/ptclbsum.c - 664 sys sys 1022588099 1243
 sys/src/9/ip/rudp.c - 664 sys sys 1055700790 21415
-sys/src/9/ip/tcp.c - 664 sys sys 1070287819 65399
+sys/src/9/ip/tcp.c - 664 sys sys 1071335383 65391
 sys/src/9/ip/tripmedium.c - 664 sys sys 1045063515 7136
 sys/src/9/ip/udp.c - 664 sys sys 1055700791 13069
 sys/src/9/mkfile - 664 sys sys 1063857477 205
@@ -5267,7 +5267,7 @@ sys/src/9/pc/archmp.c - 664 sys sys 1067722683 2323
 sys/src/9/pc/audio.h - 664 sys sys 1015014513 343
 sys/src/9/pc/cga.c - 664 sys sys 1015014513 1843
 sys/src/9/pc/dat.h - 664 sys sys 1071245548 6177
-sys/src/9/pc/devarch.c - 664 sys sys 1068466702 17542
+sys/src/9/pc/devarch.c - 664 sys sys 1071320330 18127
 sys/src/9/pc/devether.c - 664 sys sys 1048644042 10178
 sys/src/9/pc/devfloppy.c - 664 sys sys 1055689885 20024
 sys/src/9/pc/devi82365.c - 664 sys sys 1020284820 19987
@@ -5438,6 +5438,7 @@ sys/src/9/port/mkroot - 775 sys sys 1039753334 235
 sys/src/9/port/mkrootall - 775 sys sys 1055954696 386
 sys/src/9/port/mkrootc - 775 sys sys 1055954695 717
 sys/src/9/port/mksystab - 664 sys sys 1014931176 783
+sys/src/9/port/mul64fract.c - 664 sys sys 1071320142 618
 sys/src/9/port/netif.c - 664 sys sys 1066514951 13421
 sys/src/9/port/netif.h - 664 sys sys 1066514947 2975
 sys/src/9/port/nulledf.c - 664 sys sys 1037669300 821
@@ -6877,9 +6878,10 @@ sys/src/cmd/auth/lib/readn.c - 664 sys sys 1015008430 247
 sys/src/cmd/auth/lib/readwrite.c - 664 sys sys 1015008430 1424
 sys/src/cmd/auth/lib/wrbio.c - 664 sys sys 1015008430 755
 sys/src/cmd/auth/login.c - 664 sys sys 1048614961 3963
-sys/src/cmd/auth/mkfile - 664 sys sys 1048644402 1978
+sys/src/cmd/auth/mkfile - 664 sys sys 1071334970 1979
 sys/src/cmd/auth/netkey.c - 664 sys sys 1015008431 741
 sys/src/cmd/auth/newns.c - 664 sys sys 1048614962 486
+sys/src/cmd/auth/none.c - 664 sys sys 1071334976 744
 sys/src/cmd/auth/passwd.c - 664 sys sys 1055699009 2761
 sys/src/cmd/auth/pemdecode.c - 664 sys sys 1048614962 942
 sys/src/cmd/auth/pemencode.c - 664 sys sys 1048614963 998
@@ -7055,7 +7057,7 @@ sys/src/cmd/aux/rdwr.c - 664 sys sys 1016833876 811
 sys/src/cmd/aux/reboot.c - 664 sys sys 1014925091 1411
 sys/src/cmd/aux/searchfs.c - 664 sys sys 1014925091 18176
 sys/src/cmd/aux/stub.c - 664 sys sys 1032468954 2637
-sys/src/cmd/aux/timesync.c - 664 sys sys 1063897024 24500
+sys/src/cmd/aux/timesync.c - 664 sys sys 1071334828 24811
 sys/src/cmd/aux/trampoline.c - 664 sys sys 1034780422 3571
 sys/src/cmd/aux/typepasswd.c - 664 sys sys 1014925091 1761
 sys/src/cmd/aux/unlock - 664 sys sys 944960793 0
@@ -7386,7 +7388,7 @@ sys/src/cmd/disk/kfs/portfns.h - 664 sys sys 1020313861 2804
 sys/src/cmd/disk/kfs/porttime.c - 664 sys sys 1015009190 3922
 sys/src/cmd/disk/kfs/print.c - 664 sys sys 944960882 3573
 sys/src/cmd/disk/kfs/sub.c - 664 sys sys 1022008488 10804
-sys/src/cmd/disk/kfs/uid.c - 664 sys sys 1022008489 6719
+sys/src/cmd/disk/kfs/uid.c - 664 sys sys 1071335904 6791
 sys/src/cmd/disk/kfscmd.c - 664 sys sys 1015009135 1109
 sys/src/cmd/disk/mbr.c - 664 sys sys 1063855285 4325
 sys/src/cmd/disk/mkext.c - 664 sys sys 1070377355 5716
@@ -10380,8 +10382,8 @@ sys/src/cmd/tapefs/fs.c - 664 sys sys 1032060630 9777
 sys/src/cmd/tapefs/mkfile - 664 sys sys 1032060649 258
 sys/src/cmd/tapefs/tapefs.h - 664 sys sys 1014926384 1609
 sys/src/cmd/tapefs/tapfs.c - 664 sys sys 1063854819 1938
-sys/src/cmd/tapefs/tarfs.c - 664 sys sys 1026672564 2597
-sys/src/cmd/tapefs/tpfs.c - 664 sys sys 953243008 1966
+sys/src/cmd/tapefs/tarfs.c - 664 sys sys 1071322741 2621
+sys/src/cmd/tapefs/tpfs.c - 664 sys sys 1071322722 2012
 sys/src/cmd/tapefs/util.c - 664 sys sys 1014926385 2653
 sys/src/cmd/tapefs/v10fs.c - 664 sys sys 1014926385 3754
 sys/src/cmd/tapefs/v6fs.c - 664 sys sys 1014926385 3971
@@ -10756,7 +10758,7 @@ sys/src/cmd/upas/common/aux.c - 664 sys sys 1019498851 2300
 sys/src/cmd/upas/common/become.c - 664 sys sys 1015009623 430
 sys/src/cmd/upas/common/common.h - 664 sys sys 1015009623 1921
 sys/src/cmd/upas/common/config.c - 664 sys sys 944961316 254
-sys/src/cmd/upas/common/libsys.c - 664 sys sys 1070287921 14107
+sys/src/cmd/upas/common/libsys.c - 664 sys sys 1071334866 14459
 sys/src/cmd/upas/common/mail.c - 664 sys sys 944961315 1346
 sys/src/cmd/upas/common/makefile - 664 sys sys 944961315 366
 sys/src/cmd/upas/common/mkfile - 664 sys sys 1031707285 251
@@ -10776,9 +10778,9 @@ sys/src/cmd/upas/fs - 20000000775 sys sys 988250018 0
 sys/src/cmd/upas/fs/dat.h - 664 sys sys 1047490337 4267
 sys/src/cmd/upas/fs/fs.c - 664 sys sys 1068350246 27381
 sys/src/cmd/upas/fs/imap4.c - 664 sys sys 1061779754 18103
-sys/src/cmd/upas/fs/mbox.c - 664 sys sys 1068350247 28726
+sys/src/cmd/upas/fs/mbox.c - 664 sys sys 1071334860 28493
 sys/src/cmd/upas/fs/mkfile - 664 sys sys 1047490336 321
-sys/src/cmd/upas/fs/plan9.c - 664 sys sys 1047490343 7464
+sys/src/cmd/upas/fs/plan9.c - 664 sys sys 1071334861 7465
 sys/src/cmd/upas/fs/pop3.c - 664 sys sys 1063854740 12408
 sys/src/cmd/upas/fs/readdir.c - 664 sys sys 944961331 203
 sys/src/cmd/upas/fs/strtotm.c - 664 sys sys 1041137528 1904
@@ -10809,14 +10811,14 @@ sys/src/cmd/upas/ml/mlmgr.c - 664 sys sys 1045505888 2332
 sys/src/cmd/upas/ml/mlowner.c - 664 sys sys 1015096763 1142
 sys/src/cmd/upas/ned - 20000000775 sys sys 1015013194 0
 sys/src/cmd/upas/ned/mkfile - 664 sys sys 1060041738 233
-sys/src/cmd/upas/ned/nedmail.c - 664 sys sys 1067722837 42995
+sys/src/cmd/upas/ned/nedmail.c - 664 sys sys 1071335787 43442
 sys/src/cmd/upas/pop3 - 20000000775 sys sys 1015009816 0
 sys/src/cmd/upas/pop3/mkfile - 664 sys sys 1064589604 186
 sys/src/cmd/upas/pop3/pop3.c - 664 sys sys 1063854524 14283
 sys/src/cmd/upas/q - 20000000775 sys sys 988250019 0
 sys/src/cmd/upas/q/mkfile - 664 sys sys 1064589601 262
 sys/src/cmd/upas/q/qer.c - 664 sys sys 1014926528 3179
-sys/src/cmd/upas/q/runq.c - 664 sys sys 1063858968 11982
+sys/src/cmd/upas/q/runq.c - 664 sys sys 1071335819 11904
 sys/src/cmd/upas/scanmail - 20000000775 sys sys 988250021 0
 sys/src/cmd/upas/scanmail/common.c - 664 sys sys 1015013177 12385
 sys/src/cmd/upas/scanmail/mkfile - 664 sys sys 1064589604 334
@@ -10845,7 +10847,7 @@ sys/src/cmd/upas/send/skipequiv.c - 664 sys sys 944961322 1747
 sys/src/cmd/upas/send/translate.c - 664 sys sys 944961322 804
 sys/src/cmd/upas/send/tryit - 664 sys sys 944961322 584
 sys/src/cmd/upas/smtp - 20000000775 sys sys 988250017 0
-sys/src/cmd/upas/smtp/greylist.c - 664 sys sys 1067741333 5588
+sys/src/cmd/upas/smtp/greylist.c - 664 sys sys 1071335923 5588
 sys/src/cmd/upas/smtp/mkfile - 664 sys sys 1067722781 746
 sys/src/cmd/upas/smtp/mxdial.c - 664 sys sys 1055703150 4887
 sys/src/cmd/upas/smtp/rfc822.y - 664 sys sys 1064589606 13417

+ 19 - 0
dist/replica/plan9.log

@@ -13110,3 +13110,22 @@
 1071261032 0 c sys/src/cmd/auth/factotum/apop.c - 664 sys sys 1071260312 6074
 1071289835 0 c sys/man/2/encode - 664 sys sys 1071289168 1572
 1071289835 1 c sys/src/libc/port/encodefmt.c - 664 sys sys 1071289162 1100
+1071320440 0 c sys/src/9/alphapc/mkfile - 664 sys sys 1071320227 2030
+1071320440 1 c sys/src/9/pc/devarch.c - 664 sys sys 1071320330 18127
+1071320440 2 a sys/src/9/port/mul64fract.c - 664 sys sys 1071320142 618
+1071322240 0 c 386/9pxeload - 775 sys sys 1071320501 188380
+1071324040 0 c sys/src/cmd/tapefs/tarfs.c - 664 sys sys 1071322741 2621
+1071324040 1 c sys/src/cmd/tapefs/tpfs.c - 664 sys sys 1071322722 2012
+1071334841 0 c sys/src/cmd/aux/timesync.c - 664 sys sys 1071334828 24811
+1071334841 1 c sys/src/cmd/upas/common/libsys.c - 664 sys sys 1071334866 14459
+1071334841 2 c sys/src/cmd/upas/fs/mbox.c - 664 sys sys 1071334860 28493
+1071334841 3 c sys/src/cmd/upas/fs/plan9.c - 664 sys sys 1071334861 7465
+1071336642 0 c sys/src/9/ip/tcp.c - 664 sys sys 1071335383 65391
+1071336642 1 c sys/src/cmd/auth/mkfile - 664 sys sys 1071334970 1979
+1071336642 2 a sys/src/cmd/auth/none.c - 664 sys sys 1071334976 744
+1071336642 3 c sys/src/cmd/disk/kfs/uid.c - 664 sys sys 1071335904 6791
+1071336642 4 c sys/src/cmd/upas/ned/nedmail.c - 664 sys sys 1071335787 43442
+1071336642 5 c sys/src/cmd/upas/q/runq.c - 664 sys sys 1071335819 11904
+1071336642 6 c sys/src/cmd/upas/smtp/greylist.c - 664 sys sys 1071335923 5588
+1071342042 0 c 386/ld.com - 775 sys sys 1071340494 65192
+1071342042 1 c sys/man/8/ipconfig - 664 sys sys 1071340739 6037

+ 35 - 0
sys/man/8/ipconfig

@@ -16,6 +16,8 @@ ipconfig, rip \- Internet configuration and routing
 .IR hostname ]
 .RB [ -x
 .IR netmtpt ]
+.RB [ -o
+.IR dhcpoption ]
 .I type
 .I device
 .RI [ verb ]
@@ -153,6 +155,39 @@ use the IP stack mounted at
 .I netmtpt
 instead of at
 .BR /net .
+.TP
+.B o
+adds
+.I dhcpoption
+to the list of paramters requested of the DHCP server.  The
+result will appear in
+.B /net/ndb
+should this be the first interface.  The known options are:
+
+  ipmask, timeoff, ipgw, time, name, dns, log, cookie,
+  lpr, impress, rl, sys, bflen, dumpfile, dom, swap,
+  rootpath, extpath, ipforward, nonlocal, policyfilter,
+  maxdatagram, ttl, pathtimeout, pathplateau, mtu,
+  subnetslocal, baddr, discovermask, supplymask,
+  discoverrouter, rs, staticroutes, trailerencap,
+  arptimeout, etherencap, tcpttl, tcpka, tcpkag,
+  nisdomain, ni, ntp, netbiosns, netbiosdds,
+  netbiostype, netbiosscope, xfont, xdispmanager,
+  nisplusdomain, nisplus, homeagent, smtp, pop3, nntp,
+  www, finger, irc, st, stdar, , ipaddr, lease,
+  overload, type, serverid, params, message, maxmsg,
+  renewaltime, rebindingtime, vendorclass, clientid,
+  tftp, bootfile
+
+.EE
+The options
+.BR ipmask ,
+.BR ipgw ,
+.BR dns ,
+.BR sys ,
+and
+.B ntp
+are always requested.
 .PD
 .PP
 If DHCP is requested, a process is forked

+ 1 - 0
sys/src/9/alphapc/mkfile

@@ -19,6 +19,7 @@ PORT=\
 	latin1.$O\
 	log.$O\
 	edf.$O\
+	mul64fract.$O\
 	page.$O\
 	parse.$O\
 	pgrp.$O\

+ 2 - 3
sys/src/9/ip/tcp.c

@@ -1856,8 +1856,7 @@ update(Conv *s, Tcp *seg)
 			expand = tcb->snd.wnd - tcb->cwind;
 		if(tcb->cwind + expand > tcb->snd.wnd)
 			expand = tcb->snd.wnd - tcb->cwind;
-		if(expand != 0)
-			tcb->cwind += expand;
+		tcb->cwind += expand;
 	}
 
 	/* Adjust the timers according to the round trip time */
@@ -2137,7 +2136,7 @@ reset:
 
 	/* Cut the data to fit the receive window */
 	if(tcptrim(tcb, &seg, &bp, &length) == -1) {
-		netlog(f, Logtcp, "tcp len < 0, %lux\n", seg.seq);
+		netlog(f, Logtcp, "tcp len < 0, %lud %d\n", seg.seq, length);
 		update(s, &seg);
 		if(qlen(s->wq)+tcb->flgcnt == 0 && tcb->state == Closing) {
 			tcphalt(tpriv, &tcb->rtt_timer);

+ 36 - 14
sys/src/9/pc/devarch.c

@@ -55,7 +55,7 @@ int narchdir = Qbase;
 int (*_pcmspecial)(char*, ISAConf*);
 void (*_pcmspecialclose)(int);
 
-static int dotimerset = 1;
+static int doi8253set = 1;
 
 /*
  * Add a file to the #P listing.  Once added, you can't delete it.
@@ -218,7 +218,7 @@ ioalloc(int port, int size, int align, char *tag)
 		}
 	} else {
 		// Only 64KB I/O space on the x86.
-		if((port+size) >= 0x10000){
+		if((port+size) > 0x10000){
 			unlock(&iomap);
 			return -1;
 		}
@@ -497,13 +497,13 @@ nop(void)
 
 /*
  * On a uniprocessor, you'd think that coherence could be nop,
- * but it can't.  We still need wbflush when using coherence() in
+ * but it can't.  We still need a barrier when using coherence() in
  * device drivers.
  *
  * On VMware, it's safe (and a huge win) to set this to nop.
  * Aux/vmware does this via the #P/archctl file.
  */
-void (*coherence)(void) = wbflush;
+void (*coherence)(void) = nop;
 
 PCArch* arch;
 extern PCArch* knownarch[];
@@ -525,12 +525,13 @@ PCArch archgeneric = {
 .timerset=	i8253timerset,
 };
 
-typedef struct {
+typedef struct X86type X86type;
+struct X86type {
 	int	family;
 	int	model;
 	int	aalcycles;
 	char*	name;
-} X86type;
+};
 
 static X86type x86intel[] =
 {
@@ -721,6 +722,12 @@ cpuidentify(void)
 		if(m->cpuiddx & 0x80)
 			rdmsr(0x01, &mct);
 	}
+if(m->cpuiddx & 0x20){
+    vlong apicbase;
+
+    rdmsr(0x1B, &apicbase);
+    print("apicbase 0x%lluX\n", apicbase);
+}
 
 	cputype = t;
 	return t->family;
@@ -748,9 +755,16 @@ archctlread(Chan*, void *a, long nn, vlong offset)
 		cputype->name, (ulong)(m->cpuhz+999999)/1000000,
 		m->havepge ? " pge" : "");
 	n += snprint(buf+n, sizeof buf-n, "pge %s\n", getcr4()&0x80 ? "on" : "off");
-	n += snprint(buf+n, sizeof buf-n, "coherence %s\n",
-		coherence==wbflush ? "wbflush" : "nop");
-	n += snprint(buf+n, sizeof buf-n, "timerset %s\n", dotimerset ? "on" : "off");
+	n += snprint(buf+n, sizeof buf-n, "coherence ");
+	if(coherence == mb386)
+		n += snprint(buf+n, sizeof buf-n, "mb386\n");
+	else if(coherence == mb586)
+		n += snprint(buf+n, sizeof buf-n, "mb586\n");
+	else if(coherence == nop)
+		n += snprint(buf+n, sizeof buf-n, "nop\n");
+	else
+		n += snprint(buf+n, sizeof buf-n, "0x%p\n", coherence);
+	n += snprint(buf+n, sizeof buf-n, "i8253set %s\n", doi8253set ? "on" : "off");
 	buf[n] = 0;
 	return readstr(offset, a, nn, buf);
 }
@@ -793,8 +807,13 @@ archctlwrite(Chan*, void *a, long n, vlong)
 			cmderror(cb, "invalid pge ctl");
 		break;
 	case CMcoherence:
-		if(strcmp(cb->f[1], "wbflush") == 0)
-			coherence = wbflush;
+		if(strcmp(cb->f[1], "mb386") == 0)
+			coherence = mb386;
+		else if(strcmp(cb->f[1], "mb586") == 0){
+			if(X86FAMILY(m->cpuidax) < 5)
+				error("invalid coherence ctl on this cpu family");
+			coherence = mb586;
+		}
 		else if(strcmp(cb->f[1], "nop") == 0){
 			/* only safe on vmware */
 			if(conf.nmach > 1)
@@ -805,9 +824,9 @@ archctlwrite(Chan*, void *a, long n, vlong)
 		break;
 	case CMi8253set:
 		if(strcmp(cb->f[1], "on") == 0)
-			dotimerset = 1;
+			doi8253set = 1;
 		else if(strcmp(cb->f[1], "off") == 0){
-			dotimerset = 0;
+			doi8253set = 0;
 			(*arch->timerset)(0);
 		}else
 			cmderror(cb, "invalid i2853set ctl");
@@ -855,6 +874,9 @@ archinit(void)
 	if(X86FAMILY(m->cpuidax) == 3)
 		conf.copymode = 1;
 
+	if(X86FAMILY(m->cpuidax) >= 5)
+		coherence = mb586;
+
 	addarchfile("cputype", 0444, cputyperead, nil);
 	addarchfile("archctl", 0664, archctlread, archctlwrite);
 }
@@ -893,6 +915,6 @@ fastticks(uvlong *hz)
 void
 timerset(uvlong x)
 {
-	if(dotimerset)
+	if(doi8253set)
 		(*arch->timerset)(x);
 }

+ 28 - 0
sys/src/9/port/mul64fract.c

@@ -0,0 +1,28 @@
+#include <u.h>
+
+// multiply two 64 numbers and return the middle 64 bits of the 128 bit result.
+// the assummption is that one of the numbers is a fixed point number with the
+// decimal to the left of the low order 32 bits.
+//
+// there should be an assembler version of this routine for each architecture.
+// this one is provided to make ports easier.
+
+void
+mul64fract(uvlong *r, uvlong a, uvlong b)
+{
+	uvlong bh, bl;
+	uvlong ah, al;
+	uvlong res;
+
+	bl = b & 0xffffffffULL;
+	bh = b >> 32;
+	al = a & 0xffffffffULL;
+	ah = a >> 32;
+
+	res = (al*bl)>>32;
+	res += (al*bh);
+	res += (ah*bl);
+	res += (ah*bh)<<32;
+
+	*r = res;
+}

+ 1 - 1
sys/src/cmd/auth/mkfile

@@ -11,11 +11,11 @@ TARG=\
 	cron\
 	debug\
 	guard.srv\
-	iam\
 	keyfs\
 	login\
 	netkey\
 	newns\
+	none\
 	passwd\
 	pemdecode\
 	pemencode\

+ 39 - 0
sys/src/cmd/auth/none.c

@@ -0,0 +1,39 @@
+#include <u.h>
+#include <libc.h>
+#include <auth.h>
+
+void
+main(int argc, char *argv[])
+{
+	char cmd[256];
+	int fd;
+
+	argv0 = argv[0];
+	if (rfork(RFENVG|RFNAMEG) < 0)
+		sysfatal("can't make new pgrp");
+
+	fd = open("#c/user", OWRITE);
+	if (fd < 0)
+		sysfatal("can't open #c/user");
+	if (write(fd, "none", strlen("none")) < 0)
+		sysfatal("can't become none");
+	close(fd);
+
+	if (newns("none", nil) < 0)
+		sysfatal("can't build namespace");
+
+	if (argc > 1) {
+		strcpy(cmd, argv[1]);
+		exec(cmd, &argv[1]);
+		if (strncmp(cmd, "/", 1) != 0
+		&& strncmp(cmd, "./", 2) != 0
+		&& strncmp(cmd, "../", 3) != 0) {
+			sprint(cmd, "/bin/%s", argv[1]);
+			exec(cmd, &argv[1]);
+		}
+	} else {
+		strcpy(cmd, "/bin/rc");
+		execl(cmd, cmd, nil);
+	}
+	sysfatal(cmd);
+}

+ 15 - 1
sys/src/cmd/aux/timesync.c

@@ -94,6 +94,9 @@ enum
 	NTPDIGESTSIZE=	20,		// key and digest
 };
 
+// error bound of last sample
+ulong	ε;
+
 static void	addntpserver(char *name);
 static int	adjustperiod(vlong diff, vlong accuracy, int secs);
 static void	background(void);
@@ -329,6 +332,7 @@ main(int argc, char **argv)
 		diff = 0;
 
 		// get times for this sample
+		ε = ~0;
 		switch(type){
 		case Fs:
 			s->stime = sample(fstime);
@@ -390,7 +394,16 @@ main(int argc, char **argv)
 			// second (or so) the kernel will add diff/(4*secs*100)
 			// to the clock.  we only do 1/4 of the difference per
 			// period to dampen any measurement noise.
-			settime(-1, 0, diff, 4*secs);
+			//
+			// any difference greater than ε we work off during the
+			// sampling period.
+			if(abs(diff) > ε){
+				if(diff > 0)
+					settime(-1, 0, diff-((3*ε)/4), secs);
+				else
+					settime(-1, 0, diff+((3*ε)/4), secs);
+			} else
+				settime(-1, 0, diff, 4*secs);
 
 		}
 		if(debug)
@@ -996,6 +1009,7 @@ ntpsample(void)
 	else
 		stratum = ns->stratum + 1;
 
+	ε = abs(ns->rtt/2);
 	return ns->dt;
 }
 

+ 12 - 7
sys/src/cmd/disk/kfs/uid.c

@@ -151,6 +151,14 @@ cmd_user(void)
 	int c, n, o, u, g, i;
 	char name[NAMELEN];
 
+	if(con_clone(FID1, FID2))
+		goto ainitu;
+	if(con_path(FID2, "/adm/users"))
+		goto ainitu;
+	if(con_open(FID2, 0)){
+		goto ainitu;
+	}
+
 	wlock(&uidgc.uidlock);
 	uidgc.uidbuf = malloc(MAXDAT);
 
@@ -158,13 +166,6 @@ cmd_user(void)
 	memset(uidspace, 0, conf.uidspace * sizeof(*uidspace));
 	memset(gidspace, 0, conf.gidspace * sizeof(*gidspace));
 
-	if(con_clone(FID1, FID2))
-		goto initu;
-	if(con_path(FID2, "/adm/users"))
-		goto initu;
-	if(con_open(FID2, 0))
-		goto initu;
-
 	uidgc.flen = 0;
 	uidgc.find = 0;
 	cons.offset = 0;
@@ -302,6 +303,10 @@ gskip:
 	}
 	goto out;
 
+ainitu:
+	wlock(&uidgc.uidlock);
+	uidgc.uidbuf = malloc(MAXDAT);
+
 initu:
 	cprint("initializing minimal user table\n");
 	memset(uid, 0, conf.nuid * sizeof(*uid));

+ 1 - 0
sys/src/cmd/tapefs/tarfs.c

@@ -58,6 +58,7 @@ populate(char *name)
 		/* the mode test is ugly but sometimes necessary */
 		if (dblock.dbuf.linkflag == '5' || (f.mode&0170000) == 040000)
 			f.mode |= DMDIR;
+		f.mode &= DMDIR|0777;
 		linkflg = dblock.dbuf.linkflag=='s' || dblock.dbuf.linkflag=='1';
 		isabs = dblock.dbuf.name[0]=='/';
 		if (chksum != checksum()){

+ 2 - 0
sys/src/cmd/tapefs/tpfs.c

@@ -57,6 +57,8 @@ populate(char *name)
 		f.mdate = (tpp->tmod[2]<<0) + (tpp->tmod[3]<<8)
 		     +(tpp->tmod[0]<<16) + (tpp->tmod[1]<<24);
 		f.mode = tpp->mode[0]&0777;
+		f.uid = tpp->uid[0];
+		f.gid = tpp->gid[0];
 		isabs = tpp->name[0]=='/';
 		f.name = (char *)tpp->name+isabs;
 		poppath(f, 1);

+ 20 - 15
sys/src/cmd/upas/common/libsys.c

@@ -46,7 +46,7 @@ getlog(void)
 }
 
 /*
- *  return the lock name
+ *  return the lock name (we use one lock per directory)
  */
 static String *
 lockname(char *path)
@@ -59,15 +59,9 @@ lockname(char *path)
 	 */
 	lp = s_new();
 	cp = strrchr(path, '/');
-	if(cp){
-		cp++;
-		s_nappend(lp, path, cp - path);
-	} else {
-		
-		cp = path;
-	}
-	s_append(lp, "L.");
-	s_nappend(lp, cp, Elemlen-3);
+	if(cp)
+		s_nappend(lp, path, cp - path + 1);
+	s_append(lp, "L.mbox");
 
 	return lp;
 }
@@ -116,7 +110,12 @@ openlockfile(Mlock *l)
 		if(fd >= 0){
 			nulldir(&nd);
 			nd.mode = DMEXCL|0666;
-			dirfwstat(fd, &nd);
+			if(dirfwstat(fd, &nd) < 0){
+				/* if we can't chmod, don't bother */
+				/* live without the lock but log it */
+				syslog(0, "mail", "lock error: %s: %r", s_to_c(l->name));
+				remove(s_to_c(l->name));
+			}
 			l->fd = fd;
 			return 0;
 		}
@@ -128,12 +127,18 @@ openlockfile(Mlock *l)
 			*p = 0;
 			fd = access(s_to_c(l->name), 2);
 			*p = '/';
-			if(fd < 0)
-				return -1;	/* give up */
+			if(fd < 0){
+				/* live without the lock but log it */
+				syslog(0, "mail", "lock error: %s: %r", s_to_c(l->name));
+				return 0;
+			}
 		} else {
 			fd = access(".", 2);
-			if(fd < 0)
-				return -1;	/* give up */
+			if(fd < 0){
+				/* live without the lock but log it */
+				syslog(0, "mail", "lock error: %s: %r", s_to_c(l->name));
+				return 0;
+			}
 		}
 	} else
 		free(d);

+ 2 - 7
sys/src/cmd/upas/fs/mbox.c

@@ -68,7 +68,6 @@ static	void	initheaders(void);
 static void	parseattachments(Message*, Mailbox*);
 
 int		debug;
-char		stdmbox[Pathlen];
 
 char *Enotme = "path not served by this file server";
 
@@ -99,9 +98,6 @@ newmbox(char *path, char *name, int std)
 
 	initheaders();
 
-	if(stdmbox[0] == 0)
-		snprint(stdmbox, sizeof(stdmbox), "/mail/box/%s/mbox", user);
-
 	mb = emalloc(sizeof(*mb));
 	strncpy(mb->path, path, sizeof(mb->path)-1);
 	if(name == nil){
@@ -151,9 +147,8 @@ newmbox(char *path, char *name, int std)
 		}
 	}
 
-	// all mailboxes in /mail/box/$user are locked using /mail/box/$user/mbox
-	p = strrchr(stdmbox, '/');
-	mb->dolock = strncmp(mb->path, stdmbox, p - stdmbox) == 0;
+	// always try locking
+	mb->dolock = 1;
 
 	mb->refs = 1;
 	mb->next = nil;

+ 1 - 1
sys/src/cmd/upas/fs/plan9.c

@@ -365,7 +365,7 @@ plan9syncmbox(Mailbox *mb, int doplumb)
 
 	lk = nil;
 	if(mb->dolock){
-		lk = syslock(stdmbox);
+		lk = syslock(mb->path);
 		if(lk == nil)
 			return "can't lock mailbox";
 	}

+ 28 - 5
sys/src/cmd/upas/ned/nedmail.c

@@ -147,6 +147,7 @@ struct Cmd {
 Biobuf out;
 int startedfs;
 int reverse;
+int longestfrom = 12;
 
 String*		file2string(String*, char*);
 int		dir2message(Message*, int);
@@ -443,10 +444,15 @@ dir2message(Message *parent, int reverse)
 	close(fd);
 	parent->child = first;
 
-	// renumber
+	// renumber and file longest from
 	i = 1;
-	for(m = first; m != nil; m = m->next)
+	longestfrom = 12;
+	for(m = first; m != nil; m = m->next){
 		m->id = natural ? m->fileno : i++;
+		n = strlen(m->from);
+		if(n > longestfrom)
+			longestfrom = n;
+	}
 
 	return newmsgs;
 }
@@ -701,6 +707,7 @@ snprintheader(char *buf, int len, Message *m)
 {
 	char timebuf[32];
 	String *id;
+	char *p, *q;;
 
 	// create id
 	id = s_new();
@@ -714,16 +721,32 @@ snprintheader(char *buf, int len, Message *m)
 			m->len,
 			m->filename);
 	} else if(*m->subject){
+		q = p = strdup(m->subject);
+		for(;;){
+			while(*p == ' ')
+				p++;
+			if(cistrncmp(p, "re:", 3) == 0)
+				p += 3;
+			else if(cistrncmp(p, "fwd:", 4) == 0)
+				p += 4;
+			else if(cistrncmp(p, "fw:", 4) == 0)
+				p += 3;
+			else
+				break;
+		}
+		if(strlen(p) > 50)
+			p[50] = 0;
 		cracktime(m->date, timebuf, sizeof(timebuf));
-		snprint(buf, len, "%-3s %c%c%c %6d  %11.11s %-32.32s %-32.32s",
+		snprint(buf, len, "%-3s %c%c%c %6d  %11.11s %-*.*s %s",
 			s_to_c(id),
 			m->child ? 'H' : ' ',
 			m->deleted ? 'd' : ' ',
 			m->stored ? 's' : ' ',
 			m->len,
 			timebuf,
-			m->from,
-			m->subject);
+			longestfrom, longestfrom, m->from,
+			p);
+		free(q);
 	} else {
 		cracktime(m->date, timebuf, sizeof(timebuf));
 		snprint(buf, len, "%-3s %c%c%c %6d  %11.11s %s",

+ 5 - 9
sys/src/cmd/upas/q/runq.c

@@ -412,14 +412,9 @@ dofile(Dir *dp)
 	av[ac] = 0;
 
 	if(!Eflag &&time(0) - dtime > giveup){
-		if(returnmail(av, dp->name, "Giveup") == 0)
-			remmatch(dp->name);
-		else {
-			if(time(0) - dtime < giveup + 2*60*60)
-				logit("returnmail failed", dp->name, av);
-			if(time(0) - dtime > giveup + 24*60*60)
-				remmatch(dp->name);
-		}
+		if(returnmail(av, dp->name, "Giveup") != 0)
+			logit("returnmail failed", dp->name, av);
+		remmatch(dp->name);
 		goto done;
 	}
 
@@ -474,7 +469,8 @@ dofile(Dir *dp)
 			if(!Rflag && strstr(wm->msg, "Retry")==0){
 				/* return the message and remove it */
 				if(returnmail(av, dp->name, wm->msg) == 0)
-					remmatch(dp->name);
+					logit("returnmail failed", dp->name, av);
+				remmatch(dp->name);
 			} else {
 				/* add sys to bad list and try again later */
 				nbad++;

+ 1 - 1
sys/src/cmd/upas/smtp/greylist.c

@@ -13,7 +13,7 @@
  * again until after 5 PM.  Doh!
  */
 enum {
-	Nonspammax = 10*60*60,  /* must call back within this time if real */
+	Nonspammax = 14*60*60,  /* must call back within this time if real */
 };
 static char whitelist[] = "/mail/lib/whitelist";