Browse Source

Plan 9 from Bell Labs 2004-04-06

David du Colombier 20 years ago
parent
commit
db6ad113c8

+ 20 - 15
dist/replica/plan9.db

@@ -1260,7 +1260,7 @@ lib/face/48x48x2/x - 20000000755 sys sys 944941683 0
 lib/face/48x48x2/y - 20000000755 sys sys 944941683 0
 lib/face/48x48x2/z - 20000000755 sys sys 944941683 0
 lib/face/48x48x4 - 20000000775 sys sys 944941894 0
-lib/face/48x48x4/.dict - 664 sys sys 1079017691 2391
+lib/face/48x48x4/.dict - 664 sys sys 1081200610 2417
 lib/face/48x48x4/Z - 20000000775 sys sys 944945342 0
 lib/face/48x48x4/a - 20000000775 sys sys 944945701 0
 lib/face/48x48x4/a/adb.1 - 664 sys sys 944941890 962
@@ -1371,7 +1371,7 @@ lib/face/48x48x4/x - 20000000775 sys sys 944941894 0
 lib/face/48x48x4/y - 20000000775 sys sys 944941894 0
 lib/face/48x48x4/z - 20000000775 sys sys 944941894 0
 lib/face/48x48x8 - 20000000775 sys sys 944941834 0
-lib/face/48x48x8/.dict - 664 sys sys 1079103826 2117
+lib/face/48x48x8/.dict - 664 sys sys 1081200562 2146
 lib/face/48x48x8/Z - 20000000775 sys sys 944941832 0
 lib/face/48x48x8/a - 20000000775 sys sys 944941832 0
 lib/face/48x48x8/a/axel.1 - 664 sys sys 1056983599 473
@@ -1405,6 +1405,7 @@ lib/face/48x48x8/m/michael.1 - 664 sys sys 1057005144 1806
 lib/face/48x48x8/n - 20000000775 sys sys 944941833 0
 lib/face/48x48x8/n/nemo.1 - 664 sys sys 1056982242 2364
 lib/face/48x48x8/n/nigel.1 - 644 sys sys 1056981488 1611
+lib/face/48x48x8/n/noah.1 - 664 sys sys 1081200582 7065
 lib/face/48x48x8/o - 20000000775 sys sys 944941833 0
 lib/face/48x48x8/p - 20000000775 sys sys 944941833 0
 lib/face/48x48x8/q - 20000000775 sys sys 944941833 0
@@ -2800,7 +2801,7 @@ lib/tftpd - 20000000775 sys sys 944944178 0
 lib/unicode - 664 sys sys 958440028 223312
 lib/unicode.notice - 664 sys sys 958504386 1398
 lib/units - 664 sys sys 1071415518 9997
-lib/vgadb - 664 sys sys 1080049879 27670
+lib/vgadb - 664 sys sys 1081200818 27920
 lib/volcanoes - 664 sys sys 944944024 119831
 lib/words - 664 sys sys 1014923442 247097
 lp - 20000000775 sys sys 958199268 0
@@ -2979,7 +2980,7 @@ rc/bin/B - 775 sys sys 945617206 645
 rc/bin/C - 775 sys sys 1045493437 788
 rc/bin/Kill - 775 sys sys 1018637942 115
 rc/bin/a: - 775 sys sys 1063856406 255
-rc/bin/ap - 775 sys sys 1080159225 665
+rc/bin/ap - 775 sys sys 1081200030 675
 rc/bin/ape - 20000000775 sys sys 954039414 0
 rc/bin/ape/ar89 - 775 sys sys 945617285 308
 rc/bin/ape/c89 - 775 sys sys 945617285 39
@@ -3029,12 +3030,15 @@ rc/bin/membername - 775 sys sys 945617207 89
 rc/bin/mousereset - 775 sys sys 1015089542 37
 rc/bin/nroff - 775 sys sys 945617208 27
 rc/bin/patch - 20000000775 sys sys 1067803227 0
+rc/bin/patch/applied - 775 sys sys 1081204295 110
 rc/bin/patch/apply - 775 sys sys 1067804403 1234
 rc/bin/patch/create - 775 sys sys 1079969485 1126
 rc/bin/patch/diff - 775 sys sys 1067804404 466
-rc/bin/patch/list - 775 sys sys 1067804541 321
+rc/bin/patch/list - 775 sys sys 1081204287 644
+rc/bin/patch/move - 775 sys sys 1081204288 547
 rc/bin/patch/note - 664 sys sys 1067804405 593
 rc/bin/patch/okay - 775 sys sys 1067803227 240
+rc/bin/patch/sorry - 775 sys sys 1081200166 107
 rc/bin/patch/undo - 775 sys sys 1067804405 549
 rc/bin/pc - 20000000775 sys sys 960857447 0
 rc/bin/pc/bootfloppy - 775 sys sys 964455816 439
@@ -3422,7 +3426,7 @@ sys/include/httpd.h - 664 sys sys 1079372798 5747
 sys/include/ip.h - 664 sys sys 1050702405 2908
 sys/include/keyboard.h - 664 sys sys 1079577798 815
 sys/include/libc.h - 664 sys sys 1072792615 19430
-sys/include/libsec.h - 664 sys sys 1068129557 8966
+sys/include/libsec.h - 664 sys sys 1081199854 9024
 sys/include/mach.h - 664 sys sys 1068478049 8194
 sys/include/memdraw.h - 664 sys sys 1039752978 5616
 sys/include/memlayer.h - 664 sys sys 1051031022 1851
@@ -4958,7 +4962,7 @@ sys/man/4/cfs - 664 sys sys 1015024813 1758
 sys/man/4/consolefs - 664 sys sys 1069179473 3920
 sys/man/4/dossrv - 664 sys sys 1015024813 4176
 sys/man/4/execnet - 664 sys sys 1019866708 1069
-sys/man/4/exportfs - 664 sys sys 1080922547 4454
+sys/man/4/exportfs - 664 sys sys 1081200463 4652
 sys/man/4/ext2srv - 664 sys sys 1055692986 2409
 sys/man/4/factotum - 664 sys sys 1053127875 14460
 sys/man/4/fossil - 664 sys sys 1073853397 9333
@@ -5103,6 +5107,7 @@ sys/man/8/stub - 664 sys sys 1044830500 943
 sys/man/8/swap - 664 sys sys 944959679 880
 sys/man/8/timesync - 664 sys sys 1022590210 1629
 sys/man/8/tlssrv - 664 sys sys 1037580152 2594
+sys/man/8/trampoline - 664 sys sys 1081200125 0
 sys/man/8/udpecho - 664 sys sys 954305553 303
 sys/man/8/update - 664 sys sys 961259288 2336
 sys/man/8/venti - 664 sys sys 1069101926 5422
@@ -6829,7 +6834,7 @@ sys/src/cmd/acme/mkfile - 664 sys sys 1058463682 543
 sys/src/cmd/acme/regx.c - 664 sys sys 1014926094 16057
 sys/src/cmd/acme/rows.c - 664 sys sys 1068140772 14637
 sys/src/cmd/acme/scrl.c - 664 sys sys 1014926095 3072
-sys/src/cmd/acme/text.c - 664 sys sys 1079115968 27284
+sys/src/cmd/acme/text.c - 664 sys sys 1081200110 27335
 sys/src/cmd/acme/time.c - 664 sys sys 1014926095 1783
 sys/src/cmd/acme/util.c - 664 sys sys 1079102916 7412
 sys/src/cmd/acme/wind.c - 664 sys sys 1073566950 11094
@@ -7117,9 +7122,9 @@ sys/src/cmd/aux/vga/ch9294.c - 664 sys sys 1014925007 2120
 sys/src/cmd/aux/vga/clgd542x.c - 664 sys sys 1014925007 6916
 sys/src/cmd/aux/vga/clgd546x.c - 664 sys sys 1014925007 7996
 sys/src/cmd/aux/vga/ct65540.c - 664 sys sys 1014925007 5355
-sys/src/cmd/aux/vga/cyber938x.c - 664 sys sys 1045505008 6440
+sys/src/cmd/aux/vga/cyber938x.c - 664 sys sys 1081200864 6502
 sys/src/cmd/aux/vga/data.c - 664 sys sys 1019498850 2200
-sys/src/cmd/aux/vga/db.c - 664 sys sys 1078840016 9331
+sys/src/cmd/aux/vga/db.c - 664 sys sys 1081201695 9430
 sys/src/cmd/aux/vga/error.c - 664 sys sys 1014925008 745
 sys/src/cmd/aux/vga/et4000.c - 664 sys sys 1014925008 6720
 sys/src/cmd/aux/vga/et4000hwgc.c - 664 sys sys 1014925008 552
@@ -7511,7 +7516,7 @@ sys/src/cmd/execnet/main.c - 664 sys sys 1019861330 657
 sys/src/cmd/execnet/mkfile - 664 sys sys 1032059543 208
 sys/src/cmd/execnet/note.c - 664 sys sys 1019855740 2315
 sys/src/cmd/exportfs - 20000000775 sys sys 988249971 0
-sys/src/cmd/exportfs/exportfs.c - 664 sys sys 1081082332 16169
+sys/src/cmd/exportfs/exportfs.c - 664 sys sys 1081200487 16198
 sys/src/cmd/exportfs/exportfs.h - 664 sys sys 1066823091 2800
 sys/src/cmd/exportfs/exportsrv.c - 664 sys sys 1081082332 11914
 sys/src/cmd/exportfs/mkfile - 664 sys sys 1066825703 194
@@ -9401,7 +9406,7 @@ sys/src/cmd/gzip/mkfile - 664 sys sys 984758036 125
 sys/src/cmd/gzip/unzip.c - 664 sys sys 1050689595 13603
 sys/src/cmd/gzip/zip.c - 664 sys sys 1033183074 7054
 sys/src/cmd/gzip/zip.h - 664 sys sys 954778719 1428
-sys/src/cmd/hget.c - 664 sys sys 1070286807 22715
+sys/src/cmd/hget.c - 664 sys sys 1081199967 24671
 sys/src/cmd/history.c - 664 sys sys 1073079763 6117
 sys/src/cmd/hoc - 20000000775 sys sys 954036932 0
 sys/src/cmd/hoc/code.c - 664 sys sys 944961000 10041
@@ -10243,9 +10248,9 @@ sys/src/cmd/replica/avl.c - 664 sys sys 1068497830 6242
 sys/src/cmd/replica/compactdb.c - 664 sys sys 1018323475 652
 sys/src/cmd/replica/db.c - 664 sys sys 1019340165 2989
 sys/src/cmd/replica/mkfile - 664 sys sys 1032060527 647
-sys/src/cmd/replica/proto.c - 664 sys sys 1019525024 8716
+sys/src/cmd/replica/proto.c - 664 sys sys 1081202238 8724
 sys/src/cmd/replica/revdump.c - 664 sys sys 1018321112 651
-sys/src/cmd/replica/revproto.c - 664 sys sys 1018321112 8922
+sys/src/cmd/replica/revproto.c - 664 sys sys 1081202241 8932
 sys/src/cmd/replica/updatedb.c - 664 sys sys 1068497831 3045
 sys/src/cmd/replica/util.c - 664 sys sys 1022274716 1997
 sys/src/cmd/resample.c - 664 sys sys 1039753039 6268
@@ -12233,7 +12238,7 @@ sys/src/libsec/port/md4.c - 664 sys sys 1015013579 4260
 sys/src/libsec/port/md4test.c - 664 sys sys 984710522 537
 sys/src/libsec/port/md5.c - 664 sys sys 985124885 3298
 sys/src/libsec/port/md5block.c - 664 sys sys 985124885 5015
-sys/src/libsec/port/md5pickle.c - 664 sys sys 988225292 657
+sys/src/libsec/port/md5pickle.c - 664 sys sys 1081199854 716
 sys/src/libsec/port/mkfile - 664 sys sys 1044931345 879
 sys/src/libsec/port/nfastrand.c - 664 sys sys 1063853595 354
 sys/src/libsec/port/primetest.c - 664 sys sys 984710523 2486

+ 20 - 0
dist/replica/plan9.log

@@ -14787,3 +14787,23 @@
 1081083623 1 c sys/src/cmd/exportfs/exportfs.c - 664 sys sys 1081082332 16169
 1081083623 2 c sys/src/cmd/exportfs/exportsrv.c - 664 sys sys 1081082332 11914
 1081083623 3 c sys/src/cmd/import.c - 664 sys sys 1081082324 6711
+1081200644 0 c lib/face/48x48x4/.dict - 664 sys sys 1081200610 2417
+1081200644 1 c lib/face/48x48x8/.dict - 664 sys sys 1081200562 2146
+1081200644 2 a lib/face/48x48x8/n/noah.1 - 664 sys sys 1081200582 7065
+1081200644 3 c rc/bin/ap - 775 sys sys 1081200030 675
+1081200644 4 a rc/bin/patch/sorry - 775 sys sys 1081200166 107
+1081200644 5 c sys/include/libsec.h - 664 sys sys 1081199854 9024
+1081200644 6 c sys/man/4/exportfs - 664 sys sys 1081200463 4652
+1081200644 7 a sys/man/8/trampoline - 664 sys sys 1081200125 0
+1081200644 8 c sys/src/cmd/acme/text.c - 664 sys sys 1081200110 27335
+1081200644 9 c sys/src/cmd/exportfs/exportfs.c - 664 sys sys 1081200487 16198
+1081200644 10 c sys/src/cmd/hget.c - 664 sys sys 1081199967 24671
+1081200644 11 c sys/src/libsec/port/md5pickle.c - 664 sys sys 1081199854 716
+1081202443 0 c lib/vgadb - 664 sys sys 1081200818 27920
+1081202443 1 c sys/src/cmd/aux/vga/cyber938x.c - 664 sys sys 1081200864 6502
+1081202443 2 c sys/src/cmd/aux/vga/db.c - 664 sys sys 1081201695 9430
+1081202443 3 c sys/src/cmd/replica/proto.c - 664 sys sys 1081202238 8724
+1081202443 4 c sys/src/cmd/replica/revproto.c - 664 sys sys 1081202241 8932
+1081204245 0 a rc/bin/patch/applied - 775 sys sys 1081204295 110
+1081204245 1 c rc/bin/patch/list - 775 sys sys 1081204287 644
+1081204245 2 a rc/bin/patch/move - 775 sys sys 1081204288 547

+ 1 - 0
lib/face/48x48x4/.dict

@@ -73,6 +73,7 @@ delbarton.org/unknown d/delbarton.1
 ebay.com.uk/unknown u/unknown.ebay.com
 ebay.com/unknown u/unknown.ebay.com
 ghs.com/unknown u/unknown.ghs.com
+gmail.com/robpike r/rob.1
 google.com/r r/rob.1
 google.com/sean s/seanq.1
 harvard.edu/rsc r/rsc.1

+ 1 - 0
lib/face/48x48x8/.dict

@@ -20,6 +20,7 @@ cn/unknown u/unknown.cn
 collyer.net/geoff g/geoff.2
 comcast.net/unknown c/comcast.1
 cr/unknown u/unknown.cr
+cwru.edu/noah.evans n/noah.1
 cz/unknown u/unknown.cz
 de/unknown u/unknown.de
 dk/unknown u/unknown.dk

BIN
lib/face/48x48x8/n/noah.1


+ 15 - 0
lib/vgadb

@@ -919,6 +919,14 @@ sm17GLsi=1024x768						# 70Hz, 57.2KHz
 	vrs=771 vre=777 vt=806
 	hsync=- vsync=-
 
+# Samsung SyncMaster 753DF
+sm753DF = 1024x768
+	defaultclock=94.5
+	shb=1072 ehb=1168 ht=1376
+	shs=1072
+	vrs=769 vre=772 vt=808
+	hsync=+ vsync=+
+
 #
 # Sony CPD-1304
 # Horizontal timing:
@@ -1123,6 +1131,13 @@ planar=1280x1024
 	shs=1392
 	vrs=1072 vre=1073 vt=1075
 
+#
+# Samsung 213T
+#
+213t=1600x1200
+	defaultclock=200
+	shb=1664 ehb=1864 ht=2136
+	vrs=1202 vre=1207 vt=1251
 
 #
 # QVGA		320x240		Quarter Video Graphics Array

+ 4 - 3
rc/bin/ap

@@ -24,15 +24,16 @@ if ( ~ $#* 0 )
 			s = "";
 			for (i = 1; i < NF; i++)
 				s = s " " $i;
-			printf("%-40s %s\n", $NF, s);
+			printf("ap %-40s # %s\n", $NF, s);
 		}'
 
 if not
 	hget $wire/^$1^.story |
 		htmlfmt |
 		sed '
-			1,/^By Associated Press$/d
 			s/\| Article licensing.*$//
 			/^Copyright ©/p
 			/^Copyright ©/,$d
-			'
+			1,/^Top Stories$/d
+			/^$/,/^$/d
+		'

+ 8 - 0
rc/bin/patch/applied

@@ -0,0 +1,8 @@
+#!/bin/rc
+
+if(~ $#* 0){
+	echo 'usage: patch/reject patch-name...' >[1=2]
+	exit usage
+}
+
+patch/move applied $*

+ 23 - 3
rc/bin/patch/list

@@ -5,19 +5,39 @@ if(! test -d /n/sources/patch){
 	9fs sources
 }
 
+pref=''
 cd /n/sources/patch
+if(~ $1 sorry applied){
+	pref=$1^'/'
+	shift
+}
 if(~ $#* 0)
-	*=(`{ls -t})
+	*=(`{if(~ $pref *?*) cd $pref; ls -t | grep -v '^(sorry|applied)$'})
+
+trunc=(sed 5q)
+if(~ $#* 1)
+	trunc=cat
+
 
+{
 for(i in $*){
-	ls -ld $i
+	i=$pref^$i
+	if(test -f $i/origls)
+		cat $i/origls | awk '{$NF="'$i'"; print}'
+	if not
+		ls -ld $i
 	if(patch/okay $i){
 		cat $i/files | awk '{print "	" $1}'
-		cat $i/readme | sed 's/^/	/;5q'
+		cat $i/readme | sed 's/^/	/' | $trunc
 		if(test -f $i/notes)
 			cat $i/notes
 	}
 	if not
 		echo '	'bad patch: $status >[2=1]
+	echo
 }
 
+} >/tmp/patchtmp.$pid
+
+cat /tmp/patchtmp.$pid
+rm -f /tmp/patchtmp.$pid

+ 25 - 0
rc/bin/patch/move

@@ -0,0 +1,25 @@
+#!/bin/rc
+
+if(~ $#* 0 1){
+	echo 'usage: patch/move dst patch-name...' >[1=2]
+	exit usage
+}
+
+if(! test -d /n/sources/patch){
+	rfork n
+	9fs sources
+}
+
+dst=$1
+shift
+for(i){
+	if(! test -d /n/sources/patch/$i)
+		echo 'no such patch' /n/sources/patch/$i >[1=2]
+	if not if(test -d /n/sources/patch/$dst/$i)
+		echo 'already have' /n/sources/patch/$dst/$i >[1=2]
+	if not
+		ls -ldp /n/sources/patch/$i >/n/sources/patch/$i/origls &&
+		mkdir /n/sources/patch/$dst/$i && 
+		dircp /n/sources/patch/$i /n/sources/patch/$dst/$i &&
+		rm -rf /n/sources/patch/$i
+}

+ 8 - 0
rc/bin/patch/sorry

@@ -0,0 +1,8 @@
+#!/bin/rc
+
+if(~ $#* 0){
+	echo 'usage: patch/sorry patch-name...' >[1=2]
+	exit usage
+}
+
+patch/move sorry $*

+ 2 - 0
sys/include/libsec.h

@@ -150,6 +150,8 @@ DigestState* md5(uchar*, ulong, uchar*, DigestState*);
 DigestState* sha1(uchar*, ulong, uchar*, DigestState*);
 DigestState* hmac_md5(uchar*, ulong, uchar*, ulong, uchar*, DigestState*);
 DigestState* hmac_sha1(uchar*, ulong, uchar*, ulong, uchar*, DigestState*);
+char* md5pickle(MD5state*);
+MD5state* md5unpickle(char*);
 char* sha1pickle(SHA1state*);
 SHA1state* sha1unpickle(char*);
 

+ 13 - 1
sys/man/4/exportfs

@@ -4,7 +4,7 @@ exportfs, srvfs \- network file server plumbing
 .SH SYNOPSIS
 .B exportfs
 [
-.B -adsR
+.B -adnsR
 ] [
 .B -f
 .I dbgfile
@@ -23,6 +23,9 @@ exportfs, srvfs \- network file server plumbing
 .B -e
 .I "'enc auth'"
 ] [
+.B -N
+.I nsfile
+] [
 .B -P
 .I patternfile
 ]
@@ -63,6 +66,15 @@ tree are executed on the remote server and the results returned.  This
 gives the appearance of exporting a name space from a remote machine
 into a local file tree.
 .PP
+.I Exportfs
+creates a new name space for each connection, using
+.B /lib/namespace
+by default (see
+.IR namespace (6)).
+The
+.B -n
+option gives an alternative name space file.
+.PP
 The
 .B -R
 option makes the served name space read only.

+ 0 - 0
sys/man/8/trampoline


+ 7 - 7
sys/src/cmd/acme/text.c

@@ -861,7 +861,7 @@ textselect(Text *t)
 {
 	uint q0, q1;
 	int b, x, y;
-	int state;
+	int state, op;
 
 	selecttext = t;
 	/*
@@ -917,12 +917,12 @@ textselect(Text *t)
 		clicktext = nil;
 	textsetselect(t, q0, q1);
 	flushimage(display, 1);
-	state = 0;	/* undo when possible; +1 for cut, -1 for paste */
+	state = op = 0;	/* undo when possible; +1 for cut, -1 for paste */
 	while(mouse->buttons){
 		mouse->msec = 0;
 		b = mouse->buttons;
 		if(b & 6){
-			if(state==0 && t->what==Body){
+			if(state==0 && op==0 && t->what==Body){
 				seq++;
 				filemark(t->w->body.file);
 			}
@@ -931,18 +931,18 @@ textselect(Text *t)
 					winundo(t->w, TRUE);
 					textsetselect(t, q0, t->q0);
 					state = 0;
-				}else if(state != 1){
+				}else if(state != 1 && op != -1){
 					cut(t, t, nil, TRUE, TRUE, nil, 0);
-					state = 1;
+					op = state = 1;
 				}
 			}else{
 				if(state==1 && t->what==Body){
 					winundo(t->w, TRUE);
 					textsetselect(t, q0, t->q1);
 					state = 0;
-				}else if(state != -1){
+				}else if(state != -1 && op != 1){
 					paste(t, t, nil, TRUE, FALSE, nil, 0);
-					state = -1;
+					op = state = -1;
 				}
 			}
 			textscrdraw(t);

+ 2 - 0
sys/src/cmd/aux/vga/cyber938x.c

@@ -207,7 +207,9 @@ init(Vga* vga, Ctlr* ctlr)
 				vga->graphics[0x30] &= ~0x81;
 		}
 		/*FALLTHROUGH*/
+	case 0x3:					/* Cyber9320 */
 	case 0x33:				/* Cyber9385 */
+	case 0x34:				/* Cyber9385 */
 	case 0x35:				/* Cyber9385 */
 	case 0x3A:				/* Cyber9385 */
 		vga->graphics[0x0F] |= 0x07;

+ 4 - 1
sys/src/cmd/aux/vga/db.c

@@ -228,7 +228,7 @@ dbmonitor(Ndb* db, Mode* mode, char* type, char* size)
 	Ndbs s;
 	Ndbtuple *t, *tuple;
 	char *p, attr[Namelen+1], val[Namelen+1], buf[2*Namelen+1];
-	int clock, x;
+	int clock, x, i;
 
 	/*
 	 * Clock rate hack.
@@ -262,6 +262,7 @@ dbmonitor(Ndb* db, Mode* mode, char* type, char* size)
 		return 0;
 	if(mode->y == 0 && (mode->y = strtol(p, &p, 0)) == 0)
 		return 0;
+	i = 0;
 buggery:
 	if((tuple = ndbsearch(db, &s, attr, val)) == 0)
 		return 0;
@@ -297,6 +298,8 @@ buggery:
 			strcpy(attr, t->attr);
 			strcpy(val, t->val);
 			ndbfree(tuple);
+			if(i++ > 5)
+				error("dbmonitor: implausible include depth at %s=%s\n", attr, val);
 			goto buggery;
 		}
 		else if(strcmp(t->attr, "include") == 0){

+ 8 - 5
sys/src/cmd/exportfs/exportfs.c

@@ -70,14 +70,15 @@ main(int argc, char **argv)
 	char buf[ERRMAX], ebuf[ERRMAX];
 	Fsrpc *r;
 	int n, fd;
-	char *dbfile, *srv, *file, *na;
+	char *dbfile, *srv, *file, *na, *nsfile;
 	AuthInfo *ai;
 	ulong initial;
 
 	dbfile = "/tmp/exportdb";
 	srv = nil;
 	srvfd = -1;
-	na = 0;
+	na = nil;
+	nsfile = nil;
 
 	ai = nil;
 	ARGBEGIN{
@@ -93,10 +94,8 @@ main(int argc, char **argv)
 			fatal("auth_proxy: %r");
 		if(nonone && strcmp(ai->cuid, "none") == 0)
 			fatal("exportfs by none disallowed");
-		if(auth_chuid(ai, nil) < 0)
+		if(auth_chuid(ai, nsfile) < 0)
 			fatal("auth_chuid: %r");
-		if(newns(ai->cuid, 0) < 0)
-			fatal("newns");
 		putenv("service", "exportfs");
 		break;
 
@@ -136,6 +135,10 @@ main(int argc, char **argv)
 		nonone = 0;
 		break;
 
+	case 'N':
+		nsfile = EARGF(usage());
+		break;
+
 	case 'r':
 		srv = EARGF(usage());
 		break;

+ 125 - 26
sys/src/cmd/hget.c

@@ -25,6 +25,16 @@ struct Range
 	long	end;
 };
 
+typedef struct Out Out;
+struct Out
+{
+	int fd;
+	int offset;				/* notional current offset in output */
+	int written;			/* number of bytes successfully transferred to output */
+	DigestState *curr;		/* digest state up to offset (if known) */
+	DigestState *hiwat;		/* digest state of all bytes written */
+};
+
 enum
 {
 	Http,
@@ -44,8 +54,9 @@ enum
 int debug;
 char *ofile;
 
-int	doftp(URL*, URL*, Range*, int, long);
-int	dohttp(URL*, URL*,  Range*, int, long);
+
+int	doftp(URL*, URL*, Range*, Out*, long);
+int	dohttp(URL*, URL*,  Range*, Out*, long);
 int	crackurl(URL*, char*);
 Range*	crackrange(char*);
 int	getheader(int, char*, int);
@@ -58,15 +69,17 @@ int	readline(int, char*, int);
 int	readibuf(int, char*, int);
 int	dfprint(int, char*, ...);
 void	unreadline(char*);
+int	output(Out*, void*, int);
+void	setoffset(Out*, int);
 
 int	verbose;
 char	*net;
-char	tcpdir[64];
+char	tcpdir[NETPATHLEN];
 int	headerprint;
 
 struct {
 	char	*name;
-	int	(*f)(URL*, URL*, Range*, int, long);
+	int	(*f)(URL*, URL*, Range*, Out*, long);
 } method[] = {
 	[Http]	{ "http",	dohttp },
 	[Https]	{ "https",	dohttp },
@@ -86,11 +99,12 @@ main(int argc, char **argv)
 {
 	URL u;
 	Range r;
-	int fd, errs, n;
+	int errs, n;
 	ulong mtime;
 	Dir *d;
 	char postbody[4096], *p, *e, *t, *hpx;
 	URL px; // Proxy
+	Out out;
 
 	ofile = nil;
 	p = postbody;
@@ -145,16 +159,21 @@ main(int argc, char **argv)
 	if(argc != 1)
 		usage();
 
-	fd = 1;
+	
+	out.fd = 1;
+	out.written = 0;
+	out.offset = 0;
+	out.curr = nil;
+	out.hiwat = nil;
 	if(ofile != nil){
 		d = dirstat(ofile);
 		if(d == nil){
-			fd = create(ofile, OWRITE, 0664);
-			if(fd < 0)
+			out.fd = create(ofile, OWRITE, 0664);
+			if(out.fd < 0)
 				sysfatal("creating %s: %r", ofile);
 		} else {
-			fd = open(ofile, OWRITE);
-			if(fd < 0)
+			out.fd = open(ofile, OWRITE);
+			if(out.fd < 0)
 				sysfatal("can't open %s: %r", ofile);
 			r.start = d->length;
 			mtime = d->mtime;
@@ -170,10 +189,10 @@ main(int argc, char **argv)
 		sysfatal("%r");
 
 	for(;;){
+		setoffset(&out, 0);
 		/* transfer data */
 		werrstr("");
-		seek(fd, 0, 0);
-		n = (*method[u.method].f)(&u, &px, &r, fd, mtime);
+		n = (*method[u.method].f)(&u, &px, &r, &out, mtime);
 
 		switch(n){
 		case Eof:
@@ -294,7 +313,7 @@ catch(void*, char*)
 }
 
 int
-dohttp(URL *u, URL *px, Range *r, int out, long mtime)
+dohttp(URL *u, URL *px, Range *r, Out *out, long mtime)
 {
 	int fd, cfd;
 	int redirect, loop;
@@ -414,7 +433,7 @@ dohttp(URL *u, URL *px, Range *r, int out, long mtime)
 			sysfatal("No Content");
 
 		case 206:	/* Partial Content */
-			seek(out, r->start, 0);
+			setoffset(out, r->start);
 			break;
 
 		case 301:	/* Moved Permanently */
@@ -478,7 +497,7 @@ dohttp(URL *u, URL *px, Range *r, int out, long mtime)
 
 	/* transfer whatever you get */
 	if(ofile != nil && u->mtime != 0){
-		note.fd = out;
+		note.fd = out->fd;
 		note.mtime = u->mtime;
 		notify(catch);
 	}
@@ -489,7 +508,7 @@ dohttp(URL *u, URL *px, Range *r, int out, long mtime)
 		n = readibuf(fd, buf, sizeof(buf));
 		if(n <= 0)
 			break;
-		if(write(out, buf, n) != n)
+		if(output(out, buf, n) != n)
 			break;
 		tot += n;
 		if(verbose && vtime != time(0)) {
@@ -506,7 +525,7 @@ dohttp(URL *u, URL *px, Range *r, int out, long mtime)
 		rerrstr(err, sizeof err);
 		nulldir(&d);
 		d.mtime = u->mtime;
-		if(dirfwstat(out, &d) < 0)
+		if(dirfwstat(out->fd, &d) < 0)
 			fprint(2, "couldn't set mtime: %r\n");
 		errstr(err, sizeof err);
 	}
@@ -765,13 +784,13 @@ int logon(int);
 int xfertype(int, char*);
 int passive(int, URL*);
 int active(int, URL*);
-int ftpxfer(int, int, Range*);
+int ftpxfer(int, Out*, Range*);
 int terminateftp(int, int);
 int getaddrport(char*, uchar*, uchar*);
-int ftprestart(int, int, URL*, Range*, long);
+int ftprestart(int, Out*, URL*, Range*, long);
 
 int
-doftp(URL *u, URL *px, Range *r, int out, long mtime)
+doftp(URL *u, URL *px, Range *r, Out *out, long mtime)
 {
 	int pid, ctl, data, rv;
 	Waitmsg *w;
@@ -937,7 +956,7 @@ getdec(char *p, int n)
 }
 
 int
-ftprestart(int ctl, int out, URL *u, Range *r, long mtime)
+ftprestart(int ctl, Out *out, URL *u, Range *r, long mtime)
 {
 	Tm tm;
 	char msg[1024];
@@ -978,9 +997,9 @@ ftprestart(int ctl, int out, URL *u, Range *r, long mtime)
 	/* seek to restart point */
 	if(r->start > 0){
 		ftpcmd(ctl, "REST %lud", r->start);
-		if(ftprcode(ctl, msg, sizeof(msg)) == Incomplete)
-			seek(out, r->start, 0);
-		else
+		if(ftprcode(ctl, msg, sizeof(msg)) == Incomplete){
+			setoffset(out, r->start);
+		}else
 			r->start = 0;
 	}
 
@@ -1134,7 +1153,7 @@ active(int ctl, URL *u)
 }
 
 int
-ftpxfer(int in, int out, Range *r)
+ftpxfer(int in, Out *out, Range *r)
 {
 	char buf[1024];
 	long vtime;
@@ -1147,7 +1166,7 @@ ftpxfer(int in, int out, Range *r)
 			break;
 		if(i < 0)
 			return Error;
-		if(write(out, buf, i) != i)
+		if(output(out, buf, i) != i)
 			return Error;
 		r->start += i;
 		if(verbose && vtime != time(0)) {
@@ -1322,3 +1341,83 @@ getaddrport(char *dir, uchar *ipaddr, uchar *port)
 	port[1] = i;
 	return 0;
 }
+
+void
+md5free(DigestState *state)
+{
+	uchar x[MD5dlen];
+	md5(nil, 0, x, state);
+}
+
+DigestState*
+md5dup(DigestState *state)
+{
+	char *p;
+
+	p = md5pickle(state);
+	if(p == nil)
+		sysfatal("md5pickle: %r");
+	state = md5unpickle(p);
+	if(state == nil)
+		sysfatal("md5unpickle: %r");
+	free(p);
+	return state;
+}
+
+void
+setoffset(Out *out, int offset)
+{
+	md5free(out->curr);
+	if(offset == 0)
+		out->curr = md5(nil, 0, nil, nil);
+	else
+		out->curr = nil;
+	out->offset = offset;
+}
+
+/*
+ * write some output, discarding it (but keeping track)
+ * if we've already written it. if we've gone backwards,
+ * verify that everything previously written matches
+ * that which would have been written from the current
+ * output.
+ */
+int
+output(Out *out, char *buf, int nb)
+{
+	int n, d;
+	uchar m0[MD5dlen], m1[MD5dlen];
+
+	n = nb;
+	d = out->written - out->offset;
+	assert(d >= 0);
+	if(d > 0){
+		if(n < d){
+			if(out->curr != nil)
+				md5((uchar*)buf, n, nil, out->curr);
+			out->offset += n;
+			return n;
+		}
+		if(out->curr != nil){
+			md5((uchar*)buf, d, m0, out->curr);
+			out->curr = nil;
+			md5(nil, 0, m1, md5dup(out->hiwat));
+			if(memcmp(m0, m1, MD5dlen) != 0){
+				fprint(2, "integrity check failure at offset %d\n", out->written);
+				return -1;
+			}
+		}
+		buf += d;
+		n -= d;
+		out->offset += d;
+	}
+	if(n > 0){
+		out->hiwat = md5((uchar*)buf, n, nil, out->hiwat);
+		n = write(out->fd, buf, n);
+		if(n > 0){
+			out->offset += n;
+			out->written += n;
+		}
+	}
+	return n + d;
+}

+ 2 - 2
sys/src/cmd/replica/proto.c

@@ -380,13 +380,13 @@ loop:
 		return nil;
 
 	if(!*f->uid)
-		strcpy(f->uid, "-");
+		f->uid = "-";	/* LEAK */
 	p = getname(mkaux, p, &f->gid);	/* LEAK */
 	if(p == nil)
 		return nil;
 
 	if(!*f->gid)
-		strcpy(f->gid, "-");
+		f->gid = "-":	/* LEAK */
 	f->old = getpath(mkaux, p);
 	if(f->old && strcmp(f->old, "-") == 0){
 		free(f->old);

+ 2 - 2
sys/src/cmd/replica/revproto.c

@@ -384,13 +384,13 @@ loop:
 		return nil;
 
 	if(!*f->uid)
-		strcpy(f->uid, "-");
+		f->uid = "-";		/* LEAK */
 	p = getname(mkaux, p, &f->gid);	/* LEAK */
 	if(p == nil)
 		return nil;
 
 	if(!*f->gid)
-		strcpy(f->gid, "-");
+		f->gid = "-";		/* LEAK */
 	f->old = getpath(mkaux, p);
 	if(f->old && strcmp(f->old, "-") == 0){
 		free(f->old);

+ 4 - 2
sys/src/libsec/port/md5pickle.c

@@ -7,11 +7,12 @@ md5pickle(MD5state *s)
 	char *p;
 	int m, n;
 
-	m = 4*9+4*((s->blen+3)/3);
+	m = 17+4*9+4*((s->blen+3)/3 + 1);
 	p = malloc(m);
 	if(p == nil)
 		return p;
-	n = sprint(p, "%8.8ux %8.8ux %8.8ux %8.8ux ",
+	n = sprint(p, "%16.16ullx %8.8ux %8.8ux %8.8ux %8.8ux ",
+		s->len,
 		s->state[0], s->state[1], s->state[2],
 		s->state[3]);
 	enc64(p+n, m-n, s->buf, s->blen);
@@ -26,6 +27,7 @@ md5unpickle(char *p)
 	s = malloc(sizeof(*s));
 	if(s == nil)
 		return nil;
+	s->len = strtoull(p, &p, 16);
 	s->state[0] = strtoul(p, &p, 16);
 	s->state[1] = strtoul(p, &p, 16);
 	s->state[2] = strtoul(p, &p, 16);