Browse Source

Import Geoff Collyer's tree

Signed-off-by: Dan Cross <cross@gajendra.net>
Dan Cross 2 years ago
parent
commit
c813762597
100 changed files with 3021 additions and 209 deletions
  1. 0 0
      386/include/ape/_apetypes.h
  2. 1 1
      386/include/ape/stdarg.h
  3. 1 0
      386/include/u.h
  4. 4 0
      386/include/ureg.h
  5. 1 1
      NOTICE
  6. 3 0
      amd64/include/ape/_apetypes.h
  7. 4 0
      amd64/include/ape/math.h
  8. 1 1
      amd64/include/ape/stdarg.h
  9. 7 1
      amd64/include/u.h
  10. 5 2
      amd64/include/ureg.h
  11. 0 0
      arm/include/ape/_apetypes.h
  12. 1 1
      arm/include/ape/float.h
  13. 1 0
      arm/include/u.h
  14. 0 0
      mips/include/ape/_apetypes.h
  15. 1 0
      mips/include/u.h
  16. 11 0
      mips2/include/stdarg.h
  17. 65 0
      mips2/include/u.h
  18. 53 0
      mips2/include/ureg.h
  19. 0 0
      power/include/ape/_apetypes.h
  20. 1 0
      power/include/u.h
  21. 3 0
      power64/include/ape/_apetypes.h
  22. 1 0
      power64/include/u.h
  23. 1 1
      rc/bin/0l
  24. 54 0
      rc/bin/411
  25. 127 36
      rc/bin/9fs
  26. 255 0
      rc/bin/9fs.edith
  27. 314 0
      rc/bin/9fs.new
  28. 304 0
      rc/bin/9fs.pie
  29. 20 5
      rc/bin/C
  30. 6 0
      rc/bin/abaco
  31. 3 1
      rc/bin/addpsfonts
  32. 29 0
      rc/bin/addroutes
  33. 25 0
      rc/bin/addroutes.60f
  34. 1 1
      rc/bin/ape/c89
  35. 2 24
      rc/bin/ape/grep
  36. 2 9
      rc/bin/ape/ls
  37. 1 7
      rc/bin/ape/psh
  38. 10 0
      rc/bin/arp
  39. 11 0
      rc/bin/audio
  40. 16 0
      rc/bin/await
  41. 3 0
      rc/bin/bdr
  42. 17 0
      rc/bin/bootme
  43. 7 0
      rc/bin/chop
  44. 72 0
      rc/bin/classical
  45. 29 0
      rc/bin/column
  46. 35 0
      rc/bin/cookiewarning
  47. 3 0
      rc/bin/cparena
  48. 3 0
      rc/bin/cpuboo
  49. 69 48
      rc/bin/cpurc
  50. 51 8
      rc/bin/cpurc.local
  51. 1 1
      rc/bin/dbcalc
  52. 7 2
      rc/bin/diffy
  53. 2 0
      rc/bin/dircp
  54. 8 0
      rc/bin/dircpmk
  55. 22 15
      rc/bin/diskparts
  56. 4 3
      rc/bin/dontkill
  57. 27 0
      rc/bin/dumpvacroots
  58. 14 0
      rc/bin/dumpvacroots.old
  59. 4 0
      rc/bin/dup
  60. 10 0
      rc/bin/dvips
  61. 35 0
      rc/bin/editfactotumkeys
  62. 210 0
      rc/bin/fc
  63. 69 0
      rc/bin/findviaduct
  64. 12 14
      rc/bin/fshalt
  65. 26 0
      rc/bin/g
  66. 18 0
      rc/bin/health
  67. 24 0
      rc/bin/importsrv
  68. 15 0
      rc/bin/include
  69. 79 0
      rc/bin/ipconf/bsr
  70. 86 0
      rc/bin/ipconf/tmobile
  71. 72 0
      rc/bin/ipconf/verizon
  72. 42 0
      rc/bin/ipon
  73. 6 4
      rc/bin/ipv6on
  74. 94 0
      rc/bin/ipv6on.v4v6
  75. 32 19
      rc/bin/juke
  76. 19 0
      rc/bin/kern
  77. 2 0
      rc/bin/kickventiindex
  78. 5 0
      rc/bin/killnetalt
  79. 8 0
      rc/bin/killtcpport
  80. 16 0
      rc/bin/kmesg.boot
  81. 3 0
      rc/bin/lastdumpvac
  82. 10 0
      rc/bin/latex
  83. 11 0
      rc/bin/loadcfgpxe
  84. 2 1
      rc/bin/lookman
  85. 2 0
      rc/bin/lunzip
  86. 31 0
      rc/bin/mailcmd
  87. 4 2
      rc/bin/man
  88. 10 0
      rc/bin/mf
  89. 7 0
      rc/bin/minboot
  90. 59 0
      rc/bin/mkdep
  91. 41 0
      rc/bin/mkdist
  92. 24 0
      rc/bin/mkfossilconf
  93. 1 1
      rc/bin/mkusbboot
  94. 37 0
      rc/bin/moowarning
  95. 52 0
      rc/bin/mountlabs
  96. 11 0
      rc/bin/mountlabsdump
  97. 42 0
      rc/bin/movehome
  98. 49 0
      rc/bin/movemail
  99. 7 0
      rc/bin/mp
  100. 15 0
      rc/bin/newdisk

+ 0 - 0
sys/lib/dist/cdstub/bootdisk.img → 386/include/ape/_apetypes.h


+ 1 - 1
386/include/ape/stdarg.h

@@ -5,7 +5,7 @@ typedef char *va_list;
 
 #define va_start(list, start) list = (sizeof(start)<4 ? (char *)((int *)&(start)+1) : \
 (char *)(&(start)+1))
-#define va_end(list)
+#define va_end(list) USED(list)
 #define va_arg(list, mode)\
 	((sizeof(mode) == 1)?\
 		((list += 4), (mode*)list)[-4]:\

+ 1 - 0
386/include/u.h

@@ -6,6 +6,7 @@ typedef unsigned int	uint;
 typedef   signed char	schar;
 typedef	long long	vlong;
 typedef	unsigned long long uvlong;
+typedef long		intptr;
 typedef unsigned long	uintptr;
 typedef unsigned long	usize;
 typedef	uint		Rune;

+ 4 - 0
386/include/ureg.h

@@ -1,5 +1,6 @@
 struct Ureg
 {
+	/* order is that of PUSHAL instruction ... */
 	ulong	di;		/* general registers */
 	ulong	si;		/* ... */
 	ulong	bp;		/* ... */
@@ -8,15 +9,18 @@ struct Ureg
 	ulong	dx;		/* ... */
 	ulong	cx;		/* ... */
 	ulong	ax;		/* ... */
+	/* ... to here */
 	ulong	gs;		/* data segments */
 	ulong	fs;		/* ... */
 	ulong	es;		/* ... */
 	ulong	ds;		/* ... */
 	ulong	trap;		/* trap type */
+	/* below are pushed by trap/intr mechanism */
 	ulong	ecode;		/* error code (or zero) */
 	ulong	pc;		/* pc */
 	ulong	cs;		/* old context */
 	ulong	flags;		/* old flags */
+	/* below are pushed only on trap/intr to more-privileged code */
 	union {
 		ulong	usp;
 		ulong	sp;

+ 1 - 1
NOTICE

@@ -7,5 +7,5 @@ a unit of Nokia Corporation.
 This work originally included the notice below.
 
 
-Copyright © 2002 Lucent Technologies Inc.
+Copyright © 2003 Lucent Technologies Inc.
 All Rights Reserved

+ 3 - 0
amd64/include/ape/_apetypes.h

@@ -0,0 +1,3 @@
+#ifndef _BITS64
+#define _BITS64
+#endif

+ 4 - 0
amd64/include/ape/math.h

@@ -15,6 +15,7 @@ extern double asin(double);
 extern double atan(double);
 extern double atan2(double, double);
 extern double cos(double);
+extern double hypot(double, double);
 extern double sin(double);
 extern double tan(double);
 extern double cosh(double);
@@ -71,4 +72,7 @@ extern double yn(int, double);
 }
 #endif
 
+#define isnan(x) isNaN(x)
+#define isinf(x) isInf(x, 0)
+
 #endif /* __MATH */

+ 1 - 1
amd64/include/ape/stdarg.h

@@ -5,7 +5,7 @@ typedef char *va_list;
 
 #define va_start(list, start) list = (sizeof(start)<8 ? (char *)((long long *)&(start)+1) : \
 (char *)(&(start)+1))
-#define va_end(list)
+#define va_end(list) USED(list)
 #define va_arg(list, mode)\
 	((sizeof(mode) == 1)?\
 		((mode*)(list += 8))[-8]:\

+ 7 - 1
amd64/include/u.h

@@ -6,8 +6,9 @@ typedef unsigned int	uint;
 typedef   signed char	schar;
 typedef	long long	vlong;
 typedef	unsigned long long uvlong;
+typedef long long	intptr;
 typedef unsigned long long uintptr;
-typedef unsigned long	usize;
+typedef unsigned long usize;  /* changing width changes system call interface */
 typedef	uint		Rune;
 typedef union FPdbleword FPdbleword;
 typedef uintptr		jmp_buf[2];
@@ -15,6 +16,8 @@ typedef uintptr		jmp_buf[2];
 #define	JMPBUFPC	1
 #define	JMPBUFDPC	0
 typedef unsigned int	mpdigit;	/* for /sys/include/mp.h */
+
+/* rarely needed and overused */
 typedef unsigned char	u8int;
 typedef unsigned short	u16int;
 typedef unsigned int	u32int;
@@ -55,6 +58,7 @@ union FPdbleword
 	};
 };
 
+/* stdarg - little-endian 64-bit */
 typedef	char*	va_list;
 #define va_start(list, start) list =\
 	(sizeof(start) < 8?\
@@ -70,3 +74,5 @@ typedef	char*	va_list;
 	(sizeof(mode) == 4)?\
 		((list += 8), (mode*)list)[-2]:\
 		((list += sizeof(mode)), (mode*)list)[-1])
+
+#define _BITS64		/* for ape */

+ 5 - 2
amd64/include/ureg.h

@@ -21,8 +21,11 @@ struct Ureg {
 	u16int	gs;
 
 	u64int	type;
-	u64int	error;				/* error code (or zero) */
-	u64int	ip;				/* pc */
+	u64int	err;				/* error code (or zero) */
+	union{
+		u64int	ip;			/* pc, in intel jargon */
+		u64int	pc;			/* port code name */
+	};
 	u64int	cs;				/* old context */
 	u64int	flags;				/* old flags */
 	u64int	sp;				/* sp */

+ 0 - 0
sys/lib/dist/pc/emptyfile → arm/include/ape/_apetypes.h


+ 1 - 1
arm/include/ape/float.h

@@ -46,7 +46,7 @@ union FPdbleword
 
 #ifdef _RESEARCH_SOURCE
 /* define stuff needed for floating conversion */
-#define IEEE_8087	1
+#define IEEE_MC68k	1
 #define Sudden_Underflow 1
 #endif
 #ifdef _PLAN9_SOURCE

+ 1 - 0
arm/include/u.h

@@ -7,6 +7,7 @@ typedef	unsigned int	uint;
 typedef	signed char	schar;
 typedef	long long	vlong;
 typedef	unsigned long long uvlong;
+typedef long		intptr;
 typedef unsigned long	uintptr;
 typedef unsigned long	usize;
 typedef	uint		Rune;

+ 0 - 0
sys/lib/subscribers → mips/include/ape/_apetypes.h


+ 1 - 0
mips/include/u.h

@@ -6,6 +6,7 @@ typedef	unsigned int	uint;
 typedef	signed char	schar;
 typedef	long long	vlong;
 typedef	unsigned long long uvlong;
+typedef long		intptr;
 typedef unsigned long	uintptr;
 typedef unsigned long	usize;
 typedef	uint		Rune;

+ 11 - 0
mips2/include/stdarg.h

@@ -0,0 +1,11 @@
+typedef	char*	va_list;
+#define va_start(list, start) list = (char*)&start + 4
+#define va_end(list)
+#define va_arg(list, mode)\
+	(sizeof(mode)==1?\
+		((mode*)(list += 4))[-4]:\
+	sizeof(mode)==2?\
+		((mode*)(list += 4))[-2]:\
+	sizeof(mode)>4?\
+		((mode*)(list = (char*)((long)(list + 7) & ~7) + sizeof(mode)))[-1]:\
+		((mode*)(list += 4))[-1])

+ 65 - 0
mips2/include/u.h

@@ -0,0 +1,65 @@
+#define nil		((void*)0)
+typedef	unsigned short	ushort;
+typedef	unsigned char	uchar;
+typedef	unsigned long	ulong;
+typedef	unsigned int	uint;
+typedef	signed char	schar;
+typedef	long long	vlong;
+typedef	unsigned long long uvlong;
+typedef long		intptr;
+typedef unsigned long	uintptr;
+typedef unsigned long	usize;
+typedef	uint		Rune;
+typedef 	union FPdbleword FPdbleword;
+typedef uintptr	jmp_buf[2];
+#define	JMPBUFSP	0
+#define	JMPBUFPC	1
+#define	JMPBUFDPC	0
+typedef unsigned int	mpdigit;	/* for /sys/include/mp.h */
+typedef unsigned char u8int;
+typedef unsigned short u16int;
+typedef unsigned int	u32int;
+typedef unsigned long long u64int;
+
+/* FCR */
+#define	FPINEX	(1<<7)
+#define	FPUNFL	(1<<8)
+#define	FPOVFL	(1<<9)
+#define	FPZDIV	(1<<10)
+#define	FPINVAL	(1<<11)
+#define	FPRNR	(0<<0)
+#define	FPRZ	(1<<0)
+#define	FPRPINF	(2<<0)
+#define	FPRNINF	(3<<0)
+#define	FPRMASK	(3<<0)
+#define	FPPEXT	0
+#define	FPPSGL	0
+#define	FPPDBL	0
+#define	FPPMASK	0
+/* FSR */
+#define	FPAINEX	(1<<2)
+#define	FPAOVFL	(1<<4)
+#define	FPAUNFL	(1<<3)
+#define	FPAZDIV	(1<<5)
+#define	FPAINVAL	(1<<6)
+union FPdbleword
+{
+	double	x;
+	struct {	/* big endian */
+		ulong hi;
+		ulong lo;
+	};
+};
+
+/* stdarg */
+typedef	char*	va_list;
+#define va_start(list, start) (list = (char*)&start+4)
+#define va_end(list) USED(list)
+#define va_arg(list, mode)\
+	(sizeof(mode)==1?\
+		((mode*)(list += 4))[-4]:\
+	sizeof(mode)==2?\
+		((mode*)(list += 4))[-2]:\
+	sizeof(mode)<=4?\
+		((mode*)(list += 4))[-1]:\
+		((mode*)(list = (char*)((long)(list+7) & ~7) + sizeof(mode)))[-1])

+ 53 - 0
mips2/include/ureg.h

@@ -0,0 +1,53 @@
+struct Ureg
+{
+	ulong	status;
+	long	pc;
+	union
+	{
+		struct
+		{
+			long	sp;	/* r29 */
+			ulong	cause;
+		};
+		struct
+		{
+			long	usp;	/* r29 */
+			ulong	ucause;
+		};
+	};
+	ulong	badvaddr;
+	ulong	tlbvirt;
+
+	long	hhi;	long	hi;
+	long	hlo;	long	lo;
+	long	hr31;	long	r31;
+	long	hr30;	long	r30;
+	long	hr28;	long	r28;
+	long	hr27;	long	r27;
+	long	hr26;	long	r26;
+	long	hr25;	long	r25;
+	long	hr24;	long	r24;
+	long	hr23;	long	r23;
+	long	hr22;	long	r22;
+	long	hr21;	long	r21;
+	long	hr20;	long	r20;
+	long	hr19;	long	r19;
+	long	hr18;	long	r18;
+	long	hr17;	long	r17;
+	long	hr16;	long	r16;
+	long	hr15;	long	r15;
+	long	hr14;	long	r14;
+	long	hr13;	long	r13;
+	long	hr12;	long	r12;
+	long	hr11;	long	r11;
+	long	hr10;	long	r10;
+	long	hr9;	long	r9;
+	long	hr8;	long	r8;
+	long	hr7;	long	r7;
+	long	hr6;	long	r6;
+	long	hr5;	long	r5;
+	long	hr4;	long	r4;
+	long	hr3;	long	r3;
+	long	hr2;	long	r2;
+	long	hr1;	long	r1;
+};

+ 0 - 0
sys/lib/sysconfig/auth/boundary/keys.who → power/include/ape/_apetypes.h


+ 1 - 0
power/include/u.h

@@ -6,6 +6,7 @@ typedef	unsigned int	uint;
 typedef	  signed char	schar;
 typedef	long long	vlong;
 typedef	unsigned long long uvlong;
+typedef long		intptr;
 typedef unsigned long	uintptr;
 typedef unsigned long	usize;
 typedef	uint		Rune;

+ 3 - 0
power64/include/ape/_apetypes.h

@@ -0,0 +1,3 @@
+#ifndef _BITS64
+#define _BITS64
+#endif

+ 1 - 0
power64/include/u.h

@@ -6,6 +6,7 @@ typedef	unsigned int	uint;
 typedef	signed char	schar;
 typedef	long long	vlong;
 typedef	unsigned long long uvlong;
+typedef long long	intptr;
 typedef unsigned long long uintptr;
 typedef unsigned long	usize;
 typedef	uint		Rune;

+ 1 - 1
rc/bin/0l

@@ -1,2 +1,2 @@
 #!/bin/rc
-exec vl -m $*
+exec vl -L $*

+ 54 - 0
rc/bin/411

@@ -0,0 +1,54 @@
+#!/bin/rc
+p='thompson k,'
+f=/lib/411/d?
+
+switch($#*){
+case 1
+	switch($1){
+	case ?[0-9][0-9][0-9][0-9][0-9][0-9][0-9]
+		f=/lib/411/i?
+		p=`{echo $1|sed 's/.(...)(....)/\1-\2/'}
+
+	case ?[0-9][0-9][0-9]-[0-9][0-9][0-9][0-9]
+		f=/lib/411/i?
+		p=`{echo $1|sed 's/.(...)-(....)/\1-\2/'}
+
+	case [0-9][0-9][0-9][0-9][0-9][0-9][0-9]
+		f=/lib/411/i?
+		p=`{echo $1|sed 's/(...)(....)/\1-\2-908/'}
+
+	case [0-9][0-9][0-9]-[0-9][0-9][0-9][0-9]
+		f=/lib/411/i?
+		p=`{echo $1|sed 's/(...)-(....)/\1-\2-908/'}
+
+	case [0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]
+		f=/lib/411/i?
+		p=`{echo $1|sed 's/(...)(...)(....)/\2-\3-\1/'}
+
+	case [0-9][0-9][0-9]-[0-9][0-9][0-9]-[0-9][0-9][0-9][0-9]
+		f=/lib/411/i?
+		p=`{echo $1|sed 's/(...)-(...)-(....)/\2-\3-\1/'}
+
+	case *
+		f=/lib/411/d?
+		p=$1
+	}
+
+case 2
+	f=/lib/411/d?
+	p=$2 ^ ' ' ^ $1
+
+case 3
+	f=/lib/411/d?
+	p=$3 ^ ' ' ^ $1 ^ ' ' ^ $2
+
+case *
+	echo usage: 411 908-555-1212
+	echo '	  ' 411 '''finucane j'''
+	exit
+}
+
+{
+	for(i in $f)
+		look $p $i | sed 's/([0-9][0-9][0-9]-[0-9][0-9][0-9][0-9])-([0-9][0-9][0-9])/\2-\1/'
+} | sort

+ 127 - 36
rc/bin/9fs

@@ -2,54 +2,145 @@
 # 9fs filesystem [mountpoint] - srv & mount filesystem, usually from plan 9
 
 rfork e
-switch($1){
-case ''
+arch=/lib/vac/arch		# archive mount-point tree
+
+fn usage {
 	echo usage: 9fs service '[mountpoint]' >[1=2]
 	exit usage
+}
+
+switch($1){
+case '' -*
+	usage
+
+# main fs
+case dump
+	9fs boot && mount -cC /srv/boot /n/dump main/archive
+case snap
+	9fs boot && mount -C /srv/boot /n/snap main/snapshot
+
+case fs fsmain
+	srv -q fs && mount -cC /srv/fs /n/$1 main/active
+case fsdump
+	srv -q fs && mount -C /srv/fs /n/$1 main/archive
+case fssnap
+	srv -q fs && mount -C /srv/fs /n/$1 main/snapshot
+case fsstand
+	srv -q -cC net!fs!10564 $1 && mount -cC /srv/$1 /n/$1 main/active
+case stand
+	9fs fsstand
+	bind /n/fsstand /n/stand
+case fsstandsnap
+	srv -q -cC net!fs!10564 $1 && mount -C /srv/$1 /n/$1 main/snapshot
+case fsother other
+	srv -q -cC net!fs!20564 $1 && mount -cC /srv/$1 /n/$1 main/active
+case fsothersnap
+	srv -q -cC net!fs!20564 $1 && mount -C /srv/$1 /n/$1 main/snapshot
+case extother newother
+	import -cC fs /n/$1
+
+case alldumps
+	9fs dump
+	mountlabsdump
+	bind /n/dump /n/$1
+	bind -a /n/labsdump /n/$1
+# the labs
+case labsdump		# the complete and utter history of Plan 9 since 1990
+	mountlabsdump
+case labs archive bootes bootesdump fornax fornaxdump emelie emeliedump \
+	choline cholinedump pie piedump
+	mountlabs
+case audio
+	bind -a /sys/lib/music /lib/audio/maps
+
 case kfs
 	if(! test -f /srv/kfs)
 		disk/kfs
-	mount -c /srv/kfs /n/kfs
-case dump
-	mount /srv/boot /n/dump dump >[2]/dev/null ||
-		mount /srv/boot /n/dump main/archive ||
-		mount /srv/boot /n/dump dump	# again to print error
-case snap
-	mount /srv/boot /n/snap main/snapshot
-case other
-	mount -C /srv/boot /n/other other
-case juke					# ye olde file server
-	srv -q il!jukefs && mount /srv/il!jukefs /n/juke
-case sources
-	srv -nq tcp!9p.io sources /n/sources
+	mount -cC /srv/kfs /n/kfs
+
+#
+# the outside world
+#
+#cs=cs.bell-labs.com
+
+case wiki
+	srv -q 'tcp!p9f.org!wiki' wiki
+	mount /srv/wiki /mnt/wiki
+
+case sources 9p.io
+#	9fs 9p.io &&
+	9fs 148.251.6.120 && bind /n/148.251.6.120 /n/9p.io &&	# temp hack
+		bind /n/9p.io /n/sources
+case bl-sources
+#	srv net!sources.$cs!9fs sources &&
+#		mount -C -k 'user='^$user /srv/sources /n/sources
+#	if (! ~ $status '') {
+#		rm -f /srv/sources
+#		srv net!sources.$cs!9fs sources &&
+#			mount -C -k 'user='^$user /srv/sources /n/sources
+#	}
+#	# /n/sources is too much typing and /n/sources/plan9 is worse
+#	bind /n/sources /n/src
+#	if (test -e /n/src/plan9)
+#		bind /n/src/plan9 /n/p9
+	echo sources is down forever. >[1=2]
+	exit 'sources down'
 case sourcesdump
-	9fs sources
-	mount -n /srv/sources /n/sourcesdump main/archive
+#	9fs sources && mount -C /srv/sources /n/$1 main/archive
+	echo sources is down forever. >[1=2]
+	exit 'sources down'
 case sourcessnap
-	9fs sources
-	mount -n /srv/sources /n/sourcessnap main/snapshot
+#	9fs sources && mount -C /srv/sources /n/$1 main/snapshot
+	echo sources is down forever. >[1=2]
+	exit 'sources down'
+
 # arbitrary venti archives
 case vac:*
-	vacfs <{echo $1}
-case *.vac
-	if (test -e $1)
-		score=$1
-	if not if (! ~ $1 /* && test -e $home/lib/vac/$1)
-		score=$home/lib/vac/$1
-	if not if (! ~ $1 /* && test -e /lib/vac/$1)
-		score=/lib/vac/$1
-	if not {
-		echo $0: $1: no such score file >[1=2]
-		exit 'no score file'
-	}
-	vacfs -m /n/`{basename $1 .vac} `{cat $score}
-case wiki
-	srv -m 'net!9p.io!wiki' wiki /mnt/wiki
+	vacfs -p <{echo $1}
+case vac.*
+	vacfs -m /n/$1 <{echo $1 | sed 's/vac\./vac:/'}
+case oldlog
+	vacfs -m /n/$1 `{ls -t /sys/log/vac/[12]???.vac | sed 1q}
+
+case log
+	9fs consoles
+	9fs stand
+	bind -a /n/consoles/sys/log /sys/log
+	bind -a /n/stand/sys/log /sys/log
+
+# misc. unix machines
+case fw
+	exec srvssh -u /usr/local/bin/u9fs fw fw /n/fw
+case mac imacpro
+	srv -mcC imacpro && bind /n/imacpro /n/mac
+#case mac imacpro
+# ssh is too hard nowadays
+#	exec srvssh -u u9fs tcp!imacpro!myssh mac /n/mac
+case mac-nfs imacpro-nfs
+	nfs -u /lib/nfs/passwd.mac /lib/nfs/group.mac imacpro >[2]/dev/null
+	mount /srv/imacpro /n/mac / && bind /n/mac /n/imacpro
+	# catalina weirdness
+	mount /srv/imacpro /n/mac/System/Volumes/Data /System/Volumes/Data
+	cd /n/mac/System/Volumes/Data &&
+		for (dir in *)
+			bind -bc $dir /n/mac/$dir >[2]/dev/null
+
+# general case
 case *
 	switch($#*){
 	case 1
-		srv -m $1
+		exec srv -mcC $1
 	case *
-		srv -m $1 $1 $2
+		exec srv -mcC $1 $1 $2
 	}
 }
+
+# only special cases recognised above get here
+switch($#*){
+case 1
+	;
+case 2
+	bind /n/$1 $2
+case *
+	usage
+}

+ 255 - 0
rc/bin/9fs.edith

@@ -0,0 +1,255 @@
+#!/bin/rc
+# 9fs filesystem - srv & mount filesystem, usually from plan 9
+
+rfork e
+arch=/lib/vac/arch		# archive mount point tree
+
+# mount netapp nfs servers
+fn mntnfs {	# name homedir-list
+	srvr=$1; shift
+	if (test -e /srv/$srvr.all) {
+		mount -C /srv/$srvr.all /n/$srvr
+		exit
+	}
+	if(! test -f /srv/$srvr)
+		nfs -p 666 -u /lib/ndb/1127.passwd /lib/ndb/1127.group $srvr
+	unmount /n/$srvr >[2]/dev/null
+	for (i)
+		mount -aC /srv/$srvr /n/$srvr /$i
+	rfork n
+	srvfs -p 666 $srvr.all /n/$srvr		# mainly for ftpd
+}
+
+switch($1){
+case ''
+	echo usage: 9fs service '[mountpoint]' >[1=2]
+	exit usage
+
+case main
+	mount -C /srv/boot /n/main main
+case dump
+	mount -C /srv/boot /n/dump main/archive
+	9fs archive
+	bind -a $arch/emelie /n/dump
+	bind -a $arch/emelie/2003 /n/dump/2003
+	bind -a $arch/bootes /n/dump
+case snap
+	mount -C /srv/boot /n/snap main/snapshot
+case other
+	if (test -e /srv/other)
+		mount -cC /srv/other /n/other && bind /n/other /n/fsother
+	if not
+		# importsrv net!edith!20564 /n/other && bind /n/other /n/fsother
+		srv -q -cC  net!edith!20564 other &&
+			mount -cC /srv/other /n/other &&
+			bind /n/other /n/fsother
+	9fs fsotherro
+#	importsrv edith /n/fs && {
+#		# started independent fossils, so they're not visible in /n/fs.
+#		# mount from /n/fs/srv
+#		mount -cC /n/fs/srv/fossil.spare /n/other
+#		mount -cC /n/fs/srv/fossil.other /n/other.ro
+#		bind /n/other.ro  /n/fsother.ro
+#	}
+case otherdb2
+	importsrv net!edith!20564 /n/other && bind /n/other /n/fsother
+	9fs fsotherro
+
+case fs
+	srv -q edith fs && mount -cC /srv/fs /n/fs main/active
+case fsmain
+	srv -q edith fs && mount -C /srv/fs /n/fsmain main
+case fsdump
+	srv -q edith fs && mount -C /srv/fs /n/fsdump main/archive
+case fssnap
+	srv -q edith fs && mount -C /srv/fs /n/fssnap main/snapshot
+case fsother
+	exec 9fs other
+#case fsspare
+#	srv -q edith fs && mount -cC /srv/fs /n/fsspare spare/active
+case fsboot
+	srv -q -cC net!edith!10564 $1 && mount -cC /srv/$1 /n/$1 # main/active
+case fsotherro
+	srv -q -cC net!edith!30564 other.ro && mount -cC /srv/other.ro /n/other.ro
+	bind /n/other.ro  /n/fsother.ro
+
+case outside outside.cs.bell-labs.com
+	exec importsrv net!outside!666 /n/$1
+
+case dusty scummy grubby
+	unmount /n/^$1 >/dev/null >[2]/dev/null
+	srv -m $1^.research.bell-labs.com $1 /n/^$1 && mount -c /srv/^$1 /n/^$1
+
+# the old jukeboxes' contents
+case archive bootes bootesdump fornax fornaxdump \
+    emelie emeliedump choline cholinedump jukes
+	mount -C /srv/jukes /n/jukes >[2]/dev/null || {
+		unmount /n/jukes >[2]/dev/null
+		rm -f /srv/jukes
+		if (~ $sysname yoshimi)
+			vacfs -h localhost -S jukes /lib/vac/jukes.vac
+		if not {
+			import -C -s jukes yoshimi /n/jukes
+			chmod +rw /srv/jukes >[2]/dev/null
+		}
+	}
+	mount -C /srv/jukes /n/jukes || exit 'can''t mount /srv/jukes'
+	if (! test -d /n/jukes/choline) {
+		echo $0: /n/jukes/choline missing! >[1=2]
+		exit no-choline
+	}
+	bind /n/jukes/bootes/1997/1231 /n/bootes
+	bind /n/jukes/fornax/1997/1231 /n/fornax
+	bind /n/jukes/emelie/2006/10301 /n/emelie
+	bind /n/jukes/choline/2006/0814 /n/choline
+
+	for (juke in bootes fornax emelie choline) {
+		bind /n/jukes/$juke /n/$juke^dump
+		# backward compatibility
+		bind /n/jukes/$juke $arch/$juke^dump
+		# should this be one of the above binds of a date?
+		bind /n/jukes/$juke $arch/$juke
+	}
+	bind $arch /n/archive		# backward compatibility
+case audio
+	9fs choline
+	9fs other
+	bind -a /n/choline/lib/audio /lib/audio	# stale rawmap
+	bind -b /n/other/audio /lib/audio	# current rawmap
+	bind -a /sys/lib/music /lib/audio/map
+
+case kfs
+	if(! test -f /srv/kfs)
+		disk/kfs
+	mount -cC /srv/kfs /n/kfs
+case localhost
+	srv -mC localhost
+case gridroot
+	import -C a.grid.bell-labs.com / /n/gridroot
+case grid
+	srv -mC a.grid.bell-labs.com grid /n/grid
+case home
+	srv -mC nslocum
+	bind /n/nslocum/home /home
+
+case martha	# martha local fossil
+	import -C sources.cs.bell-labs.com / /n/martha
+case sources	# martha network fossil
+	srv -mC net!sources!9fs sources /n/sources
+#	if (~ $status '')
+#		exit ''
+	if (! ~ $status '') {
+		rm -f /srv/sources
+		srv -mC net!sources!9fs sources /n/sources
+	}
+	# /n/sources is too much typing and /n/sources/plan9 is worse
+	bind /n/sources /n/src
+	if (test -e /n/src/adm)
+		bind /n/src/plan9 /n/p9
+case cm
+	# import net!cm.cs.bell-labs.com!666 / /n/cm	# no cm.cs any more
+	9fs alice
+	bind /n/alice/cm /n/cm
+case sourcesdump
+	9fs sources
+	mount -C /srv/sources /n/sourcesdump main/archive
+case sourcessnap
+	9fs sources
+	mount -C /srv/sources /n/sourcessnap main/snapshot
+
+# future main fs
+case yoshimi
+	srv -q yoshimi && mount -cC /srv/yoshimi /n/yoshimi main/active
+case yoshimimain
+	srv -q yoshimi && mount -cC /srv/yoshimi /n/yoshimimain main
+case yoshimidump
+	srv -q yoshimi && mount -C /srv/yoshimi /n/yoshimidump main/archive
+case yoshimisnap
+	srv -q yoshimi && mount -C /srv/yoshimi /n/yoshimisnap main/snapshot
+case yoshimistand
+	srv -q -cC net!yoshimi!10564 yoshimistand &&
+		mount -cC /srv/yoshimistand /n/yoshimistand main/active
+case yoshimiother
+	srv -q -cC net!yoshimi!20564 yoshimiother &&
+		mount -cC /srv/yoshimiother /n/yoshimiother main/active
+
+# temporary
+case nana
+	srv -q nana && mount -cC /srv/nana /n/nana main/active
+case nanamain
+	srv -q nana && mount -cC /srv/nana /n/nanamain main
+case nanasnap
+	srv -q nana && mount -cC /srv/nana /n/nanasnap main/snapshot
+
+#
+# obsolete
+#
+case jukeemelie
+	echo $0: sorry, emelie is frozen, effective 30 oct 2006 >[1=2]
+	exit frozen
+#	srv -q -cC emelie jemelie && mount -cC /srv/jemelie /n/emelie
+case jukeemeliedump
+	echo $0: sorry, emelie is frozen, effective 30 oct 2006 >[1=2]
+	exit frozen
+#	srv -q -cC emelie jemelie && mount -cC /srv/jemelie /n/emeliedump dump
+case emelietemp
+	echo $0: sorry, emelie is turned off, effective 30 oct 2006 >[1=2]
+	exit gone
+#	srv -q -cC emelie jemelie && mount -cC /srv/jemelie /n/emelietemp temp
+case emelieother
+	echo $0: sorry, emelie is turned off, effective 30 oct 2006 >[1=2]
+	exit gone
+#	srv -q -cC emelie jemelie && mount -cC /srv/jemelie /n/emelieother other
+
+#
+# netapp nfs servers
+#
+case bopp
+	mntnfs $1 (a0 b302 shome su0 su2 su3 v^(1 2 3 4 5 6 7 8 9) \
+		u^(0 1 2 3 4 5 6 7 8 9 a b c d e f g h i j y z))
+case hale
+	mntnfs $1 (h002 h003 h101 h103 h104)
+case scone
+	mntnfs $1 (scone^(0 1 2 3 4))
+case washer
+	mntnfs $1 (vol)
+
+case cab
+	srv -m net!crash-and-burn.lcs.mit.edu!9fs cab /n/cab
+case vac:*
+	vacfs <{echo $1}
+case vac.*
+	vacfs -m /n/$1 <{echo $1 | sed 's/vac\./vac:/'}
+case wiki
+	srv -q 'net!204.178.31.2!wiki' wiki
+	mount /srv/wiki /mnt/wiki
+case boundary lookout
+	exec importsrv $1
+case log
+	9fs boundary
+	9fs lookout
+	bind -a /n/boundary/sys/log /sys/log
+	bind -a /n/lookout/sys/log /sys/log
+case freebsd
+#	exec srvssh $1 $1 /n/$1
+	exec srvssh -u /home/geoff/bin/386/u9fs $1 $1 /n/$1
+case saras65k wolverine wraith
+	exec srvssh -u /home/geoff/bin/sparc/u9fs $1 $1 /n/$1
+case ipv6
+	exec srvssh -u u9fs net!$1.cs.bell-labs.com $1 /n/$1
+case outfw
+	exec srvssh -u u9fs /net.alt/net!$1.cs.bell-labs.com $1 /n/$1
+case geoff-fw
+	exec srvssh -u /usr/local/bin/u9fs /net.alt/net!10.0.0.1 fw /n/fw
+case geoff-nfw
+	exec srvssh -u /usr/local/bin/u9fs /net.alt/net!10.0.0.2 nfw /n/nfw
+case geoff-nfw-ext
+	exec srvssh -u /usr/local/bin/u9fs /net.alt/net!netbsd.collyer.net nfw /n/nfw
+case *
+	switch($#*){
+	case 1
+		exec srv -mc $1
+	case *
+		exec srv -mc $1 $1 $2
+	}
+}

+ 314 - 0
rc/bin/9fs.new

@@ -0,0 +1,314 @@
+#!/bin/rc
+# 9fs filesystem [mountpoint] - srv & mount filesystem, usually from plan 9
+
+rfork e
+arch=/lib/vac/arch		# archive mount-point tree
+
+# mount netapp nfs servers
+fn mntnfs {	# name homedir-list
+	srvr=$1; shift
+	if (test -e /srv/$srvr.all) {
+		mount -C /srv/$srvr.all /n/$srvr
+		exit
+	}
+	if(! test -f /srv/$srvr)
+		nfs -p 666 -u /lib/ndb/1127.passwd /lib/ndb/1127.group $srvr
+	unmount /n/$srvr >[2]/dev/null
+
+	# print errors only on first mount attempt
+	mount -aC /srv/$srvr /n/$srvr /$1
+	shift
+	for (i)
+		mount -aC /srv/$srvr /n/$srvr /$i >[2]/dev/null
+	rfork n
+	srvfs -p 666 $srvr.all /n/$srvr		# mainly for ftpd
+}
+
+fn usage {
+	echo usage: 9fs service '[mountpoint]' >[1=2]
+	exit usage
+}
+
+switch($1){
+case ''
+	usage
+
+# main fs
+case main snap dump other stand
+	9fs pie$1 && bind /n/pie$1 /n/$1
+case fs
+	9fs piemain && bind /n/piemain /n/$1
+case fsother
+	9fs pieother && bind /n/pieother /n/$1
+
+case pie
+	srv -q pie && mount -cC /srv/pie /n/$1 main/active
+case piemain
+	srv -q pie && mount -cC /srv/pie /n/$1 main/active
+case piedump
+	srv -q pie && mount -C /srv/pie /n/$1 main/archive
+	9fs archive
+	bind -a $arch/emelie /n/$1
+	bind -a $arch/emelie/2003 /n/$1/2003
+	bind -b $arch/bootes /n/$1
+case piesnap
+	srv -q pie && mount -C /srv/pie /n/$1 main/snapshot
+case piestand
+	srv -q -cC net!pie!10564 $1 && mount -cC /srv/$1 /n/$1 main/active
+case piestanddump
+	srv -q -cC net!pie!10564 $1 && mount -cC /srv/$1 /n/$1 main/archive
+case pieother
+	srv -q -cC net!pie!20564 $1 && mount -cC /srv/$1 /n/$1 main/active
+
+# previous fs
+case yoshimi
+	srv -q yoshimi && mount -cC /srv/yoshimi /n/$1 main/active
+case yoshimimain
+	srv -q yoshimi && mount -cC /srv/yoshimi /n/$1 main/active
+case yoshimidump
+	srv -q yoshimi && mount -C /srv/yoshimi /n/$1 main/archive
+	9fs archive
+	bind -a $arch/emelie /n/$1
+	bind -a $arch/emelie/2003 /n/$1/2003
+	bind -b $arch/bootes /n/$1
+case yoshimisnap
+	srv -q yoshimi && mount -C /srv/yoshimi /n/$1 main/snapshot
+case yoshimistand
+	srv -q -cC net!yoshimi!10564 $1 && mount -cC /srv/$1 /n/$1 main/active
+case yoshimistanddump
+	srv -q -cC net!yoshimi!10564 $1 && mount -cC /srv/$1 /n/$1 main/archive
+case yoshimiother
+	srv -q -cC net!yoshimi!20564 $1 && mount -cC /srv/$1 /n/$1 main/active
+
+# previous previous file server
+case edith
+	srv -q edith && mount -cC /srv/edith /n/$1 main/active
+case edithmain
+	srv -q edith && mount -C /srv/edith /n/$1 main
+case edithdump
+	srv -q edith && mount -C /srv/edith /n/$1 main/archive
+case edithsnap
+	srv -q edith && mount -C /srv/edith /n/$1 main/snapshot
+case edithroot
+	srv -q -cC net!edith!10564 $1 && mount -cC /srv/$1 /n/$1 main/active
+case edithrootdump
+	srv -q -cC net!edith!10564 $1 && mount -cC /srv/$1 /n/$1 main/archive
+case edithother
+	srv -q -cC net!edith!20564 $1 && mount -cC /srv/$1 /n/$1 main/active
+case edithotherro
+	srv -q -cC net!edith!30564 $1 && mount -cC /srv/$1 /n/$1 main/active
+
+# the old jukeboxes' contents
+case archive bootes bootesdump fornax fornaxdump \
+    emelie emeliedump choline cholinedump jukes
+	mount -C /srv/jukes /n/jukes >[2]/dev/null || {
+		unmount /n/jukes >[2]/dev/null
+		rm -f /srv/jukes
+		if (~ $sysname pie)
+			vacfs -h localhost -S jukes /lib/vac/jukes.vac
+		if not {
+#			import -C -s jukes pie /n/jukes
+#			chmod +rw /srv/jukes >[2]/dev/null
+			import pie / /n/pie &&
+				mount -C /n/pie/srv/jukes /n/jukes
+		}
+	}
+	if (! test -d /n/jukes/choline) {
+		mount -C /srv/jukes /n/jukes || exit 'can''t mount /srv/jukes'
+		if (! test -d /n/jukes/choline) {
+			echo $0: /n/jukes/choline missing! >[1=2]
+			exit no-choline
+		}
+	}
+	bind /n/jukes/bootes/1997/1231 /n/bootes
+	bind /n/jukes/fornax/1997/1231 /n/fornax
+	bind /n/jukes/emelie/2006/10301 /n/emelie
+	bind /n/jukes/choline/2006/0814 /n/choline
+
+	for (juke in bootes fornax emelie choline) {
+		bind /n/jukes/$juke /n/$juke^dump
+		# backward compatibility
+		bind /n/jukes/$juke $arch/$juke^dump
+		# should this be one of the above binds of a date?
+		bind /n/jukes/$juke $arch/$juke
+	}
+	bind $arch /n/archive		# backward compatibility
+case audio
+	bind -a /sys/lib/music /lib/audio/maps
+
+case kfs
+	if(! test -f /srv/kfs)
+		disk/kfs
+	mount -cC /srv/kfs /n/kfs
+case localhost
+	srv -mC localhost
+
+# the inside/outside border
+case boundary lookout
+	# permissions need to work and they don't with srv
+	exec import -C $1 / /n/$1
+#	exec importsrv $1
+
+#
+# the outside world
+#
+
+# outside venti & fossil server
+case outfs
+	srv -q outfs && mount -cC /srv/outfs /n/$1 main/active
+case outfsdump
+	srv -q outfs && mount -C /srv/outfs /n/$1 main/archive
+case outfssnap
+	srv -q outfs && mount -C /srv/outfs /n/$1 main/snapshot
+case outfsmain
+	srv -q -cC net!outfs!10564 $1 && mount -cC /srv/$1 /n/$1 main/active
+
+# new outside fossil server
+case bovril
+	srv -q bovril && mount -cC /srv/bovril /n/$1 main/active
+case bovrildump
+	srv -q bovril && mount -C /srv/bovril /n/$1 main/archive
+case bovrilsnap
+	srv -q bovril && mount -C /srv/bovril /n/$1 main/snapshot
+case bovrilmain
+	srv -q -cC net!bovril!10564 $1 && mount -cC /srv/$1 /n/$1 main/active
+
+# other outside machines, mostly legacy
+case outside outside.cs.bell-labs.com
+	exec import -C net!outside.cs.bell-labs.com!666 / /n/outside
+#	exec importsrv net!outside!666 /n/$1
+case outside-norm
+	srv -q outside && mount -cC /srv/outside /n/$1 main/active
+case noutside noutside.cs.bell-labs.com
+	exec import -C net!noutside.cs.bell-labs.com!666 / /n/noutside
+#	exec importsrv net!noutside!666 /n/$1
+case noutside-norm
+	srv -q noutside && mount -cC /srv/noutside /n/$1 main/active
+case noutsidedump
+	9fs noutside && mount -cC /srv/noutside /n/$1 main/archive
+case wiki
+	srv -q 'tcp!noutside!wiki' wiki
+	mount /srv/wiki /mnt/wiki
+case dusty scummy grubby
+	unmount /n/^$1 >/dev/null >[2]/dev/null
+	srv -m $1^.research.bell-labs.com $1 /n/^$1 && mount -c /srv/^$1 /n/^$1
+case gridroot
+	import -C a.grid.bell-labs.com / /n/gridroot
+case grid
+	srv -mC a.grid.bell-labs.com grid /n/grid
+case martha		# martha local fossil
+	exec import -C sources.cs.bell-labs.com / /n/martha
+case sources		# martha network fossil
+	srv -mC net!sources!9fs sources /n/sources
+	if (! ~ $status '') {
+		rm -f /srv/sources
+		srv -mC net!sources!9fs sources /n/sources
+	}
+	# /n/sources is too much typing and /n/sources/plan9 is worse
+	bind /n/sources /n/src
+	if (test -e /n/src/plan9)
+		bind /n/src/plan9 /n/p9
+case sourcesdump
+	9fs sources && mount -C /srv/sources /n/$1 main/archive
+case sourcessnap
+	9fs sources && mount -C /srv/sources /n/$1 main/snapshot
+
+#
+# netapp nfs servers
+#
+case home
+	9fs slocum && bind /n/slocum/home /n/home
+case prometheus
+	srv -mcC prometheus.research.bell-labs.com
+	bind  /n/prometheus.research.bell-labs.com /n/prometheus
+case cm
+	unix=slocum
+	if (! test -e /n/cm/index.html) {
+		if (! 9fs $unix) {
+			rm -f /srv/$unix
+			9fs $unix
+		}
+		bind /n/$unix/n/hale/h003/u0/cm /n/cm && {
+			rm -f /srv/cm
+			srvfs -p 666 cm /n/cm
+		}
+	}
+case bopp
+	# v8 first to make rae visible
+	mntnfs $1 (v8 a0 b302 shome su0 su2 su3 v^(1 2 3 4 5 6 7 9) \
+		u^(0 1 2 3 4 5 6 7 8 9 a b c d e f g h i j y z))
+case hale
+	mntnfs $1 (h002 h003 h101 h103 h104)
+case scone
+	mntnfs $1 (scone^(0 1 2 3 4))
+case washer
+	mntnfs $1 (vol)
+
+# arbitrary venti archives
+case vac:*
+	vacfs <{echo $1}
+case vac.*
+	vacfs -m /n/$1 <{echo $1 | sed 's/vac\./vac:/'}
+case oldlog
+	vacfs -m /n/$1 `{sed 1q `{ls -t /sys/log/vac/[12]???.vac}}
+
+case log
+	9fs boot
+	bind /n/boot/sys/log /sys/log
+	for (fsys in boundary lookout stand outfs) {
+		9fs $fsys && bind -a /n/$fsys/sys/log /sys/log
+	}
+
+case coraid
+	srv -mc net!devi!10564 coraid /n/coraid
+
+# misc. unix machines
+case album
+	9fs album.research.bell-labs.com &&
+		bind /n/album.research.bell-labs.com /n/album
+case slocum
+	9fs slocum.research.bell-labs.com &&
+		bind /n/slocum.research.bell-labs.com /n/slocum
+case slocum-ssh
+	sys=slocum
+	exec srvssh -u u9fs net!$sys.research.bell-labs.com $sys /n/$sys
+case slocum-big
+	exec srvssh -u /home/geoff/bin/IP27.IRIX64/u9fs \
+		slocum $1 /n/slocum
+case geoff-x60 geoff-x60-50 brunei soekris1 db-security
+	exec srvssh -u /usr/local/bin/u9fs $1 $1 /n/$1
+case freebsd
+#	exec srvssh $1 $1 /n/$1
+	exec srvssh -u /home/geoff/bin/386/u9fs $1 $1 /n/$1
+case saras65k wolverine wraith
+	exec srvssh -u /home/geoff/bin/sparc/u9fs $1 $1 /n/$1
+case ipv6 vfw vfw-out outfw ethel
+	exec srvssh -u u9fs net!$1.cs.bell-labs.com $1 /n/$1
+# at home
+case geoff-fw
+	exec srvssh -u /usr/local/bin/u9fs /net.alt/net!10.0.0.2 fw /n/fw
+case geoff-mac
+	exec srvssh -u /usr/local/bin/u9fs /net.alt/net!10.0.10.2 mac /n/mac
+# at work
+case geoff-fw-ext
+	exec srvssh -u /usr/local/bin/u9fs /net.alt/net!fw-fios.collyer.net fw /n/fw
+
+# general case
+case *
+	switch($#*){
+	case 1
+		exec srv -mc $1
+	case *
+		exec srv -mc $1 $1 $2
+	}
+}
+
+# only special cases recognised above get here
+switch($#*){
+case 1
+	;
+case 2
+	bind /n/$1 $2
+case *
+	usage
+}

+ 304 - 0
rc/bin/9fs.pie

@@ -0,0 +1,304 @@
+#!/bin/rc
+# 9fs filesystem [mountpoint] - srv & mount filesystem, usually from plan 9
+
+rfork e
+arch=/lib/vac/arch		# archive mount-point tree
+
+fn usage {
+	echo usage: 9fs service '[mountpoint]' >[1=2]
+	exit usage
+}
+
+# mount netapp nfs servers
+fn mntnfs {	# name homedir-list
+	srvr=$1; shift
+	if (test -e /srv/$srvr.all) {
+		mount -C /srv/$srvr.all /n/$srvr
+		exit
+	}
+	if(! test -f /srv/$srvr)
+		nfs -p 666 -u /lib/ndb/1127.passwd /lib/ndb/1127.group $srvr
+	unmount /n/$srvr >[2]/dev/null
+
+	# print errors only on first mount attempt
+	mount -aC /srv/$srvr /n/$srvr /$1
+	shift
+	for (i)
+		mount -aC /srv/$srvr /n/$srvr /$i >[2]/dev/null
+	rfork n
+	srvfs -p 666 $srvr.all /n/$srvr		# mainly for ftpd
+}
+
+switch($1){
+case ''
+	usage
+
+# main fs
+#case pieother other		# for use when other is being checked
+#	echo $1 is being repaired, try again later. >[1=2]
+#	exit check
+case main other stand
+	9fs pie$1 && bind -c /n/pie$1 /n/$1
+case snap dump othersnap standdump standsnap
+	9fs pie$1 && bind /n/pie$1 /n/$1
+case fs
+	9fs piemain && bind -c /n/piemain /n/$1
+case fsother
+	9fs pieother && bind -c /n/pieother /n/$1
+
+case pie piemain
+	srv -q pie && mount -cC /srv/pie /n/$1 main/active
+case piedump
+	srv -q pie && mount -C /srv/pie /n/$1 main/archive
+	9fs archive
+	bind -a $arch/emelie /n/$1
+	bind -a $arch/emelie/2003 /n/$1/2003
+	bind -b $arch/bootes /n/$1
+case piesnap
+	srv -q pie && mount -C /srv/pie /n/$1 main/snapshot
+case piestand
+	srv -q -cC net!pie!10564 $1 && mount -cC /srv/$1 /n/$1 main/active
+case piestanddump
+	srv -q -cC net!pie!10564 $1 && mount -cC /srv/$1 /n/$1 main/archive
+case piestandsnap
+	srv -q -cC net!pie!10564 $1 && mount -cC /srv/$1 /n/$1 main/snapshot
+case pieother
+	srv -q -cC net!pie!20564 $1 && mount -cC /srv/$1 /n/$1 main/active
+case pieothersnap
+	srv -q -cC net!pie!20564 $1 && mount -cC /srv/$1 /n/$1 main/snapshot
+
+# the old jukeboxes' contents
+case archive bootes bootesdump fornax fornaxdump \
+    emelie emeliedump choline cholinedump jukes
+	mount -C /srv/jukes /n/jukes >[2]/dev/null || {
+		unmount /n/jukes >[2]/dev/null
+		rm -f /srv/jukes
+		if (~ $sysname pie)
+			vacfs -h localhost -S jukes /lib/vac/jukes.vac
+		if not {
+			import pie / /n/pie &&
+				mount -C /n/pie/srv/jukes /n/jukes
+		}
+	}
+	if (! test -d /n/jukes/choline) {
+		mount -C /srv/jukes /n/jukes || exit 'can''t mount /srv/jukes'
+		if (! test -d /n/jukes/choline) {
+			echo $0: /n/jukes/choline missing! >[1=2]
+			exit no-choline
+		}
+	}
+	bind /n/jukes/bootes/1997/1231 /n/bootes
+	bind /n/jukes/fornax/1997/1231 /n/fornax
+	bind /n/jukes/emelie/2006/10301 /n/emelie
+	bind /n/jukes/choline/2006/0814 /n/choline
+
+	for (juke in bootes fornax emelie choline) {
+		bind /n/jukes/$juke /n/$juke^dump
+		# backward compatibility
+		bind /n/jukes/$juke $arch/$juke^dump
+		# should this be one of the above binds of a date?
+		bind /n/jukes/$juke $arch/$juke
+	}
+	bind $arch /n/archive		# backward compatibility
+case audio
+	bind -a /sys/lib/music /lib/audio/maps
+
+case kfs
+	if(! test -f /srv/kfs)
+		disk/kfs
+	mount -cC /srv/kfs /n/kfs
+case localhost
+	srv -mC localhost
+
+# antwerp and its complicated networks
+case delirium				# only on network 10
+	import duvel / /n/$1
+
+# the inside/outside border
+case boundary lookout
+	# permissions need to work and they don't with srv
+	exec import -C $1 / /n/$1
+
+#
+# the outside world
+#
+
+# outside venti & fossil server
+case outfs
+	srv -q outfs && mount -cC /srv/outfs /n/$1 # main/active
+case outfsdump
+	srv -q outfs && mount -C /srv/outfs /n/$1 main/archive
+case outfssnap
+	srv -q outfs && mount -C /srv/outfs /n/$1 main/snapshot
+case outfsmain
+	srv -q -cC net!outfs!10564 $1 && mount -cC /srv/$1 /n/$1
+case outfsother
+	srv -q -cC net!outfs!20564 $1 && mount -cC /srv/$1 /n/$1
+
+# new outside fossil server
+case bovril
+	srv -q bovril && mount -cC /srv/bovril /n/$1 main/active
+case bovrildump
+	srv -q bovril && mount -C /srv/bovril /n/$1 main/archive
+case bovrilsnap
+	srv -q bovril && mount -C /srv/bovril /n/$1 main/snapshot
+case bovrilmain
+	srv -q -cC net!bovril!10564 $1 && mount -cC /srv/$1 /n/$1 main/active
+
+# other outside machines, mostly legacy
+case outside outside.cs.bell-labs.com
+	exec import -C net!outside.cs.bell-labs.com!666 / /n/outside
+#	exec importsrv net!outside!666 /n/$1
+case outside-norm
+	srv -q outside && mount -cC /srv/outside /n/$1 main/active
+case wiki
+	srv -q 'tcp!outside!wiki' wiki
+	mount /srv/wiki /mnt/wiki
+case roku
+	srv -q www.collyer.net roku && mount -cC /srv/roku /n/roku
+case dusty scummy grubby
+	unmount /n/^$1 >/dev/null >[2]/dev/null
+	srv -m $1^.research.bell-labs.com $1 /n/^$1 && mount -c /srv/^$1 /n/^$1
+case haggis			# haggis local fossil
+	exec import -C sources.cs.bell-labs.com / /n/haggis
+case sources			# haggis network fossil
+	srv -mcC net!sources!9fs sources /n/sources
+	if (! ~ $status '') {
+		rm -f /srv/sources
+		srv -mcC net!sources!9fs sources /n/sources
+	}
+	# /n/sources is too much typing and /n/sources/plan9 is worse
+	bind /n/sources /n/src
+	if (test -e  /n/src/plan9)
+		bind /n/src/plan9 /n/p9
+case srcnone			# haggis network fossil
+	srv -mcCn net!sources!9fs src /n/src
+	if (! ~ $status '') {
+		rm -f /srv/src
+		srv -mcCn net!sources!9fs src /n/src
+	}
+	if (test -e  /n/src/plan9)
+		bind /n/src/plan9 /n/p9
+case sourcesdump
+	9fs sources && mount -cC /srv/sources /n/$1 main/archive
+case sourcessnap
+	9fs sources && mount -cC /srv/sources /n/$1 main/snapshot
+
+#
+# netapp nfs servers
+#
+case home
+	9fs slocum && bind /n/slocum/home /n/home
+case prometheus
+	srv -mcC prometheus.research.bell-labs.com
+	bind  /n/prometheus.research.bell-labs.com /n/prometheus
+case cm
+	unix=slocum
+	if (! test -e /n/cm/index.html) {
+		if (! 9fs $unix) {
+			rm -f /srv/$unix
+			9fs $unix
+		}
+		bind /n/$unix/n/hale/h003/u0/cm /n/cm && {
+			rm -f /srv/cm
+			srvfs -p 666 cm /n/cm
+		}
+	}
+case bopp
+	# v8 first to make rae visible
+	mntnfs $1 (v8 a0 b302 shome su0 su2 su3 v^(1 2 3 4 5 6 7 9) \
+		u^(0 1 2 3 4 5 6 7 8 9 a b c d e f g h i j y z) vol)
+case hale
+	mntnfs $1 (h002 h003 h101 h103 h104)
+case scone
+	mntnfs $1 (scone^(0 1 2 3 4 5))
+case washer
+	mntnfs $1 (vol)
+
+# arbitrary venti archives
+case vac:*
+	vacfs <{echo $1}
+case vac.*
+	vacfs -m /n/$1 <{echo $1 | sed 's/vac\./vac:/'}
+case *.vac
+	if (test -e $1)
+		score=$1
+	if not if (! ~ $1 /* && test -e $home/lib/vac/$1)
+		score=$home/lib/vac/$1
+	if not if (! ~ $1 /* && test -e /lib/vac/$1)
+		score=/lib/vac/$1
+	if not {
+		echo $0: $1: no such score file >[1=2]
+		exit 'no score file'
+	}
+	vacfs -m /n/`{basename $1 .vac} `{cat $score}
+
+case oldlog
+	vacfs -m /n/$1 `{sed 1q `{ls -t /sys/log/vac/[12]???.vac}}
+case log
+	9fs boot
+	bind /n/boot/sys/log /sys/log
+	# order matters: boundary should be after lookout
+	for (fsys in lookout boundary tatties stand outfs) {
+		@ { 9fs $fsys && bind -a /n/$fsys/sys/log /sys/log } &
+		sleep 0.1
+	}
+	wait
+
+# misc. unix machines
+case album
+	9fs album.research.bell-labs.com &&
+		bind /n/album.research.bell-labs.com /n/album
+case slocum
+	9fs slocum.research.bell-labs.com &&
+		bind /n/slocum.research.bell-labs.com /n/slocum
+case slocum-ssh
+	sys=slocum
+	exec srvssh net!$sys.research.bell-labs.com $sys /n/$sys
+case brunei db-security debian-box soekris1 toast ubuntu-box celnet-pc-zt4* \
+	bbrouter
+	exec srvssh -u /usr/local/bin/u9fs $1
+case ches
+	exec srvssh -u /v/bin/u9fs $1
+case freebsd
+	exec srvssh -u /home/geoff/bin/386/u9fs $1
+case saras65k wolverine wraith
+	exec srvssh -u /home/geoff/bin/sparc/u9fs $1
+case abmx inet* outfw* noutfw* rpi soylent tedium* torture ts vfw*
+	exec srvssh $1
+case config
+	user=hpss srvssh net!config.ho.lucent.com config /n/config
+	exit
+case soylent.*.bell-labs.com
+	exec srvssh net!$1 soylent /n/soylent
+# at home
+case geoff-fw
+	outside
+	exec srvssh -u /usr/local/bin/u9fs /net.alt/net!fw.collyer.net fw /n/fw
+case geoff-mac macpro.collyer.net
+	outside
+	exec srvssh -u /usr/local/bin/u9fs /net.alt/net!macpro.collyer.net mac /n/mac
+# at work
+case geoff-fw-ext
+	outside
+	exec srvssh -u /usr/local/bin/u9fs /net.alt/net!fw-fios.collyer.net fw /n/fw
+
+# general case
+case *
+	switch($#*){
+	case 1
+		exec srv -mc $1
+	case *
+		exec srv -mc $1 $1 $2
+	}
+}
+
+# only special cases recognised above get here
+switch($#*){
+case 1
+	;
+case 2
+	bind -c /n/$1 $2
+case *
+	usage
+}

+ 20 - 5
rc/bin/C

@@ -1,6 +1,10 @@
 #!/bin/rc
 # C system - connect to system's console
 rfork en
+if (~ $#* 0) {
+	echo usage: $0 '[-r]' system >[1=2]
+	exit usage
+}
 oflag=()
 opt=-r
 while(~ $1 -*)
@@ -17,11 +21,13 @@ while(~ $1 -*)
 	}
 
 switch($1){
+# usually you should add a 'console=<console-server>' clause
+# to the target machine's ndb entry, not modify this script.
 case ella
 	exec C office0
 	exit
-case erika
-	exec C office1
+case Rella
+	exec C office2 < /dev/null
 	exit
 case *
 	# look for server in /lib/ndb
@@ -29,7 +35,7 @@ case *
 	switch($server){
 	case ''
 		echo C: unknown console server for $1
-		exit 1
+		exit 'unknown console server'
 	}
 }
 
@@ -37,7 +43,10 @@ case *
 switch($server){
 case dinar bones
 	ssh $server C $1
-	exit 0
+	exit ''
+case out?* roku?*
+	outside
+	bind /net.alt /net
 }
 
 if(! test -e /mnt/consoles/$1){
@@ -45,7 +54,13 @@ if(! test -e /mnt/consoles/$1){
 	case $server
 		mount /srv/consoles /mnt/consoles
 	case *
-		import $oflag $server /mnt/consoles
+		import -E clear $oflag $server /mnt/consoles
+		x=`{ls /mnt/consoles}
+		if (~ $#x 0) {
+			import -E clear $oflag $server / /n/$server
+			# gets: i/o on hungup channel
+			mount /n/$server/srv/consoles /mnt/consoles
+		}
 	}
 }
 

+ 6 - 0
rc/bin/abaco

@@ -0,0 +1,6 @@
+#!/bin/rc
+rfork n
+webfs
+webcookies
+bind -a /sys/src/cmd/abaco /lib/font/bit/lucidasans # for passwd.6.font
+exec /$cputype/bin/abaco $*

+ 3 - 1
rc/bin/addpsfonts

@@ -2,4 +2,6 @@
 # addpsfonts [file]... - add postscript fonts named in %%DocumentFonts comments
 #	of postscript input
 echo %!PS-Adobe-2.0
-exec aux/download -f -mfontmap -plw+ -r/sys/lib/postscript/font/lw+ $*
+# rsc recommends adding -r/sys/lib/postscript/font/lw+,
+# but i haven't seen the benefit yet.
+exec aux/download -f -mfontmap -plw+ $*

+ 29 - 0
rc/bin/addroutes

@@ -0,0 +1,29 @@
+#!/bin/rc
+# addroutes [netdir] - add local routes to network
+rfork e
+pfx=2603:3024:9fd:60		# old
+# pfx=2603:3024:90c:9e		# old
+
+if (~ $#* 0)
+	cd /net
+if not
+	cd $1
+if(! test -e iproute)	# 9vx potentially doesn't have /net/iproute
+	exit ''
+
+if(grep -s '^10\.0\.' ipselftab) {	# on private network 10 only
+	# default v6 route towards internet via nat.
+	echo add :: /0 $pfx^e1::6 >iproute
+}
+if not {				# on public network
+	# default v6 route to comcast-gw via fw & net 10
+	echo add :: /0 $pfx^e2::2 >iproute
+
+	# route to private network from public via nat in fw.
+	# NB: subnet masks are v6, even for v4 addresses
+	echo add 10.0.0.0 /120 96.78.174.36 >iproute
+	echo add $pfx^e1:: /64 $pfx^e2::2 >iproute
+
+	# remove bogus private v6 address until we find out where it comes from
+	echo remove $pfx^e1:: /64 >iproute
+}

+ 25 - 0
rc/bin/addroutes.60f

@@ -0,0 +1,25 @@
+#!/bin/rc
+# addroutes [netdir] - add local routes to network
+if (~ $#* 0)
+	cd /net
+if not
+	cd $1
+if(! test -e iproute)	# 9vx potentially doesn't have /net/iproute
+	exit ''
+
+if(grep -s '^10\.0\.' ipselftab) {	# on private network 10 only
+	# default v6 route towards internet via nat.
+	echo add :: /0 2603:3024:9fd:60f1::6 >iproute
+}
+if not {				# on public network
+	# default v6 route to comcast-gw via fw & net 10
+	echo add :: /0 2603:3024:9fd:60f2::2 >iproute
+
+	# route to private network from public via nat in fw.
+	# NB: subnet masks are v6, even for v4 addresses
+	echo add 10.0.0.0 /120 96.78.174.36 >iproute
+	echo add 2603:3024:9fd:60f1:: /64 2603:3024:9fd:60f2::2 >iproute
+
+	# remove bogus private v6 address until we find out where it comes from
+	echo remove 2603:3024:9fd:60f1:: /64 >iproute
+}

+ 1 - 1
rc/bin/ape/c89

@@ -1,2 +1,2 @@
 #!/bin/rc
-exec /$cputype/bin/ape/cc $*
+exec /$objtype/bin/ape/cc $*

+ 2 - 24
rc/bin/ape/grep

@@ -1,25 +1,3 @@
 #!/bin/rc
-
-rfork e
-
-opts=()
-files=()
-argv0=$0
-while(! ~ $#* 0){
-	switch($1){
-	case -e
-		opts=($opts $1 $2)
-		shift
-	case -[cfinsv]
-		opts=($opts $1)
-	case -q
-		opts=($opts -s)
-	case -*
-		echo $argv0 $1 not supported >[2=1]
-		exit 'not supported'
-	case *
-		files=($files $1)
-	}
-	shift
-}
-exec /$cputype/bin/grep $opts $files
+# the -G flag is gone!
+exec /$cputype/bin/grep $*

+ 2 - 9
rc/bin/ape/ls

@@ -14,7 +14,6 @@
 # -c	show ctime
 # -d	dirs
 # -f	no sorting
-# -i	inode numbers
 # -l	long
 # -p	put slash after dir (-F)
 # -r	reverse
@@ -24,7 +23,7 @@
 # -1	single-column
 
 
-flagfmt='A,C,F,H,L,R,U,a,c,d,f,i,l,p,r,s,t,u,1'
+flagfmt='A,C,F,H,L,R,U,a,c,d,f,l,p,r,s,t,u,1'
 args='[file ...]'
 
 if(! ifs=() eval `{aux/getflags $*}){
@@ -37,12 +36,7 @@ fn fixlong {
 	/$cputype/bin/sed 's/^(.).(.........) . [0-9]+ /\1\2 1 /'
 }
 
-fn qid2inode {
-	/$cputype/bin/sed 's/^\(([^ ]+).*\) /\1 /'
-}
-
 post=cat
-post2=cat
 
 all=()
 # ignore -A
@@ -55,7 +49,6 @@ if(~ $flagU 1) all=($all -n)
 if(~ $flagd 1) all=($all -d)
 if(~ $flagf 1) all=($all -n)
 if(~ $flagl 1) { all=($all -l); post=fixlong }
-if(~ $flagi 1) { all=($all -q); post2=qid2inode }
 if(~ $flagp 1) all=($all -F)
 if(~ $flagr 1) all=($all -r)
 if(~ $flags 1) all=($all -s)
@@ -63,4 +56,4 @@ if(~ $flagt 1) all=($all -t)
 if(~ $flagu 1) all=($all -u)
 # ignore -1
 
-/$cputype/bin/ls $all $* | $post | $post2
+/$objtype/bin/ls $all $* | $post

+ 1 - 7
rc/bin/ape/psh

@@ -7,10 +7,4 @@ bind -b /rc/bin/ape /bin
 bind -b /$cputype/bin/ape /bin
 if(test -d /$cputype/bin/pub)
 	bind -a /$cputype/bin/pub /bin
-if(test -d /$cputype/bin/X11){
-	bind -a /$cputype/bin/X11 /bin
-	if(test ! -e /env/DISPLAY)
-		DISPLAY=:0.0
-}
-
-/bin/sh $*
+exec /bin/sh $*

+ 10 - 0
rc/bin/arp

@@ -0,0 +1,10 @@
+#!/bin/rc
+# arp [/net/arp] - format /net*/arp more usefully
+if (! ~ $#* 1)
+	* = (/net/arp)		# default
+if (test -d $1)
+	* = $1^/arp		# accept just the directory name
+{
+	grep 'OK|WAIT' $1 | column 3 4 | grep '\.' | sort -t. +3n	# v4
+	grep 'OK|WAIT' $1 | column 3 4 | grep -v '\.' | sort		# v6
+} | column 2 1

+ 11 - 0
rc/bin/audio

@@ -0,0 +1,11 @@
+#!/bin/rc
+# audio - set up namespaces and run agui
+rfork n
+if (test -e '#A/audio')
+	bind -a '#A' /dev			>/dev/null >[2=1]
+if (! test -e /dev/audio)
+	mount -b /srv/usbaudio.$sysname	/dev	>/dev/null >[2=1]
+if (! test -e /dev/audio)
+	usb/usbaudio -V -s usbaudio.$sysname
+9fs audio
+exec games/agui $*

+ 16 - 0
rc/bin/await

@@ -0,0 +1,16 @@
+#!/bin/rc
+# badguy ip... - add ip addresses of bad guys to /sys/lib/badips
+cd /sys/lib
+chmod +l badips.lock >>badips.lock		# for first time
+{
+	for (ip) {
+		if (~ $ip *.*.*.* && ! ~ $ip 50.250.245.* && ! ~ $ip 10.0.*)
+			echo $ip >>badips
+		if not
+			echo $0: $ip: illegal bad-guy ipv4 addr >[1=2]
+	}
+# don't race with smtpd, which adds impatient spammers
+#	chmod -a badips
+#	sort -u badips | sort -o badips -t. +0n -1 +1n -2 +2n -3 +3n
+	chmod +a badips
+} >>badips.lock

+ 3 - 0
rc/bin/bdr

@@ -0,0 +1,3 @@
+#!/bin/rc
+# print names of device directories of local BD-R devices
+grep -l '^(inquiry|model).*(BLU|BD)' '#S'/sd*/ctl | sed 's;/ctl$;;' | sort -u

+ 17 - 0
rc/bin/bootme

@@ -0,0 +1,17 @@
+#!/bin/rc
+rfork n
+cd /
+9fs boot		# in case of odd namespace
+
+kern=`{echo $terminal | sed 's;^([^ ]+) .*/([^/]+)$;/n/boot/'$cputype'/9\2;'}
+if (! test -e $kern) {
+	echo $0: $kern: no such kernel >[1=2]
+	exit 'no '$"kern
+}
+echo booting $kern
+echo reboot  $kern >/dev/reboot >[2]/dev/null
+
+# try boot image, if $kern is a raw binary
+kern=`{ echo $kern | sed 's;.*/;&s;' }
+echo booting $kern
+echo reboot  $kern >/dev/reboot

+ 7 - 0
rc/bin/chop

@@ -0,0 +1,7 @@
+#!/bin/rc
+# chop file ... - truncate append-only files
+for (f) {
+	chmod -a $f >[2]/dev/null
+	>$f
+	chmod +a $f
+}

+ 72 - 0
rc/bin/classical

@@ -0,0 +1,72 @@
+#!/bin/rc
+
+rfork ne
+
+wide=`{echo $vgasize | sed 's/(.*)x.*x.*/\1 > 240/' | hoc}
+
+debug=0
+tflag=''
+wflag=''
+host=''
+kb=4096
+flags=()
+sname=$user
+if (! ~ $wide 1) {
+	flags=($flags -t)
+	kb=1024
+}
+while(! ~ $#* 0) {
+	switch ($1) {
+	case -d
+		debug=$2
+		shift
+	case -t
+		tflag='-t'
+	case -h
+		host=$2
+		shift
+	case -w
+		wflags='-w'
+	case -s
+		sname=$2
+		shift
+	case -*
+		echo Usage: classical [-d level] [-t] [-h srvhost]
+		exit usage
+	}
+	shift
+}
+if (! test -e /mnt/playlist){
+	if (! ~ $debug '0') echo mounting playlistfs
+	if (! test -e /srv/playlist.$sname && ! ~ $host ''){
+		import -a $host /srv /srv
+	}
+	if (! mount -b /srv/playlist.$sname /mnt >/dev/null >[2]/dev/null){
+		rm -f /srv/playlist.$sname
+		if (! test -e /sys/lib/music/classic){
+			if (! ~ $debug '0') echo connecting to choline
+			if (! test -e /n/choline/lib/audio)
+				9fs choline
+			if (! bind -a /n/choline/lib/audio /sys/lib/music)
+				exit choline
+		}
+		if (! ~ $debug '0') echo starting playlistfs
+		games/playlistfs -s $sname -d $debug
+	}
+	if not {
+		mount -b /srv/playlist.$sname /mnt
+	}
+}
+if (! test -w /mnt/classical) {
+	if (! test -e /srv/classicsrv.$user && ! ~ $host ''){
+		import -a $host /srv /srv
+	}
+	if (! mount -b /srv/classicsrv.$user /mnt >/dev/null >[2]/dev/null){
+		if (! ~ $debug '0') echo games/classicsrv
+		games/classicsrv -s
+	}
+}
+if (~ $wflags '-w') {
+	exec games/classicjuke -w -d $debug $tflag &
+}
+exec games/classicjuke -d $debug $tflag

+ 29 - 0
rc/bin/column

@@ -0,0 +1,29 @@
+#!/bin/rc
+# column [-F sep] [n...]] - print n'th column(s); `n' may be `NF'
+rfork e
+switch ($1) {
+case -F
+	if (~ $2 '\t')
+		sep='-F	'
+	if not
+		sep=-F^$"2
+	shift 2
+case -F?*
+	if (~ $1 '-F\t')
+		sep='-F	'
+	if not
+		sep=$1
+	shift
+}
+
+switch ($#*) {
+case 0
+	* = 1
+case *
+	if (! ~ $1 NF [0-9] [0-9][0-9] [0-9][0-9][0-9]) {
+		echo usage: $0 '[-F sep] [n...]' >[1=2]
+		exit usage
+	}
+}
+arglist=`{echo $* | sed -e 's/NF|[0-9]+/$&,/g' -e 's/,$//'}
+exec awk $sep '{print '^$"arglist^'}'

+ 35 - 0
rc/bin/cookiewarning

@@ -0,0 +1,35 @@
+#!/bin/rc
+# cookiewarning - warn the cookie czar to bring some
+rfork ne
+ramfs
+moo=()
+
+ifs='
+'
+next=`{calendar -y -p 4 /lib/cookie}
+for(i in $next)
+	moo=($moo `{echo $i|awk '{print $3;}'})
+
+mail clarkson <<EOF
+
+next COOKIE is:
+$next
+sent mail to $moo
+
+EOF
+mail $moo <<EOF
+Next cookie rotation goes to:
+
+$next
+
+For your week, you're the cookie czar.  Buy or bake whatever kind of
+cookies you want and like, and don't feel compelled to get high-end or
+fancy stuff.  We have had one request that Oatmeal Raisin cookies be
+part of the selection, if at all possible.  Please refer any
+complainers to Ken Clarkson, who will be happy to enlist them as a new
+volunteer.
+
+Eight bags of Pepperidge Farm-style cookies seems to be about the
+right amount of cookies for one Friday.
+
+EOF

+ 3 - 0
rc/bin/cparena

@@ -0,0 +1,3 @@
+#!/bin/rc
+date
+time venti/wrarena -h fs -o $1 /dev/sdC0/arena0

+ 3 - 0
rc/bin/cpuboo

@@ -0,0 +1,3 @@
+#!/bin/rc
+myfact
+exec cpu -u bootes $*

+ 69 - 48
rc/bin/cpurc

@@ -1,21 +1,29 @@
 #!/bin/rc
-# cpu server start up
-date > /env/boottime
+# cpu server startup
+boottime=`{date}
+boottime=$"boottime
+echo cpurc starting $boottime
 
-# mount points
-mntgen -s slashn && chmod 666 /srv/slashn
-
-# name translation, cs sets /dev/sysname
-ndb/cs
+# cs sets /dev/sysname
+ndb/cs -4			# bloody google's ipv6 mail sending rules
 sysname=`{cat /dev/sysname}
 
+# get rid of need for dirs in /n
+mntgen -s slashn && chmod 666 /srv/slashn
+
 # parallelism for mk
 NPROC = `{wc -l </dev/sysstat}
 
+# enable usb keyboard, among other usb devices
+if (! test -e /srv/usb && test -e '#u/usb')
+	usb/usbd
+
 # site-specific startup
+listener=()
 if(test -e /rc/bin/cpurc.local)
 	. /rc/bin/cpurc.local
 
+# sysname sanity checks
 if (~ $#sysname 0 || ~ $sysname '') {
 	sysname = helix			# default
 	echo -n $sysname >/dev/sysname
@@ -23,60 +31,73 @@ if (~ $#sysname 0 || ~ $sysname '') {
 prompt=($sysname^'# ' '	')
 
 # cpu-specific startup
+# if it runs aux/listen, it must first run ndb/dns.
+if(! test -e '/env/*envloaded')
+	. loadcfgpxe
 if(test -e /cfg/$sysname/cpurc)
 	. /cfg/$sysname/cpurc
 
+# if we're not a server, start a dns resolver
+if(! test -e /srv/dns && ! test -e /env/dns) {
+	echo -n dns...
+	ndb/dns	&		# -rF
+}
+
+# reboot cpu server if we lose the file server
+if (! ~ $sysname fs)
+	aux/reboot &
+
+# don't turn on dong's tcp port hog defense; our firewall drops
+# the out-of-sequence keepalives it uses, thus dropping
+# inside-to-outside connections after 5 minutes.
+#if( test -e /net/tcp/clone)
+#	echo -n tcpporthogdefense on > /net/tcp/0/ctl
+
+# keep other bootes processes from creating capabilities (optional)
+rm '#¤/caphash' > /dev/null >[2=1]
+
 # start up internet if we don't already have an address
-if(! grep u /net/ipselftab | grep -sv 127.0.0.1)
+if(! grep u /net/ipselftab | grep -sv 127.0.0.1) {
+	echo -n ipconfig for ip...
+	ip/ipconfig
+}
+if not if (~ $sysname pi) # in case on net 10 and answered by fw or airport extreme
 	ip/ipconfig
-if(! grep -s 127.0.0.1 /net/ipselftab)
+if(! grep -s 127.0.0.1 /net/ipselftab) {
+	echo -n loopbacks...
 	ip/ipconfig loopback /dev/null 127.1
+	ip/ipconfig loopback /dev/null ::1 /128
+}
 
-# if we're not a server, start a dns resolver
-if(! test -e /srv/dns)
-	ndb/dns -r
-
-# If you are on an auth server, start these before listening:
-#
-# auth/keyfs -wp -m /mnt/keys /adm/keys >/dev/null >[2=1]
-# auth/cron >>/sys/log/cron >[2=1] &
-
-# keep other bootes processes from creating capabilities
-rm -f '#¤/caphash'
-
-# also rename some files on an auth server:
-#
-# if(! test -e /rc/bin/service.auth/tcp567){
-#	mv /rc/bin/service.auth/authsrv.il566 /rc/bin/service.auth/il566
-#	mv /rc/bin/service.auth/authsrv.tcp567 /rc/bin/service.auth/tcp567
-#	mv /rc/bin/service/il566 /rc/bin/service/_il566
-#	mv /rc/bin/service/tcp567 /rc/bin/service/_tcp567
-# }
-
-# netssh
-
-# start listeners if it hasn't already been done (dicey check)
-if(! netstat -n | grep -s 'tcp.*Listen.* (7|9|21|22|23|25|110|113|565|993|17007|17009|17010) .*')
-	aux/listen -q tcp
-# we don't use IL, maybe you do
-if(! netstat -n | grep -v 17008 | grep -s il.*Listen)
-	aux/listen -q il
+# start listeners if it hasn't already been done (dicey check; auth can be slow)
+if(! netstat -n | grep -s '^tcp.*Listen.* (7|9|21|22|23|25|110|113|565|993|17007|17009|17010|17013) .*' &&
+    ! ~ $listener yes) {
+	echo -n listen...
+	aux/listen -q &
+	sleep 2
+}
 
 if(! ps|grep -s timesync) {
-	aux/timesync -n pool.ntp.org
-	if (test -e '#r/rtc') @ {
-		sleep 10			# let timesync correct the time
-		awk '{print $1}' /dev/time >'#r/rtc'	# fix hw clock
-	} &
+	echo -n timesync...
+	starttimesync &
+	sleep 2
 }
 
 # cpu-specific late startup
 if(test -e /cfg/$sysname/cpustart)
-	. /cfg/$sysname/cpustart
+	.  /cfg/$sysname/cpustart
+
+# prevent killing specific processes when out of memory.
+# processes started via listen must be killable, so exclude listen.
+dontkill '^(ipconfig|factotum|mntgen|venti|fossil|cs|dns|reboot)$' &
 
-# mode of /proc/*/ctl is inherited across rfork, and sets modes on
-# other /proc files, such as note, so let listen be killed.
-dontkill '^(ipconfig|factotum|mntgen|venti|fossil|cs|dns|reboot)$'
+# log boot and kernel information
+kern=`{ls -ld `{kern}}
+echo $"boottime $sysname $terminal $"kern >>/sys/log/boot
+ls -l /srv/boot | sed -e 's/.* 0 /kernel built: /' -e 's; /srv/boot;;'
+echo $terminal $"kern
+echo -n `{date} ' '; uptime
 
-# echo `{date} $sysname >>/sys/log/boot
+echo collect kmesg...
+kmesg.boot &
 exit ''

+ 51 - 8
rc/bin/cpurc.local

@@ -1,11 +1,54 @@
 #!/bin/rc
-# local cpu startup
+# site-local cpu startup
 
 # used only by upas, as default return domain appended to all unqualified
-# return addresses, even local ones
-site=DOM.EXAMPLE.COM
-# replace FILESERVER with the name of your file server
-# here we start with kfs, your local disk file system
-fileserver=kfs
-# replace FACEDOM with the local domain to be used in the faces database
-facedom=FACEDOM
+# return addresses, even local ones, and as one of the values of \l in rewrite.
+site=collyer.net
+fileserver=cpu
+facedom=astro
+cpu=cpu
+pccpu=fm			# 386 or arm to run gs, aux/pm, etc.
+
+# if no dns server yet, start one
+DNSSERVER=8.8.8.8
+
+# on file servers, configure network and ensure dns is running
+if(~ $sysname fs) {
+	# configure primary network
+	if(test -e /net/ipifc/clone) {
+		if (~ $#ip 1)
+			ip/ipconfig -g $ipgw ether /net/ether0 $ip $ipmask
+		if not
+			ip/ipconfig
+		ipconfiged=done
+	}
+	addroutes
+	if(! test -e /srv/dns && ! test -e /env/dns) {
+		echo -n dns...
+		ndb/dns -rR		# don't answer udp
+		dns=running		# tell cpurc we've already got one
+	}
+}
+
+9fs other >[2]/dev/null &
+
+# load keys into factotum; must be before listens
+# without dd, this takes 10s of seconds on pf
+if (test -r /adm/mailkeys) {
+	echo -n 'factotum mail & tls keys...'
+	dd -quiet 1 </adm/mailkeys -bs 8192 | read -m >>/mnt/factotum/ctl
+}
+echo -n secstore...
+# TODO: shouldn't need this any more, but factotum doesn't get it right
+auth/secstore -s p9auth.collyer.net -n -G factotum >>/mnt/factotum/ctl &
+
+echo -n pie...
+9fs pie &		# make /srv/labs available to export before listens
+
+sleep 2			# wait but don't hang
+
+# ipv6on invokes ip/config 4 times and takes just under 10 seconds
+{ ipv6on; addroutes } &
+
+if (test -e '#w/wdctl')
+	aux/watchdog &

+ 1 - 1
rc/bin/dbcalc

@@ -1,3 +1,3 @@
 #!/bin/rc
 # use db as a pure calculator
-db /dev/null | grep -v ' binary$'
+db /dev/null | grep -vb ' binary$'

+ 7 - 2
rc/bin/diffy

@@ -12,5 +12,10 @@ if(! ~ $#* 1)
 	diffopts=($diffopts -m)
 if (~ $#* 0)
 	* = (.)
-for(f)
-	diff $diffopts `{yesterday $f} $f
+for(f) {
+	dumpdir=`{yesterday $f}
+	if (test -e $dumpdir)
+		diff $diffopts $dumpdir $f
+	if not
+		echo $dumpdir missing >[1=2]
+}

+ 2 - 0
rc/bin/dircp

@@ -1,5 +1,7 @@
 #!/bin/rc
 # dircp src dest - copy a tree with tar
+rfork e
+cdpath=.
 switch($#*){
 case 2
 	@ {builtin cd $1 && tar cif /fd/1 .} | @ {builtin cd $2 && tar xTf /fd/0}

+ 8 - 0
rc/bin/dircpmk

@@ -0,0 +1,8 @@
+#!/bin/rc
+# dircpmk src dst - copy trees with mkfs|mkext
+if (! ~ $#* 2) {
+	echo usage: $0 src dest >[1=2]
+	exit usage
+}
+# mkext -v will verbosely describe extraction
+disk/mkfs -a -s $1 <{echo +} | disk/mkext -ud $2 

+ 22 - 15
rc/bin/diskparts

@@ -4,7 +4,8 @@ rfork e
 if (! test -e /dev/sdctl)
 	bind -b '#S' /dev
 if (~ $#* 0)
-	*=`{ls -d /dev/sd* | uniq}
+	# skip missing drives such as fs's /dev/sdF1
+	* = `{grep -l '^inquiry..' /dev/sd*/ctl | uniq | sed 's;/ctl$;;'}
 
 bind -a /bin/disk /bin >[2]/dev/null		# work with /boot too
 
@@ -14,25 +15,31 @@ bind -a /bin/disk /bin >[2]/dev/null		# work with /boot too
 # block numbers, so we may have to examine the data file with prep if
 # there's no plan9 file.  beware that `disk/prep -p data' on a disk with
 # no plan 9 partition table will delete all extant partitions.
-for(disk) {
-	if(test -f $disk/data && test -f $disk/ctl)
-		{ fdisk -p $disk/data |
-			grep -v '^delpart ' >$disk/ctl } >[2]/dev/null
-	if(test -f $disk/plan9)
-		parts=($disk/plan9*)
-	if not
-		parts=($disk/data)
-	for(part in $parts)
-		if(test -f $part)
-			 { prep -p $part |
-				grep -v '^delpart ' >$disk/ctl } >[2]/dev/null
-}
+for (disk)
+	if (test -f $disk/data && test -f $disk/ctl) {
+		echo -n $disk...
+		ctl=$disk/ctl
+		data=$disk/data
+		{ fdisk -p $data | grep -v '^delpart ' >$ctl } >[2]/dev/null
+		if (test -f $disk/plan9)
+			parts=($disk/plan9*)
+		if not
+			parts=$data
+		for (part in $parts)
+			if(test -f $part) {
+				prep -p $part | grep -v '^delpart ' >$ctl
+			} >[2]/dev/null
+	}
 
 sysname=`{cat /dev/sysname}
 
 # set up any fs(3) partitions
+echo -n fs...
 if (! test -e /dev/fs/ctl && test -e '#k/fs')
 	bind -b '#k' /dev
+# initialize fs only if necessary
 if (~ $#sysname 1 && ! ~ $sysname '' &&
-    test -r /cfg/$sysname/fsconfig && test -w /dev/fs/ctl)
+    test -r /cfg/$sysname/fsconfig && test -w /dev/fs/ctl &&
+    ~ `{wc -l </dev/fs/ctl} 0)
 	read -m /cfg/$sysname/fsconfig >/dev/fs/ctl
+echo

+ 4 - 3
rc/bin/dontkill

@@ -5,7 +5,8 @@ if (! ~ $#* 1) {
 	echo $0 regexp >[1=2]
 	exit usage
 }
-cd /proc
 # see /sys/src/9/port/proc.c:/^killbig
-pids=`{psu | awk '$NF ~ /'$1'/ {print $2}'}
-~ $#pids 0 || chmod -w $pids^/ctl >[2]/dev/null
+rfork e
+procs=`{psu | awk '$NF ~ /'$1'/ {print $2}'}
+if (! ~ $#procs 0)
+	exec chmod -w /proc/^$procs^/ctl >[2]/dev/null

+ 27 - 0
rc/bin/dumpvacroots

@@ -0,0 +1,27 @@
+#!/bin/rc
+# dumpvacroots - dumps all the vac scores ever stored to the venti server
+# if nothing else, this illustrates that you have to control access
+# to the physical disks storing the archive!
+
+ventihttp=`{
+#	echo $venti | sed 's/^[a-z]+!([0-9\.]+)![a-z0-9]+$/\1/
+#		s/^[a-z]+!([0-9\.]+)/\1/; s/$/:8000/'
+	echo $venti | sed 's/^[a-z]+!([0-9\.]+)![a-z0-9]+$/\1/
+		s/^[a-z]+!([0-9\.]+)/\1/'
+}
+
+hget http://$ventihttp:81/index |
+	awk '
+ 		/^index=/ { blockSize = 0 + substr($3, 11) }
+ 		/^arena=/ { arena = substr($1, 7) }
+ 		/^	arena=/ {
+			# anum computation depends on format of arena names
+			anum = substr(arena, 8) + 0
+			if (anum < 1514)	# just process final arenas
+				next
+			start = (0 + substr($5, 2)) - blockSize
+			printf("venti/printarena -o %.0f %s\n", start, $3 "")
+		}
+	' |
+	rc |
+	awk '$3 == 16 { printf("vac:%s\n", $2 "") }'

+ 14 - 0
rc/bin/dumpvacroots.old

@@ -0,0 +1,14 @@
+#!/bin/rc
+rfork e
+# this dumps all the vac scores ever stored to the venti server
+# if nothing else, this illustrates that you have to control access
+# to the physical disks storing the archive!
+
+ventihttp=127.0.0.1:81
+hget http://$ventihttp/index | 
+	awk '
+ /^index=/ { blockSize=0+substr($3, 11); }
+ /^arena=/ { arena=substr($1, 7); }
+ /^	arena=/ { start=0+substr($5, 2)-blockSize; printf("venti/printarena -o %d %s\n", start, $3); }' |
+	rc |
+	sed -n 's/^(.*) 1$/vac:\1/p'

+ 4 - 0
rc/bin/dup

@@ -0,0 +1,4 @@
+#!/bin/rc
+rfork n
+bind -a /bin/aux /bin
+pdup $* | dupstat

+ 10 - 0
rc/bin/dvips

@@ -0,0 +1,10 @@
+#!/bin/rc
+
+if(~ $NEWTEX no) 
+	exec /sys/lib/texmf/bin/$cputype/old.dvips $*
+
+rfork en
+bind -b /sys/lib/texmf/bin/$cputype /bin
+bind -b /sys/lib/texmf/bin/rc /bin
+
+/sys/lib/texmf/bin/$cputype/_dvips $*

+ 35 - 0
rc/bin/editfactotumkeys

@@ -0,0 +1,35 @@
+#!/bin/rc
+
+rfork n
+ramfs
+cd /tmp
+
+switch($#*){
+case 0
+	editor=acme
+case 1
+	editor=$1
+case *
+	echo 'usage: editfactotumkeys [editor]' >[1=2]
+	exit usage
+}
+
+myfactotum=1
+if(! syscall open /mnt/factotum/ctl 2 >[2]/dev/null)
+	myfactotum=0
+
+echo fetching keys...
+if(! auth/secstore -g factotum)
+	exit secstore
+cp factotum factotum.o || exit secstore
+$editor factotum
+if(! cmp factotum factotum.o >[2]/dev/null >/dev/null){
+	sleep 2	# wait for samterm to exit
+	echo 'keys modified; writing back...'
+	auth/secstore -p factotum
+	# why not use read -m here?  no one else uses aux/lines.
+	if(~ $myfactotum 1)
+		aux/lines <factotum >/mnt/factotum/ctl
+}
+if not
+	echo 'keys unchanged.'

+ 210 - 0
rc/bin/fc

@@ -0,0 +1,210 @@
+#!/bin/ape/sh
+# f77-style shell script to compile and load fortran, C, and assembly codes
+#	usage:	f77 [-g] [-O] [-o absfile] [-c] files [-l library]
+#		-o objfile	Override default executable name a.out.
+#		-c		Do not call linker, leave relocatables in *.o.
+#		-C		Check that subscripts are in bounds.
+#		-S		leave assembler output on file.s
+#		-l library	(passed to ld).
+#		-u		complain about undeclared variables
+#		-w		omit all warning messages
+#		-w66		omit Fortran 66 compatibility warning messages
+#		files		FORTRAN source files ending in .f .
+#				FORTRAN with cpp preprocessor directives
+#					ending in .F .
+#				C source files ending in .c .
+#				Assembly language files ending in .s .
+#				efl source files ending in .e .
+#				RATFOR files ending in .r .
+#		-D def		passed to C compiler (for .c files)
+#		-I includepath	passed to C compiler (for .c files)
+#		-Ntnnn		allow nnn entries in table t
+
+eval `grep -v '^/bin/sh' /bin/ape/psh`
+
+s=/tmp/stderr_$$
+t=/tmp/f77_$$.o
+CC=${CC_f2c:-'cc'}
+EFL=${EFL:-efl}
+EFLFLAGS=${EFLFLAGS:-'system=portable deltastno=10'}
+RATFOR=${RATFOR:-ratfor}
+RFLAGS=${RFLAGS:-'-6& -C'}
+F2C=${F2C:-f2c}
+F2CFLAGS=${F2CFLAGS:='-ARw8 -Nn802'}
+CPP=${CPP:-cpp}
+rc=0
+trap "rm -f $s $t; exit \$rc" 0
+lib=/usr/geoff/lib/$objtype
+OUTF=a.out
+cOPT=1
+set -- `getopt cCD:gI:N:Oo:Suw6 "$@"`
+case $? in
+0)	;;
+*)	exit 1;;
+esac
+CCFLAGS=
+while
+	test X"$1" != X--
+do
+	case "$1"
+	in
+	-C)	F2CFLAGS="$F2CFLAGS -C"
+		shift;;
+
+	-c)	cOPT=0
+		shift
+		;;
+
+	-D)	CCFLAGS="$CCFLAGS -D$2"
+		shift 2
+		;;
+
+	-g)	CFLAGS="$CFLAGS -g"
+		CCFLAGS="$CCFLAGS -g"
+		F2CFLAGS="$F2CFLAGS -g"
+		shift;;
+
+	-I)	CCFLAGS="$CCFLAGS -I$2"
+		shift 2
+		;;
+
+	-o)	OUTF=$2
+		shift 2
+		;;
+
+	-O)	case $2 in -1) O=-O1;; -2) O=-O2;; -3) O=-O3;; *) O=-O;; esac
+		case $O in -O);; *) shift;; esac
+		# lcc ignores -O...
+		shift
+		;;
+
+	-u)	F2CFLAGS="$F2CFLAGS -u"
+		shift
+		;;
+
+	-w)	F2CFLAGS="$F2CFLAGS -w"
+		case $2 in -6) F2CFLAGS="$F2CFLAGS"66; shift
+			case $2 in -6) shift;; esac;; esac
+		shift
+		;;
+
+	-N)	F2CFLAGS="$F2CFLAGS $1""$2"
+		shift 2
+		;;
+
+	-S)	CFLAGS="$CFLAGS -S"
+		cOPT=0
+		shift
+		;;
+
+	*)
+		echo "invalid parameter $1" 1>&2
+		shift
+		;;
+	esac
+done
+shift
+while
+	test -n "$1"
+do
+	case "$1"
+	in
+	*.[fF])
+		case "$1" in *.f) f=".f";; *.F) f=".F";; esac
+		case "$1" in
+			*.f)	b=`basename $1 .f`
+				$F2C $F2CFLAGS $1
+				rc=$?
+				;;
+			*.F)	b=`basename $1 .F`
+				$CPP $1 >$b.i
+				rc=$?
+				case $rc in 0)
+					$F2C $F2CFLAGS <$b.i >$b.c
+					rc=$?
+					;;esac
+				rm $b.i
+				;;
+			esac
+		case $rc in 0);; *) exit $rc;; esac
+                $CC -c $CFLAGS $b.c 2>$s
+		rc=$?
+		sed '/parameter .* is not referenced/d;/warning: too many parameters/d' $s 1>&2
+		case $rc in 0);; *) exit;; esac
+		OFILES="$OFILES $b.o"
+		rm $b.c
+		case $cOPT in 1) cOPT=2;; esac
+		shift
+		;;
+	*.e)
+		b=`basename $1 .e`
+		$EFL $EFLFLAGS $1 >$b.f
+		case $? in 0);; *) exit;; esac
+		$F2C $F2CFLAGS $b.f
+		case $? in 0);; *) exit;; esac
+                $CC -c $CFLAGS $b.c
+		case $? in 0);; *) exit;; esac
+		OFILES="$OFILES $b.o"
+		rm $b.[cf]
+		case $cOPT in 1) cOPT=2;; esac
+		shift
+		;;
+	*.r)
+		b=`basename $1 .r`
+		$RATFOR $RFLAGS $1 >$b.f
+		case $? in 0);; *) exit;; esac
+		$F2C $F2CFLAGS $b.f
+		case $? in 0);; *) exit;; esac
+		$CC -c $CFLAGS $b.c
+		case $? in 0);; *) exit;; esac
+		OFILES="$OFILES $b.o"
+		rm $b.[cf]
+		case $cOPT in 1) cOPT=2;; esac
+		shift
+		;;
+	*.s)
+		echo $1: 1>&2
+		OFILE=`basename $1 .s`.o
+		${AS:-/usr/bin/as} -o $OFILE $AFLAGS $1
+		case $? in 0);; *) exit;; esac
+		OFILES="$OFILES $OFILE"
+		case $cOPT in 1) cOPT=2;; esac
+		shift
+		;;
+	*.c)
+		echo $1: 1>&2
+		OFILE=`basename $1 .c`.o
+                $CC -c $CFLAGS $CCFLAGS $1
+		rc=$?; case $rc in 0);; *) exit;; esac
+		OFILES="$OFILES $OFILE"
+		case $cOPT in 1) cOPT=2;; esac
+		shift
+		;;
+	*.o)
+		OFILES="$OFILES $1"
+		case $cOPT in 1) cOPT=2;; esac
+		shift
+		;;
+	-l)
+		OFILES="$OFILES -l$2"
+		shift 2
+		case $cOPT in 1) cOPT=2;; esac
+		;;
+	-l*)
+		OFILES="$OFILES $1"
+		shift
+		case $cOPT in 1) cOPT=2;; esac
+		;;
+	-o)
+		OUTF=$2; shift 2;;
+	*)
+		OFILES="$OFILES $1"
+		shift
+		case $cOPT in 1) cOPT=2;; esac
+		;;
+	esac
+done
+
+case $cOPT in 2) $CC -o $OUTF -u MAIN__ $OFILES -lF77 -lI77 -lm;; esac
+rc=$?
+exit $rc

+ 69 - 0
rc/bin/findviaduct

@@ -0,0 +1,69 @@
+#!/bin/rc
+# findviaduct ip - map ip to viaduct and user
+# findviaduct -n viaduct - print bridge & tunnel info for viaduct
+#
+# findviaduct -r ip ether - run ip mapping on a vespine
+# findviaduct -g name - run -n on a vespine
+rfork en
+vespines=(vespine vespine2)
+bind -a '#B' /dev >[2]/dev/null
+
+switch($1){
+case -r
+	ip=$2
+	ether=$3
+#	echo; echo on $sysname:
+
+	cd /dev/bridge0
+	bridge=`{grep $ether cache | sed 's/^[^ ]* *([^ ]*).*/\1/'}
+	if (~ $bridge ''){
+		echo no bridge device associated with $ether
+		exit no-bridge
+	}
+	x=`{cat $bridge/status}
+	switch($x){
+	case tunnel*
+		viaduct=`{echo $x | sed 's/^[^ ]* *([^:]*).*/\1/'}
+	case *
+		# no viaduct associated with $ether on this machine
+		exit no-viaduct
+	}
+	echo -n ip $ip ether $ether $sysname bridge $bridge $viaduct ''
+
+	grep $viaduct^'[	 ]' /adm/brickdb/owners |
+		sed 's/^[a-z0-9]+[	 ]+//'
+case -g
+	name=$2
+	cd /dev/bridge0
+	{
+		for(i in [0-9]*){
+			echo -n $sysname /dev/bridge0/$i ' '
+			cat $i/status
+		}
+	} | grep $name:
+
+case -n
+	name=$2
+	for (v in $vespines)
+		rx $v findviaduct -g $name
+case *
+	ip=$1
+	ippat=`{echo $ip | sed 's/\./\\./g'}
+
+	# find ether address.  would it be better to do this with dhcpleases?
+	ether=`{
+		tail -r -n 100000 /sys/log/ipboot |
+		grep -b 'Request.*[^0-9]'^$ippat^'[^0-9].*id\((id|hwa)01' |
+		sed 1q |
+		sed 's/.*id\((id|hwa)01_?([^)]*)\).*/\2/' |
+		sed 1q
+	}
+	if (~ $ether ''){
+		echo $1 not in /sys/log/ipboot
+		exit ip-not-in-ipboot
+	}
+#	echo ip $ip ether $ether
+
+	for (v in $vespines)
+		rx $v findviaduct -r $ip $ether
+}

+ 12 - 14
rc/bin/fshalt

@@ -4,10 +4,9 @@
 rfork nes
 kern=()
 kerncopy=()
-loadkern=yes
 reboot=no
 fn usage {
-	echo usage: $1 '[-r] [-R] [new-kernel]' >[1=2]
+	echo usage: $1 '[-r] [new-kernel]' >[1=2]
 	exit usage
 }
 if (! ~ $#* 0)
@@ -15,10 +14,6 @@ if (! ~ $#* 0)
 	case -r
 		reboot=yes
 		shift
-	case -R
-		loadkern=no
-		reboot=yes
-		shift
 	case -*
 		usage $0
 	}
@@ -26,6 +21,8 @@ switch ($#*) {
 case 0
 case 1
 	kern = $1
+	if (! test -e $kern)
+		echo $0: caution: no $kern >[1=2]
 case *
 	usage $0
 }
@@ -53,13 +50,12 @@ fn isbootable {
 		*' plan 9 executable'* *ELF*' executable'
 }
 fn usekernel {
-	kerncopy=kern
-	cp $1 /tmp/$kerncopy && echo -n using kernel $1...
+	cp $1 /tmp && echo -n using kernel $1...
+	kerncopy=`{basename $1}
 }
 
 # make a copy of the right kernel
-if (~ $reboot yes)
-if (~ $loadkern yes) {
+if (~ $reboot yes) {
 	if (~ $#kern 0)
 		kern=`{echo $terminal |
 			sed 's;^([^ ]+) .*/([^/ ]+).*$;/n/boot/'$cputype'/9\2;'}
@@ -86,7 +82,8 @@ kill watchdog | rc
 sleep 1
 
 f=`{ls /srv/fscons*>[2]/dev/null}
-k=`{ls /srv/kfs*cmd >[2]/dev/null|sort -r}
+# k=`{ls /srv/kfs*cmd >[2]/dev/null|sort -r}
+k=()
 
 echo -n syncing...
 for(i in $f) @ {
@@ -96,7 +93,7 @@ for(i in $f) @ {
 		dial/drain &
 		sleep 2
 		echo fsys all sync
-		if(! dial/expect -t 120 ': ')
+		if(! dial/expect -t 060 ': ')
 			echo -n 'not synced...' > /dev/cons
 	} < $i >> $i
 }
@@ -122,7 +119,8 @@ for (i in $k){
 
 # halting (binaries we run can't be on the fs we're halting)
 builtin cd /bin
-cp dial/expect echo disk/kfscmd rc sed /tmp
+cp dial/expect echo rc sed /tmp
+# cp disk/kfscmd /tmp
 builtin cd /tmp
 mkdir /tmp/lib
 cp /rc/lib/rcmain /tmp/lib
@@ -154,7 +152,7 @@ fn x {
 		}
 	}
 	echo
-	echo done halting
+	echo done halting fs
 
 	if (~ $reboot yes)
 		echo reboot $kerncopy >'#c/reboot'

+ 26 - 0
rc/bin/g

@@ -0,0 +1,26 @@
+#!/bin/rc
+# g - grep sources
+rfork e
+args=()
+while(! ~ $#* 0 1 && ~ $1 -*) {
+	args=($args $1)
+	shift
+}
+
+if(~ $#* 0) {
+	echo usage: $0 '[grep-opt]... [file]...' >[1=2]
+	exit usage
+}
+if(~ $#* 1)
+	exec grep -n $args -e $1 *.[chsy] /dev/null >[2]/dev/null
+if not {
+	args=($args -e $1)
+	shift
+	for(arg in $*){
+		if(test -d $arg)
+			args = ($args $arg/*.[chsy])
+		if not
+			args = ($args $arg)
+	}
+	exec grep -n $args /dev/null >[2]/dev/null
+}

+ 18 - 0
rc/bin/health

@@ -0,0 +1,18 @@
+#!/bin/rc
+# health [system ...] - report systems' ill-health
+rfork en
+sts=''
+if (~ $#* 0)
+	* = (fs cpu consoles fm ts apu)	# xtc mips
+
+for (sys) {
+	{
+		if (! ip/ping -q -i 250 -n 15 $sys) {
+			echo $sys down
+#			sts = $sts^' '^$sys^' down'
+		}
+	} &
+}
+# exit $sts
+wait
+# tail -1 /sys/log/cron

+ 24 - 0
rc/bin/importsrv

@@ -0,0 +1,24 @@
+#!/bin/rc
+# importsrv system [mntpt] - import but first look for /srv file to mount.
+#	be careful about exit status so we can invoke this from mkfiles.
+rfork e
+switch ($#*) {
+case 2
+	mntpt=$2
+case 1
+	mntpt=/n/$1
+case *
+	echo usage: $0 system >[1=2]
+	exit usage
+}
+sys=$1
+srv=`{echo $sys.$user | sed 's/^tcp!//'}
+
+#if (test -e $mntpt/adm)		# unsafe optimisation
+#	exit ''
+mount -cC /srv/$srv $mntpt >[2]/dev/null
+if (~ $status '')
+	exit ''
+rm -f /srv/$srv
+# permissions don't work right via srv, thus use import
+import -s $srv $sys / $mntpt && mount -cC /srv/$srv $mntpt

+ 15 - 0
rc/bin/include

@@ -0,0 +1,15 @@
+#!/bin/rc
+# general include processor.  lines starting "include file" read "file".
+# the $0 recursion is a bit subtle.
+# requires an awk that invokes rc for system().
+exec awk 'BEGIN { me = "'$0'" }
+$1 == "include" && NF == 2 {
+	r = system("if (! test -e " $2 ") exit missing; " me " " $2)
+	if (r) {
+		print $2 " missing" >"/dev/stderr"
+		exit 1
+	}
+	next
+}
+	{ print }' $*
+

+ 79 - 0
rc/bin/ipconf/bsr

@@ -0,0 +1,79 @@
+#!/bin/rc
+
+fn initfn {
+	dial/drain
+	dial/at '' e1
+}
+
+fn dialfn {
+	dial/drain
+	dial/at 'd*99***1#'
+}
+
+# process options
+for(i in $*){
+	switch($i){
+	case '-P'
+		primary=-P
+	}
+}
+
+# the following can be inherited
+switch($dev){
+case ''
+	dev=/dev/eia1
+}
+switch($baud){
+case ''
+	baud=115200
+}
+
+{
+	# set up uart
+	if( test -e $dev^ctl ){
+		echo -n b^$baud	# baud rate
+		echo -n m1	# cts/rts flow control
+		echo -n q64000	# big buffer
+		echo -n n1	# nonblocking writes
+		echo -n r1	# rts on
+		echo -n d1	# dtr on
+		echo -n c1	# handup wen we lose dcd
+		echo -n w10	# 1ms wait time
+	} > $dev^ctl
+
+	# get the modem's attention
+	while( ! initfn )
+		sleep 1
+
+	# dial
+	while( ! dialfn )
+		sleep 30
+		
+	echo connected to PPP >[1=2]
+
+	# start ppp
+	bind '#I1' /net.alt
+	ip/ppp -P -fx /net.alt
+} < $dev > $dev
+
+# supply unknowns with inside addresses
+if( ! grep -s 'auth=' /net.alt/ndb){
+	echo '	auth=204.178.31.2'>>/net.alt/ndb
+	echo '	authdom=cs.bell-labs.com'>>/net.alt/ndb
+}
+if( ! grep -s 'ntp=' /net.alt/ndb)
+	echo '	ntp=204.178.31.2'>>/net.alt/ndb
+if( ! grep -s 'dns=' /net.alt/ndb){
+	echo '	dns=204.178.31.3'>>/net.alt/ndb
+	echo '	dns=204.178.31.4'>>/net.alt/ndb
+}
+
+# start cs if it isn't already going
+if(! test -e /srv/cs_net.alt )
+	ndb/cs -rx /net.alt -f /lib/ndb/external
+if not mount -a /srv/cs_net.alt /net.alt
+
+# start dns if it isn't already going
+if(! test -e /srv/dns_net.alt )
+	ndb/dns -rx /net.alt -f /lib/ndb/external
+if not mount -a /srv/dns_net.alt /net.alt

+ 86 - 0
rc/bin/ipconf/tmobile

@@ -0,0 +1,86 @@
+#!/bin/rc
+
+fn initfn {
+	dial/drain
+	dial/at '' e1
+}
+
+fn dialfn {
+	dial/drain
+	dial/at e1 +cgmm +cgmr +cgsn
+	echo -n 'at+cpin?
'
+	if(! dial/expect -t 5 READY OK)
+		dial/at '+cpin='$pin
+	dial/at '+cgdcont=1,"IP","internet3.voicestream.com",,0,0' e0 'd*99***1#'
+}
+
+# process options
+for(i in $*){
+	switch($i){
+	case '-P'
+		primary=-P
+	}
+}
+
+# the following can be inherited
+switch($dev){
+case ''
+	dev=/dev/eia1
+}
+switch($pin){
+case ''
+	pin=230596
+}
+switch($baud){
+case ''
+	baud=57600
+}
+
+{
+	# set up uart
+	if( test -e $dev^ctl ){
+		echo -n b^$baud	# baud rate
+		echo -n m1	# cts/rts flow control
+		echo -n q64000	# big buffer
+		echo -n n1	# nonblocking writes
+		echo -n r1	# rts on
+		echo -n d1	# dtr on
+		echo -n c1	# handup wen we lose dcd
+	} > $dev^ctl
+
+	# get the modem's attention
+	while( ! initfn )
+		sleep 1
+
+	# dial
+	while( ! dialfn )
+		sleep 30
+		
+	echo connected to T-Mobile >[1=2]
+
+	# start ppp
+	bind '#I1' /net.alt
+	ip/ppp -s iStream:dummy -P -fx /net.alt
+} < $dev > $dev
+
+# supply unknowns with inside addresses
+if( ! grep -s 'auth=' /net.alt/ndb){
+	echo '	auth=204.178.31.2'>>/net.alt/ndb
+	echo '	authdom=cs.bell-labs.com'>>/net.alt/ndb
+}
+if( ! grep -s 'ntp=' /net.alt/ndb)
+	echo '	ntp=204.178.31.2'>>/net.alt/ndb
+if( ! grep -s 'dns=' /net.alt/ndb){
+	echo '	dns=204.178.31.3'>>/net.alt/ndb
+	echo '	dns=204.178.31.4'>>/net.alt/ndb
+}
+
+# start cs if it isn't already going
+if(! test -e /srv/cs_net.alt )
+	ndb/cs -rx /net.alt -f /lib/ndb/external
+if not mount -a /srv/cs_net.alt /net.alt
+
+# start dns if it isn't already going
+if(! test -e /srv/dns_net.alt )
+	ndb/dns -rx /net.alt -f /lib/ndb/external
+if not mount -a /srv/dns_net.alt /net.alt

+ 72 - 0
rc/bin/ipconf/verizon

@@ -0,0 +1,72 @@
+#!/bin/rc
+
+fn initfn {
+	dial/drain
+	dial/at -q H		# hangup
+	dial/at -q E0V1		# wordy dialog
+	dial/at -q '+IFC=2,2'	# hardware flow control
+	dial/at -q 'S0=0'	# default timeouts
+}
+
+fn dialfn {
+	dial/drain
+	dial/at 'd#19788'	# dial the universal verizon number
+}
+
+# the following can be inherited
+switch($dev){
+case ''
+	dev=/dev/eia1
+}
+switch($baud){
+case ''
+	baud=115200
+}
+
+{
+	# set up uart
+	if( test -e $dev^ctl ){
+		echo d1		# turn on dtr
+		echo m1		# enable hardware flow control
+		echo q64000	# increase buffer sizes to serial line
+		echo b^$baud	# set baud rate
+		echo n1		# non-blocking writes
+		echo c1		# hangup when we lose dcd
+	} > $dev^ctl
+
+	# get the modem's attention
+	while( ! initfn )
+		sleep 1
+
+	# dial
+	while( ! dialfn )
+		sleep 30
+		
+	echo connected to Verizon >[1=2]
+
+	# start ppp
+	bind '#I1' /net.alt
+	ip/ppp -s 9082296596@vzw3g.com:vzw -P -fx /net.alt
+} < $dev > $dev
+
+# supply unknowns with inside addresses
+if( ! grep -s 'auth=' /net.alt/ndb){
+	echo '	auth=204.178.31.2'>>/net.alt/ndb
+	echo '	authdom=cs.bell-labs.com'>>/net.alt/ndb
+}
+if( ! grep -s 'ntp=' /net.alt/ndb)
+	echo '	ntp=204.178.31.2'>>/net.alt/ndb
+if( ! grep -s 'dns=' /net.alt/ndb){
+	echo '	dns=204.178.31.3'>>/net.alt/ndb
+	echo '	dns=204.178.31.4'>>/net.alt/ndb
+}
+
+# start cs if it isn't already going
+if(! test -e /srv/cs_net.alt )
+	ndb/cs -rx /net.alt -f /lib/ndb/external
+if not mount -a /srv/cs_net.alt /net.alt
+
+# start dns if it isn't already going
+if(! test -e /srv/dns_net.alt )
+	ndb/dns -rx /net.alt -f /lib/ndb/external
+if not mount -a /srv/dns_net.alt /net.alt

+ 42 - 0
rc/bin/ipon

@@ -0,0 +1,42 @@
+#!/bin/rc
+# ipon [-g gwv4] ipv4 mask [netdir etherno ndbroot] - enable IP on netdir &
+#	ether-and-ip-stack-no with address ipv4 & optional ipv4 gateway gwv4
+rfork e
+fn usage {
+	echo usage: ipon '[-g gwv4] ipv4 mask [netdir ether&stack-no [ndbroot]]' >[1=2]
+	exit usage
+}
+switch ($1) {
+case -g
+	gw=(-g $2)
+	shift 2
+case -*
+	usage
+}
+switch ($#*) {
+case 2
+	netdir=/net
+	etherno=0
+	ndbroot=/lib/ndb/local
+case 4
+	netdir=$3
+	etherno=$4
+case 5
+	netdir=$3
+	etherno=$4
+	ndbroot=$5
+case *
+	usage
+}
+ipv4=$1
+mask=$2
+
+bind -b '#l'$etherno $netdir
+bind -b '#I'$etherno $netdir
+ip/ipconfig -x $netdir $gw ether $netdir/ether$etherno $ipv4 $mask
+if (~ $#ndbroot 1) {
+	ndb/cs	    -x $netdir -f $ndbroot
+	ndb/dns -r  -x $netdir -f $ndbroot
+}
+if not
+	exit ''

+ 6 - 4
rc/bin/ipv6on

@@ -43,12 +43,14 @@ fn nonnil {		# variable
 # configure v6 for link-local addresses (fe80::) & multicast (ff02::).
 # accept router advertisements, which will contain a default route.
 #
-if (! ip/ipconfig -6 $xdir ether $netdir/ether?)
+ether=`{ls -d $netdir/ether? | sed 1q}
+if (! ip/ipconfig -6 $xdir ether $ether)
 	exit 'ipconfig -6 failed'
-ip/ipconfig $xdir ether $netdir/ether? ra6 recvra 1
+ip/ipconfig $xdir ether $ether ra6 recvra 1
 
 # lookup any v6 address for me in ndb, else use slaac
-myeth=`{cat $netdir/ether?/addr}
+addr=`{ls $ether/addr | sed 1q}
+myeth=`{cat $addr}
 mev6=`{ndb/query -f $ndbf ether $myeth ipv6}
 if (~ $#mev6 0 || ~ $mev6 '')
 	mev6=`{ndb/query -f $ndbf sys $sysname ipv6}
@@ -68,5 +70,5 @@ nonnil mev6
 # configure my global v6 addresses
 #
 v6mask=`{ipq ip $mev6 ipmask}
-ip/ipconfig $xdir ether $netdir/ether?	add $mev6 $v6mask
+ip/ipconfig $xdir ether $ether	add $mev6 $v6mask
 ip/ipconfig $xdir loopback /dev/null	add $mev6 /128

+ 94 - 0
rc/bin/ipv6on.v4v6

@@ -0,0 +1,94 @@
+#!/bin/rc
+# ipv6on [netdir ndbfile [gwv4]] - configure an interface for v6,
+#	once v4 is configured.  assumes v6 sysnames and dom names end in `v6',
+#	and v4 sysnames and dom names end in `v4'.
+if (! ~ $#* 0 2 3) {
+	echo usage: $0 '[netdir ndbfile [gw-v4-name]]' >[1=2]
+	exit usage
+}
+rfork e
+if (~ $#* 0) {
+	netdir=/net
+	ndbf=/lib/ndb/local
+	gw=`{ndb/ipquery sys $sysname ipgw | sed 's/ipgw=//'}
+}
+if not {
+	netdir=$1
+	ndbf=$2
+	if (~ $#* 2)
+		# gw=()
+		gw=`{ndb/ipquery sys $sysname ipgw | sed 's/ipgw=//'}
+	if not
+		gw=$3
+}
+if (~ $netdir /net) {
+	xsfx=()
+	xdir=()
+}
+if not {
+	xsfx=(-x `{echo $netdir | sed 's;^/net;;'})
+	xdir=(-x $netdir)
+}
+
+fn nonnil {	# name ip
+	if (~ $#2 0) {
+		echo no ip for $1
+		exit no-ip
+	}
+}
+fn column {	# column
+	awk '{print $'^$1^'}'
+}
+
+# configure v6 for link-local addresses (fe80::) & multicast (ff02::)
+if (! ip/ipconfig -6 $xdir ether $netdir/ether?)
+	exit 'ipconfig -6 failed'
+ip/ipconfig ra6 recvra 1
+
+mev6=`{ndb/query -f $ndbf sys $sysname^v6 ip}
+mev4=`{ndb/query -f $ndbf sys $sysname^v4 ip}
+if (~ $#mev6 0 || ~ $mev6 '')			# assume name and namev4
+	mev6=`{ndb/query -f $ndbf sys $sysname ipv6}
+if (~ $#mev4 0 || ~ $mev4 '')			# assume namev6 and name
+	mev4=`{ndb/query -f $ndbf sys $sysname ip}
+
+# for testing
+mylnk=`{ip/linklocal `{cat $netdir/ether?/addr}}
+nonnil mylnk $mylnk
+
+if (~ $#gw 1) {
+	if (~ $gw [0-9]*.[0-9]*.[0-9]*.[0-9]*)
+		gwv4 = $gw
+	if not
+		gwv4=`{ndb/query -f $ndbf sys $gw^v4 ip}
+	if (~ $#gwv4 0 || ~ $gwv4 '')		# assume namev6 and name
+		gwv4=`{ndb/query -f $ndbf sys $gw ip}
+	gwv6=`{ndb/query -f $ndbf sys $gw^v6 ip}
+	if (~ $#gwv6 0 || ~ $gwv6 '')		# assume name and namev4
+		gwv6=`{ndb/query -f $ndbf sys $gw ipv6}
+
+	if (! ~ $#gwv4 0) {
+		echo ping gw $gwv4...
+		# load arp cache
+		ip/ping -qn 3 $netdir/icmp!$gwv4 >/dev/null >[2=1] &
+		sleep 3					# wait for ping
+
+		gweth=`{grep '* '^$gwv4^' ' $netdir/arp | column 4}
+		nonnil gweth $gweth
+		gwlnk=`{ip/linklocal $gweth}
+		nonnil gwlnk $gwlnk
+	}
+}
+nonnil mev6 $mev6
+# configure my global v6 addresses
+ip/ipconfig $xdir ether $netdir/ether? add $mev6 /64
+ip/ipconfig $xdir loopback /dev/null add $mev6 /128
+
+if (~ $#gw 1) {
+	if (~ $#gwv6 0 || ~ $gwv6 '')
+		gwv6=`{ip/linklocal $gweth}
+	nonnil gwv6 $gwv6
+	# add default v6 route to v6 addr of v4 gw
+	echo add :: /0 $gwv6 >$netdir/iproute	# need not be link-local
+}
+exit ''

+ 32 - 19
rc/bin/juke

@@ -9,12 +9,12 @@ host=''
 kb=4096
 flags=()
 sname=$user
-if (! ~ $wide 1) {
+if(! ~ $wide 1){
 	flags=($flags -t)
 	kb=1024
 }
-while(! ~ $#* 0) {
-	switch ($1) {
+while(! ~ $#* 0){
+	switch($1){
 	case -d
 		debug=$2
 		shift
@@ -22,10 +22,13 @@ while(! ~ $#* 0) {
 		tflag='-t'
 	case -h
 		host=$2
+		if(! ~ $snameset yes)
+			sname=$2
 		shift
 	case -w
-		wflags='-w'
+		wflag='-w'
 	case -s
+		snameset=yes
 		sname=$2
 		shift
 	case -*
@@ -34,27 +37,37 @@ while(! ~ $#* 0) {
 	}
 	shift
 }
-if (! test -e /mnt/playlist){
-	if (! ~ $debug '0') echo mounting playlistfs
-	if (! test -e /srv/playlist.$sname && ! ~ $host ''){
-		import -a $host /srv /srv
-	}
-	if (! mount -b /srv/playlist.$sname /mnt >/dev/null >[2]/dev/null){
-		rm -f /srv/playlist.$sname
+if(! test -e /mnt/playlist){
+	if(! ~ $debug 0) echo mounting playlistfs
+	if(~ $sname linux){
+		rm -f /srv/playlist.$sname.$user
 		if (! ~ $debug '0') echo starting playlistfs
-		games/playlistfs -s $sname -d $debug
+		games/playlistfs -s $sname.$user -d $debug
+	}
+	if not {
+		if (! test -e /srv/playlist.$sname && ! ~ $host ''){
+			if (! ~ $debug '0') echo import srv from $host
+			import -a $host /srv /srv
+		}
+		if (! ~ $debug '0') echo mount /srv/playlist.$sname
+		if (! mount -b /srv/playlist.$sname /mnt >/dev/null >[2]/dev/null){
+			rm -f /srv/playlist.$sname
+			if (! ~ $debug '0') echo starting playlistfs
+			games/playlistfs -s $sname -d $debug
+		}
 	}
 }
 if (! test -w /mnt/juke) {
-	if (! test -e /srv/jukefs.$sname && ! ~ $host ''){
+	if (! test -e /srv/jukefs.$host && ! ~ $host ''){
+		if (! ~ $debug '0') echo import srv from $host
 		import -a $host /srv /srv
 	}
-	if (! mount -b /srv/jukefs.$sname /mnt >/dev/null >[2]/dev/null){
+	if (! ~ $debug '0') echo mount /srv/jukefs.$user
+	if (! mount -b /srv/jukefs.$user /mnt >/dev/null >[2]/dev/null){
+	    if (! mount -b /srv/jukefs.$host /mnt >/dev/null >[2]/dev/null){
 		if (! ~ $debug '0') echo games/jukefs
-		games/jukefs -s $sname
+		games/jukefs -s $user
+	    }
 	}
 }
-if (~ $wflags '-w') {
-	exec games/jukebox -w -d $debug $tflag &
-}
-exec games/jukebox -d $debug $tflag
+exec games/jukebox $wflag -d $debug $tflag

+ 19 - 0
rc/bin/kern

@@ -0,0 +1,19 @@
+#!/bin/rc
+# kern - print path name of running kernel
+rfork e
+kern=`{sed 's/.*!//' /env/bootfile >[2]/dev/null}
+cpu=`{echo $kern | sed 's;/([^/]+)/.*;\1;'}
+base = `{echo $terminal | sed 's/.* //'}
+if (! ~ $cpu $cputype) {
+	echo $0: implausible bootfile kernel $kern for cputype $cputype >[1=2]
+	kern = $base
+}
+switch ($kern) {
+case /sys/src/9*/* ''
+	kern=/$cputype/9^`{basename $base}
+case /*
+	;
+case *
+	kern=/$cputype/$kern
+}
+echo $kern

+ 2 - 0
rc/bin/kickventiindex

@@ -0,0 +1,2 @@
+#!/bin/rc
+exec hget http://127.1:81/kickicache

+ 5 - 0
rc/bin/killnetalt

@@ -0,0 +1,5 @@
+#!/bin/rc
+# killnetalt - emit commands to kill all processes with fd's to /net.alt
+grep /net.alt /proc/*/fd |
+	sed 's^/proc/(.*)/fd.*^chmod +rw /proc/\1/ctl; echo kill >/proc/\1/ctl^' |
+	sort -u

+ 8 - 0
rc/bin/killtcpport

@@ -0,0 +1,8 @@
+#!/bin/rc
+# killtcpport port - emit commands to kill processes with remote tcp port open
+rfork e
+port=$1
+for(i in `{grep '!'$port'$' /net/tcp/*/remote | sed s'/(.*\/)remote.*/\1/'})
+	grep $i /proc/*/fd |
+		sed 's^/proc/(.*)/fd.*^chmod +rw /proc/\1/ctl; echo kill >/proc/\1/ctl^' |
+		sort -u

+ 16 - 0
rc/bin/kmesg.boot

@@ -0,0 +1,16 @@
+#!/bin/rc
+# gather /dev/kmesg contents since boot into /sys/log/kmesg
+
+cd /sys/log/kmesg
+cp /dev/kmesg $sysname.temp
+{
+	echo; echo; date
+	if (grep -s '^Plan 9($| )' $sysname.temp) {
+		echo '?^Plan 9($| )?,$p' | ed - $sysname.temp
+	}
+	if not
+		tail -50 $sysname.temp
+	echo
+	cat /dev/swap
+} >>$sysname
+rm -f $sysname.temp

+ 3 - 0
rc/bin/lastdumpvac

@@ -0,0 +1,3 @@
+#!/bin/rc
+9fs log
+grep 'archive vac:' /sys/log/fs | tail -1 | sed 's/.*vac://'

+ 10 - 0
rc/bin/latex

@@ -0,0 +1,10 @@
+#!/bin/rc
+
+if(~ $NEWTEX no)
+	exec /sys/lib/tex/bin/$cputype/virtex '&latex386' $*
+
+rfork en
+bind -b /sys/lib/texmf/bin/$cputype /bin
+bind -b /sys/lib/texmf/bin/rc /bin
+
+/sys/lib/texmf/bin/$cputype/_tex '&'latex.`{endian} $*

+ 11 - 0
rc/bin/loadcfgpxe

@@ -0,0 +1,11 @@
+#!/bin/rc
+# loadcfgpxe - turn /cfg/pxe/$myether into rc variable assignments, execute them
+myeth=`{ndb/query sys $sysname ether}
+if (! ~ $#myeth 0) {
+	pxefile=/cfg/pxe/$myeth(1)
+	if (test -e $pxefile) {
+		# in case we booted directly, without 9boot
+		eval `{sed -e '/^#/d' -e '/=([^'']|$)/s/=(.*)/=''\1''/' $pxefile}
+		'*envloaded'=1
+	}
+}

+ 2 - 1
rc/bin/lookman

@@ -31,6 +31,7 @@ for(i in $*){
 		' > $t2
 	mv $t2 $t1
 }
-sort $t1 | sed 's;/sys/man/;;
+# use /.*/man instead of /sys/man to allow private manual trees
+sort $t1 | sed 's;/.*/man/;;
 	s;(.*)/(.*);man \1 \2 # \2(\1);'
 exit ''

+ 2 - 0
rc/bin/lunzip

@@ -0,0 +1,2 @@
+#!/bin/rc
+exec lzip -d $*

+ 31 - 0
rc/bin/mailcmd

@@ -0,0 +1,31 @@
+#!/bin/rc
+# mailcmd [-m addr] cmd [arg] ... - run cmd with args; if it fails, send mail
+rfork ne
+ifs='
+'
+mailto=()
+while(~ $1 -m*){
+	if(~ $1 -m){
+		mailto=($mailto $2)
+		shift
+		shift
+	}
+	if not{
+		mailto=($mailto `{echo $1 | sed 's/-m//'})
+		shift
+	}
+}
+if(~ $#mailto 0)
+	mailto=(`{cat /dev/user})
+
+if(~ $#* 0){
+	echo 'usage: mailcmd [-m addr] ''cmd''' >[1=2]
+	exit usage
+}
+
+sysname=`{cat /dev/sysname}
+sysname=$"sysname
+ifs=()
+rc -c $"* >/tmp/mailcmd.$pid >[2=1] ||
+	mail -s $sysname': '$"* $mailto </tmp/mailcmd.$pid
+rm /tmp/mailcmd.$pid

+ 4 - 2
rc/bin/man

@@ -60,7 +60,7 @@ search=yes
 while(~ $d 0) {
 	if(~ $#* 0) {
 		echo 'Usage: man [-bntpPSw] [0-9] [0-9] ... name1 name2 ...' >[1=2]
-		exit
+		exit usage
 	}
 	if(test -d $S/$1){
 		sec=($sec $1)
@@ -88,11 +88,12 @@ fils=()
 if(~ $search yes)
 for(i in $S/$sec){
 	if(/bin/test -f $i/INDEX){
-		try=`{grep -i $pat $i/INDEX | sed 's/^[^ ]* //' | sort -u}
+		try=`{grep -i $pat $i/INDEX | sed 's/^[^ ]+ //' | sort -u}
 		if(! ~ $#try 0)
 			fils=($fils $i/$try)
 	}
 }
+fils=`{echo $fils | tr ' ' '\12' | sort -u}		# de-dup
 # bug: should also do following loop if not all pages found
 if(~ $#fils 0) {
 	# nothing in INDEX. try for file of given name
@@ -147,3 +148,4 @@ for(i in $fils) {
 		}
 	}
 }
+exit ''

+ 10 - 0
rc/bin/mf

@@ -0,0 +1,10 @@
+#!/bin/rc
+
+if(~ $NEWTEX no)
+	exec /sys/lib/tex/bin/$cputype/virmf '&mf' $*
+
+rfork en
+bind -b /sys/lib/texmf/bin/$cputype /bin
+bind -b /sys/lib/texmf/bin/rc /bin
+
+/sys/lib/texmf/bin/$cputype/_mf '&'mf.`{endian} $*

+ 7 - 0
rc/bin/minboot

@@ -0,0 +1,7 @@
+#!/bin/rc
+rfork nes
+@ {
+	sleep 60		# avoid double-boot when run from cron
+	fshalt -r
+	reboot			# paranoia
+} &

+ 59 - 0
rc/bin/mkdep

@@ -0,0 +1,59 @@
+#!/bin/rc
+
+rfork e
+
+includes=(/sys/include /$objtype/include)
+dirs=(.)
+
+st = ''
+
+while(~ $1 -*){
+	switch($1){
+	case -d
+		shift
+		dirs=($1 $dirs)
+	case -d*
+		inc=`{echo $1 | sed 's/-d//'}
+		dirs=($inc $dirs)
+	case -I
+		shift
+		includes=($includes $1)
+	case -I*
+		inc=`{echo $1 | sed 's/-I//'}
+		includes=($includes $inc)
+	case -*
+		echo Ignoring flag $1 >[1=2]
+	}
+	shift
+}
+
+for(f in $*){
+	file=''
+	for(d in $dirs){
+		if(test -e $d/$f)
+			file = $d/$f
+	}
+	if(! ~ $file ''){
+		incbase=`{grep '^[ 	]*#include' $file | sed 's/.*#include[ 	]+[<"](.*)[>"][ 	]*$/ \1/'}
+		incfiles=()
+		for (j in $incbase) {
+			incfile=''
+			for (i in (. $includes)) {
+				if (test -r $i/$j) {
+					incfile=$i/$j
+				}
+			}
+			if (! ~ $incfile '') {
+				incfiles=($incfiles $incfile)
+			}
+			if not {
+				st = $file^': cannot find '^$j
+				echo $st >/fd/2
+			}
+		}
+		echo `{basename $file .c}^'.$O': $incfiles | \
+		sed 's/\/'$objtype'\//\/$objtype\//g
+			s/ \.\// /g'
+	}
+}
+exit $st

+ 41 - 0
rc/bin/mkdist

@@ -0,0 +1,41 @@
+#!/bin/rc
+# mkdist changes - prepare distribution of kernels' sources,
+#	changes to /sys and /rc, plus commentary in .
+rfork e
+dist=/tmp/dist
+target=/tmp/9changed.tlz
+origdir=`{pwd}
+new=$1
+if (! ~ $1 /*)
+	new=$origdir/$1
+if (test ! -f $new) {
+	echo $0: $1 missing >[1=2]
+	exit missing
+}
+
+mkdir $dist
+cd $dist
+cp -x /sys/src/^(NOTICE mkfile mkfile.proto) .
+for (k in 9 9k) {
+	echo -n $k...
+	mkdir $k
+	dircp /sys/src/$k $k
+	@ { cd $k && mk clean >/dev/null }
+	rm -f 9*/boot/libboot.a?
+}
+
+echo -n changes...
+mkdir -p `{sed 's;/[^/]*$;;' $new | sort -u}
+for (f in `{cat $new})
+	cp -x /$f $f
+mkdir changes
+dircp $origdir changes
+
+# don't ship everything
+echo -n exclude...
+rm -rf `{dirs  | grep /_}
+rm -rf `{files | grep /_}
+
+echo -n tar...
+tar czf $target *
+echo

+ 24 - 0
rc/bin/mkfossilconf

@@ -0,0 +1,24 @@
+#!/bin/rc
+# mkfossilconf name
+rfork e
+name = $1
+
+cat <<!
+# fossil.$name.conf for /dev/fs/$name
+srv -p fscons.$name
+
+fsys $name config
+fsys $name venti localhost
+fsys $name open -c 13977
+fsys $name snaptime -a 0500 -s 720 -t 11520
+# fsys $name snaptime -a none -s none -t none
+fsys $name
+
+# listen tcp!*!564
+msg -m 500 -p 80
+
+srv $name
+srv fossil.$name
+srv -APW $name.open
+srv -APW fossil.$name.open
+!

+ 1 - 1
rc/bin/mkusbboot

@@ -75,7 +75,7 @@ case 386
 	k=/tmp/9pccpuf.gz
 	gzip -9 </$objtype/9pccpuf >$k
 case amd64
-	k=/$objtype/9k8cpu
+	k=/$objtype/9k10cpu
 case *
 	echo $0: 'can''t cope with architecture' $objtype >[1=2]
 	exit unknown-arch

+ 37 - 0
rc/bin/moowarning

@@ -0,0 +1,37 @@
+#!/bin/rc
+# moowarning - warn the milk czar to bring some
+rfork ne
+ramfs
+moo=()
+
+ifs='
+'
+next=`{calendar /lib/moo}
+for(i in $next)
+	moo=($moo `{echo $i | sed 's/.*[ 	]//'})
+ifs=' 	
+'
+
+mail pb <<EOF
+
+next MOO is:
+$next
+sent mail to $moo
+
+EOF
+mail $moo <<EOF
+Next unix room milk duty goes to:
+
+$next
+
+You may bring in your own milk or buy it at the
+cafeteria.  Gallons are now available in the cafeteria
+(in the fridge where they have small cartons of milk).
+
+At the moment we're consuming about 4-5 gallons a
+week.  Check the refrigerator before buying and try to 
+keep the stockpile of approximately 1 gallon during the 
+week.  If we stock more, it goes bad(!!!).  Please bring
+in 1% and/or 2% milk, hardly anybody prefers whole
+milk these days.
+EOF

+ 52 - 0
rc/bin/mountlabs

@@ -0,0 +1,52 @@
+#!/bin/rc
+# mount 1127 final plan 9 file server images on /n/labs, etc.
+rfork e
+arch=/lib/vac/arch		# archive mount-point tree
+
+mount -C /srv/labs /n/labs >[2]/dev/null || {
+	unmount /n/labs >[2]/dev/null
+	rm -f /srv/labs
+	if (~ $sysname fs) {
+		vacfs -p -h localhost -S labs /lib/vac/labs.vac
+		chgrp -u geoff /srv/labs
+		chmod 'o=' /srv/labs
+		vacfs    -h localhost -S publabs /lib/vac/labs.vac
+		mount -C /srv/publabs /n/publabs
+	}
+	if not {
+		# devmnt interferes with crypto (by breaking long records?)
+		import -E clear fs / /n/fs && {
+			mount -C /n/fs/srv/labs /n/labs
+			mount -C /n/fs/srv/publabs /n/publabs
+		}
+		srvfs labs /n/labs
+		srvfs publabs /n/publabs
+		chmod +rw /srv/labs /srv/publabs
+	}
+}
+if (! test -d /n/labs/choline) {
+	mount -C /srv/labs /n/labs || exit 'can''t mount /srv/labs'
+	if (! test -d /n/labs/choline) {
+		echo $0: /n/labs/choline missing! >[1=2]
+		exit no-choline
+	}
+}
+bind /n/labs/bootes/1997/1231 /n/bootes
+bind /n/labs/fornax/1997/1231 /n/fornax
+bind /n/labs/emelie/2006/10301 /n/emelie
+bind /n/labs/choline/2006/0814 /n/choline
+bind /n/publabs/choline/2006/0814 /n/cholinepub
+bind /n/labs/pie/archive/2014/0306 /n/pie
+
+for (juke in bootes fornax emelie choline) {
+	bind /n/labs/$juke /n/$juke^dump
+	bind /n/labs/$juke $arch/$juke^dump	# backward compatibility
+	# should this be one of the above binds of a date?
+	bind /n/labs/$juke $arch/$juke
+}
+# drat; pie.vac is a fossil dump score, so we have to fiddle names
+bind /n/labs/pie/archive /n/piedump
+bind /n/labs/pie/archive $arch/piedump
+bind /n/labs/pie/active $arch/pie
+
+bind $arch /n/archive		# backward compatibility

+ 11 - 0
rc/bin/mountlabsdump

@@ -0,0 +1,11 @@
+#!/bin/rc
+# mount /n/labsdump
+rfork e
+mtpt=labsdump
+arch=/lib/vac/arch		# archive mount-point tree
+
+mountlabs
+bind -a $arch/piedump /n/$mtpt
+bind -a $arch/emelie /n/$mtpt
+bind -a $arch/emelie/2003 /n/$mtpt/2003
+bind -b $arch/bootes /n/$mtpt

+ 42 - 0
rc/bin/movehome

@@ -0,0 +1,42 @@
+#!/bin/rc
+rfork ne
+9fs fs
+rm /srv/emelie
+9fs emelie
+old=/n/emelie/usr/$user
+new=/n/fs/usr/$user
+
+PROTO=/mail/tmp/proto.$pid.$user
+PROF=/mail/tmp/profile.$pid.$user
+cat > $PROTO <<EOF
+usr
+	$user
+		+
+EOF
+cat > $PROF <<EOF
+unmount $home
+. $home/lib/profile
+EOF
+cat $PROTO
+
+unmount /usr/$user
+
+echo Copying from $old to $new.
+echo This could take a while.
+{
+	disk/mkfs -a -s /n/emelie $PROTO | disk/mkext -T -d /n/fs
+}
+#rm $PROTO
+echo Copying done.
+echo
+echo Creating a new profile on emelie.  The old one will be moved to
+echo $old/lib/_profile.
+
+if(! test -e $old/lib/_profile )
+	mv $old/lib/profile $old/lib/_profile
+mv $PROF $old/lib/profile
+
+echo Done.
+echo
+echo If you''re on a terminal, reboot now.  If you''re cpu''d to
+echo a cpu server, close the window and reconnect.

+ 49 - 0
rc/bin/movemail

@@ -0,0 +1,49 @@
+#!/bin/rc
+rfork ne
+9fs fs
+rm /srv/emelie
+9fs emelie
+
+switch($#*){
+case 1
+	user=$1
+}
+old=/n/emelie/mail/box/$user
+new=/n/fs/mail/box/$user
+
+PROTO=/tmp/movemail.$pid.$user
+cat > $PROTO << EOF
+mail
+	box
+		$user
+			+
+EOF
+
+echo Getting all your mailbox files into the cache.
+echo This could take a while, but we do this first to
+echo shorten the time your mailbox is locked during the
+echo copy.
+{
+	disk/mkfs -a -s /n/emelie $PROTO > /dev/null
+}
+echo
+echo Caching done!
+echo
+
+unmount /mail/box
+mail -c
+
+echo Copying your mailbox files from $old to $new.
+echo Your mailbox will be locked until this finishes.
+echo Ignore the message about L.mbox...
+echo
+upas/lockmailbox
+{
+	rm $new/mbox
+	disk/mkfs -a -s /n/emelie $PROTO | disk/mkext -d /n/fs
+}
+echo
+echo Copying done!
+
+kill lockmailbox | rc
+rm $PROTO

+ 7 - 0
rc/bin/mp

@@ -0,0 +1,7 @@
+#!/bin/rc
+
+rfork en
+bind -b /sys/lib/texmf/bin/$cputype /bin
+bind -b /sys/lib/texmf/bin/rc /bin
+
+/sys/lib/texmf/bin/$cputype/_mp '&'mp.`{endian} $*

+ 15 - 0
rc/bin/newdisk

@@ -0,0 +1,15 @@
+#!/bin/rc
+# newdisk /dev/sdXn - prepare a disk per the example in prep(8),
+#	but without a fossil or cache
+if (! ~ $#* 1) {
+	echo usage: $0 device
+	exit usage
+}
+rfork en
+bind -a /bin/disk /bin
+
+dev=$1
+mbr -m /386/mbr $dev/data
+fdisk -baw $dev/data
+prep -bw -a^(9fat nvram swap) $dev/plan9
+format -b /386/pbslba -d -r 2 $dev/9fat /386/9load

Some files were not shown because too many files changed in this diff