git: 9front

Download patch

ref: 2c78dc093ebbd838480040ef556e651781099d6a
parent: 48454b08e777482859af639178d769caf3edbc44
author: cinap_lenrek <cinap_lenrek@localhost>
date: Tue Apr 12 11:53:55 EDT 2011

updating cwfs and moving installer in /rc/bin

--- /dev/null
+++ b/rc/bin/inst/bootfloppy
@@ -1,0 +1,47 @@
+#!/bin/rc
+
+rfork e
+
+echo
+echo 'Insert a disk other than your installation boot disk'
+echo 'into your floppy drive; it will be erased to create'
+echo 'the boot floppy.'
+echo
+echo -n 'Press enter when ready.'
+read >/dev/null >[2]/dev/null
+
+if(~ $#adisk 1)
+	;	# do nothing
+if not if(~ $#bootfile 0)
+	adisk=/dev/fd0disk
+if not {
+	switch($bootfile) {
+	case sd*
+		adisk=`{echo $bootfile | sed 's#(sd..).*#/dev/\1/data#'}
+	case fd*
+		adisk=`{echo $bootfile | sed 's#(fd.).*#/dev/\1disk#'}
+	case *
+		echo 'unknown bootfile '^$bootfile^'; mail 9trouble@plan9.bell-labs.com'
+		exit oops
+	}
+}
+
+if(! ~ `{ls -l $adisk | awk '{print $6}'} 1474560){
+	echo 'Will not format non-floppy disk '^$"adisk. >[1=2]
+	exit 'bad adisk'
+}
+
+log Formatting boot floppy
+if (test -e  /n/newfs/386/9loadnousb)
+	bind /n/newfs/386/9loadnousb /n/newfs/386/9load	# cater to old bioses
+disk/format -b /386/pbs \
+	-fd $adisk /n/newfs/386/9load /n/newfs/386/9pcdisk.gz \
+	/tmp/plan9ini.bak
+x=$status
+
+if(~ $x ''){
+	echo 
+	echo 'Done!'
+	echo
+}
+exit $x
--- /dev/null
+++ b/rc/bin/inst/bootplan9
@@ -1,0 +1,55 @@
+#!/bin/rc
+
+first=`{ls -p '#S' | sed 1q}
+if(! ~ $first $disk) {
+	echo 'warning: The plan 9 partition is not on the boot disk,'
+	echo 'so making it the active partition will have no effect.'
+}
+
+p9offset=`{grep '^part 9fat ' /dev/$disk/ctl |awk '{print $3}'}
+if(! ~ $#p9offset 1) {
+	echo 'could not find plan 9 partition.'
+	echo 'cannot happen'
+	exit bad
+}
+
+if(test $p9offset -gt 4128695) {	# 65536 * 63 - 10
+	echo 
+	echo 'Your Plan 9 partition is more than 2GB into your disk,'
+	echo 'and the master boot records used by Windows 9x/ME'
+	echo 'cannot access it (and thus cannot boot it).'
+	echo
+	echo 'You can install the Plan 9 master boot record, which can load'
+	echo 'partitions far into the disk.'
+	echo 
+}
+
+echo 'If you use the Windows NT/2000/XP master boot record'
+echo 'or a master boot record from a Unix clone (e.g., LILO or'
+echo 'FreeBSD bootmgr), it is probably safe to continue using'
+echo 'that boot record rather than install the Plan 9 boot record.'
+echo
+prompt 'Install the Plan 9 master boot record' y n 
+switch($rd) {
+case n
+	;
+case y
+	disk/mbr -m /386/mbr /dev/$disk/data
+}
+
+log Setting Plan 9 partition active.
+p9part=`{disk/fdisk /dev/$disk/data >[2]/dev/null </dev/null | 
+		grep PLAN9 | sed 1q | sed 's/ *(p.) .*/\1/'}
+if(~ $#p9part 0){
+	echo 'You have no Plan 9 partitions (How could this happen?)' >[1=2]
+	exit 'no plan 9 partition found'
+}
+p9part=$p9part(1)
+{ echo 'A '^$p9part; echo w } | disk/fdisk /dev/$disk/data >[2]/dev/null >/dev/null
+x=$status
+if(~ $x '' '|'){
+	echo
+	echo 'The Plan 9 partition is now marked as active.'
+	exit ''
+}
+exit $x
--- /dev/null
+++ b/rc/bin/inst/bootsetup
@@ -1,0 +1,125 @@
+#!/bin/rc
+
+# desc: create a boot floppy or configure hard disk to boot plan 9
+# prereq: copydist
+
+switch($1) {
+case go
+	echo
+	echo 'Initializing Plan 9 FAT configuration partition (9fat)'
+	echo
+	
+	fat=(/dev/sd*/9fat)
+	fat=$fat(1)
+	disk=`{echo $fat | sed 's:/dev/::;s:/9fat::'}
+	bootfs=`{echo $fs | sed 's:/dev/(sd..)/(.*):\1!\2:'}
+	bootfat=`{echo $fs | sed 's:/dev/(sd..)/(.*):\1!9fat:'}
+	if(! test -f /dev/$disk/9fat) {
+		echo 'You have no 9fat partition.  Can''t setup booting.'
+		exit
+	}
+
+	if(! test -f /tmp/plan9.ini) {
+		{
+			sfs=`{echo $fs | sed 's;/dev;#S;'}
+			if(~ $fstype fossil fossil+venti){
+				echo bootfile'='$bootfat!9pcf
+				echo 'bootargs=local!'^$sfs
+				echo 'bootdisk=local!'^$sfs
+			}
+			if not {
+				echo bootfile'='$bootfs!/386/9pcdisk
+				echo 'bootdisk=local!'^$sfs
+			}
+			if(~ $fstype fossil+venti){
+				venti=`{echo $ventiarena | sed 's;/dev;#S;'}
+				echo venti'='^$venti
+			}
+			# sort -u avoids dups which could otherwise trigger
+			# pointless boot menus.
+			grep -v '(^\[)|menuitem|adisk|bootfile|bootdisk|bootargs|nobootprompt|mouseport|vgasize|monitor|cdboot' /tmp/plan9.orig |
+				sort -u
+			echo 'mouseport='^$mouseport
+			echo 'monitor='^$monitor
+			echo 'vgasize='^$vgasize
+		} >/tmp/plan9.ini
+	}
+	if(! test -f /tmp/plan9ini.bak)
+		cp /tmp/plan9.ini /tmp/plan9ini.bak
+
+	need9fatformat=no
+	if(! isfat /dev/$disk/9fat)
+		need9fatformat=yes
+	if not if(! mount -c /srv/dos /n/9fat /dev/$disk/9fat >[2]/dev/null)
+		need9fatformat=yes
+	if not if(! test -f /n/9fat/plan9.ini)
+		need9fatformat=yes
+
+	if (test -e  /n/newfs/386/9loadnousb)
+		bind /n/newfs/386/9loadnousb /n/newfs/386/9load	# cater to old bioses
+	if(~ $need9fatformat yes){
+		log Initializing Plan 9 FAT partition.
+		disk/format -r 2 -d -b /386/pbs \
+			/dev/$disk/9fat /n/newfs/386/9load
+		# silently install pbslba if the partition is way into the disk.
+		# it''s our only hope.  only need this for >8.5GB into the disk.
+		# but...
+		# there are so few non-LBA bioses out
+		# there anymore that we'll do this even if we're only 2GB into
+		# the disk.  it's just not worth the headaches of dealing with
+		# crappy bioses that don't address the whole 8.5GB properly
+
+		9fatoffset=`{grep '^part 9fat ' /dev/$disk/ctl | awk '{print $4}'}
+		if(! ~ $#9fatoffset 1) {
+			echo 'could not find plan 9 partition.'
+			echo 'cannot happen'
+			exit bad
+		}
+		if(test $9fatoffset -gt 2097152)	# 2GB
+			disk/format -b /386/pbslba /dev/$disk/9fat
+
+		mount -c /srv/dos /n/9fat /dev/$disk/9fat
+	}
+
+	if(! test -f /n/9fat/4e){
+		logprog cp /n/newfs/386/9load /n/9fat/9load
+		logprog cp /n/newfs/386/9pcf /n/9fat/9pcf
+		if(test -f /n/9fat/plan9.ini && ! test -f /n/9fat/plan9-3e.ini)
+			logprog mv /n/9fat/plan9.ini /n/9fat/plan9-3e.ini
+		if(test -f /n/9fat/9pcdisk && ! test -f /n/9fat/9pc3e)
+			logprog mv /n/9fat/9pcdisk /n/9fat/9pc3e
+
+		awk -f /bin/inst/mkini.awk >/n/9fat/plan9.ini
+		>/n/9fat/4e
+	}
+
+	echo
+	echo 'There are myriad ways to boot a Plan 9 system.'
+	echo 'You can use any of the following.'
+	echo
+	echo '  floppy - create a boot floppy'
+	echo '  plan9  - make the plan 9 disk partition the default for booting'
+	echo '  win9x  - add a plan 9 option to windows 9x boot menu'
+	echo '  winnt  - add a plan 9 option to windows nt/2000/xp boot manager'
+	echo
+	echo 'If you are upgrading an extant third edition installation and booting'
+	echo 'from something other than a floppy, you needn''t run anything here.'
+	echo 'Just type ctl-d.'
+
+	oldbootsetup=$didbootsetup
+	didbootsetup=1
+	export didbootsetup
+	prompt 'Enable boot method' floppy plan9 win9x winnt
+	
+	if(! boot$rd){
+		didbootsetup=$oldbootsetup
+		export didbootsetup
+	}
+
+case checkdone
+	xxxfat=(/dev/sd*/9fat)
+	if(! isfat $xxxfat(1) || ! ~ $didbootsetup 1){
+		bootsetup=ready
+		export bootsetup
+	}
+}
--- /dev/null
+++ b/rc/bin/inst/bootwin9x
@@ -1,0 +1,117 @@
+#!/bin/rc
+
+dosdisk=`{ls /dev/sd??/dos >[2]/dev/null | sed 1q | sed 's!.*/(.*)/dos!\1!'}
+if(~ $#dosdisk 0 || ! c: || ! test -f /n/c:/autoexec.bat || ! test -f /n/c:/config.sys) {
+	echo 'Could not find autoexec.bat or config.sys on the first FAT disk.'
+	exit bad
+}
+
+for (i in autoexec config msdos)
+	if(test -f /n/c:/$i.p9) {
+		echo 'A Plan 9 backup already exists; will not edit system files again.'
+		exit bad
+	}
+
+for (i in autoexec.bat config.sys msdos.sys)
+	if(! cp /n/c:/$i /n/c:/^`{echo $i | sed 's/\.(bat|sys)$/.p9/'}) {
+		echo 'Could not back up '^$i^'; will not continue.'
+		exit bad
+	}
+
+if(! test -d /n/c:/plan9 && ! mkdir /n/c:/plan9) {
+	echo 'Could not create directory /n/c:/plan9.'
+	exit bad
+}
+
+if(! cp /n/newfs/386/^(9load ld.com 9pcdisk) /tmp/plan9ini.bak /n/c:/plan9) {
+	echo 'Could not copy Plan 9 boot files into /n/c:/plan9.'
+	exit bad
+}
+
+chmod +w /n/c:/autoexec.bat /n/c:/config.sys /n/c:/msdos.sys
+
+if(grep -si 'Plan ?9' /n/c:/config.sys || grep -si 'Plan ?9' /n/c:/autoexec.bat) {
+	echo 'Plan 9 entries already in config.sys or autoexec.bat.'
+	echo 'Not changing them; refer to Plan 9 install documentation'
+	echo 'to configure manually.'
+	exit bad
+}
+
+if(! grep -si '\[menu\]' /n/c:/config.sys) {
+	{
+		echo 1
+		echo i
+		echo '[menu]
'
+		echo 'menuitem=windows, Windows
'
+		echo 'menudefault=windows
'
+		echo '
'
+		echo '[common]
'
+		echo '
'
+		echo '[windows]
'
+		echo .
+		echo w
+		echo q
+	} | ed /n/c:/config.sys >/dev/null >[2]/dev/null
+}
+
+{
+	echo 1
+	echo '/\[[Mm][Ee][Nn][Uu]\]'
+	echo '?^[Mm][Ee][Nn][Uu][Ii][Tt][Ee][Mm]='
+	echo a
+	echo 'menuitem=plan9, Plan 9 from Bell Labs
'
+	echo .
+	echo '$'
+	echo a
+	echo '
'
+	echo '[plan9]
'
+	echo '
'
+	echo .
+	echo w
+	echo q
+} | ed /n/c:/config.sys >/dev/null>[2]/dev/null
+
+{
+	echo 1
+	echo i
+	echo '@echo off
'
+	echo 'if %config%==plan9 goto plan9
'
+	echo 'goto notplan9
'
+	echo ':plan9
'
+	echo 'plan9\ld '^$dosdisk^'!dos!plan9/9load
'
+	echo ':notplan9
'
+	echo .
+	echo w
+	echo q
+} | ed /n/c:/autoexec.bat >/dev/null>[2]/dev/null
+
+fn zeroopt {
+	if(grep -s '^'^$1^'=1' /n/c:/msdos.sys) {
+		{
+			echo '/^'^$1^'=1/s/=1/=0/'
+			echo w
+			echo q
+		} | ed /n/c:/msdos.sys>/dev/null>[2]/dev/null
+	}
+	if not if (grep -s '^'^$1^'=0' /n/c:/msdos.sys)
+		;
+	if not {
+		{
+			echo 1
+			echo i
+			echo '[Options]
'
+			echo 'Logo=0
'
+			echo .
+			echo w
+			echo q
+		} | ed /n/c:/msdos.sys>/dev/null>[2]/dev/null
+	}
+}
+
+if(grep -si '^\[paths\]' /n/c:/msdos.sys){	# Windows 9x rather than DOS
+	zeroopt Logo
+#	zeroopt BootGUI
+}
+		
+echo 'Plan 9 added to Windows 9X boot menu.'
+exit ''
--- /dev/null
+++ b/rc/bin/inst/bootwinnt
@@ -1,0 +1,47 @@
+#!/bin/rc
+
+if(! c: || ! test -f /n/c:/boot.ini) {
+	echo 'Could not find NT''s boot.ini on the first FAT disk.'
+	exit bad
+}
+
+if(test -f /n/c:/boot.p9) {
+	echo 'A Plan 9 backup already exists; will not edit boot.ini again.'
+	exit bad
+}
+
+if(! cp /n/c:/boot.ini /n/c:/boot.p9) {
+	echo 'Could not back up boot.ini; will not continue.'
+	exit bad
+}
+
+chmod +w /n/c:/boot.ini
+
+if(! grep -si '\[operating systems\]' /n/c:/boot.ini) {
+	echo 'Could not parse boot.ini.'
+	exit bad
+}
+
+if(grep -si 'Plan 9' /n/c:/boot.ini) {
+	p9file=`{grep 'Plan 9' /n/c:/boot.ini | sed 1q | sed 's/=.*//'}
+	if(! ~ $p9file [Cc]:'\'*) {
+		echo 'Unexpected Plan 9 entry in boot.ini already; not continuing.'
+		exit bad
+	}
+}
+
+if not {
+	p9file='c:\bootsect.p9'
+	echo 'c:\bootsect.p9 = "Plan 9 from Bell Labs"
' >>/n/c:/boot.ini
+}
+
+p9file=/n/^`{echo $p9file | sed 's!\\!/!g'}
+
+
+if(dd -if /dev/$disk/plan9 -bs 512 -count 1 -of $p9file >/dev/null >[2]/dev/null) {
+	echo 'Plan 9 added to Windows NT boot menu.'
+	exit ''
+}
+
+echo 'Error copying Plan 9 boot sector to file.'
+exit bad
--- /dev/null
+++ b/rc/bin/inst/configarch
@@ -1,0 +1,40 @@
+#!/bin/rc
+
+# desc: set source of distribution archives
+# prereq: mountfs
+
+switch($1) {
+case go
+	echo
+	echo 'Will you be using a distribution archive on local media or the internet?'
+	echo
+
+	prompt 'Distribution is from' local internet
+	archmedium=$rd
+	export archmedium
+
+	switch($archmedium) {
+	case local
+		exec configlocal go
+	case internet
+		exec configip go
+	}
+
+case checkdone
+	switch($#archmedium) {
+	case 1
+		switch($archmedium) {
+		case local
+			exec configlocal checkdone
+		case internet
+			exec configip checkdone
+		case *
+			configarch=notdone
+			export configarch
+		}
+	case *
+		configarch=notdone
+		export configarch
+	}
+}
+		
--- /dev/null
+++ b/rc/bin/inst/configdist
@@ -1,0 +1,22 @@
+#!/bin/rc
+
+# prereq: mountfs
+# desc: choose the source of the distribution archive
+
+switch($1){
+case checkdone
+	if(! ~ $distisfrom net local){
+		configdist=ready
+		export configdist
+	}
+
+case go
+	echo 'Are you going to download the distribution'
+	echo 'from the internet or do you have it on local media?'
+	echo
+	prompt -d local 'Distribution is from' local net
+	distisfrom=$rd
+	export distisfrom
+}
+
+
--- /dev/null
+++ b/rc/bin/inst/configether
@@ -1,0 +1,53 @@
+#!/bin/rc
+
+# desc: configure your internet connection via an ethernet card
+
+switch($1) {
+case go
+	echo
+	echo 'Please choose a method for configuring your ethernet connection.'
+	echo
+	echo '	manual - specify IP address, network mask, gateway IP address'
+	echo '	dhcp - use DHCP to automatically configure'
+	echo
+	
+	prompt 'Configuration method' manual dhcp
+	ethermethod=$rd
+	gwaddr=xxx
+	ipaddr=xxx
+	ipmask=xxx
+	switch($ethermethod){
+	case dhcp
+		echo
+		echo 'Some ISPs, notably @HOME, require a host name passed with DHCP'
+		echo 'requests.  An example for @HOME would be "cc1018221-a".  If your'
+		echo 'ISP supplied you such a name, enter it.'
+		echo
+		prompt -d none 'host name'; dhcphost=$rd
+		switch($dhcphost){
+		case none
+			dhcphost=();
+		case *
+			dhcphost=(-h $dhcphost)
+		}
+		export dhcphost
+	case manual
+		prompt 'ip address'; ipaddr=$rd
+		prompt 'network mask'; ipmask=$rd
+		prompt 'gateway address'; gwaddr=$rd
+		export ipaddr ipmask gwaddr
+	}
+	
+	export ethermethod gwaddr ipaddr ipmask dhcphost
+	exec startether go
+
+case checkdone
+	if(! ~ $ethermethod manual dhcp) {
+		configether=notdone
+		export configether
+	}
+	if(~ $ethermethod manual && ~ 0 $#ipaddr $#ipmask $#gwaddr) {
+		configether=notdone
+		export configether
+	}
+}
--- /dev/null
+++ b/rc/bin/inst/configfs
@@ -1,0 +1,23 @@
+#!/bin/rc
+
+# desc: choose the type of file system to install
+
+switch($1){
+case checkdone
+	if(! ~ $fstype fossil fossil+venti){
+		configfs=ready
+		export configfs
+	}
+
+case go
+	echo 'You can install the following types of file systems:'
+	echo
+	echo '	fossil			the new Plan9 fileserver'
+	echo '	fossil+venti	fossil + a archival dump server'
+	echo
+	prompt -d fossil 'File system' fossil fossil+venti
+	fstype=$rd
+	export fstype
+}
+
+
--- /dev/null
+++ b/rc/bin/inst/configip
@@ -1,0 +1,64 @@
+#!/bin/rc
+
+switch($1) {
+case go
+
+	devs=''
+	if(test -d '#l/ether0' >[2]/dev/null)
+		devs=$devs^ether
+	if(test -f '#t'/eia? >[2]/dev/null)
+		devs=$devs^ppp
+	
+	switch($devs){
+	case ''
+		echo
+		echo 'Could not find ethernet card nor serial port nor modem.'
+		echo 'Please use a local copy of the distribution archive.'
+		echo
+		ifc=none
+	
+	case ppp
+		echo
+		echo 'No ethernet card was detected, but there is a serial port or modem.'
+		echo 'We will configure PPP.'
+		echo
+		ifc=ppp
+	
+	case ether
+		echo
+		echo 'No serial port or modem detected, but there is an ethernet card.'
+		echo 'We will configure the ethernet.'
+		echo
+		ifc=ether
+	
+	case etherppp
+		echo
+		echo 'You can connect to the internet via'
+		echo 'a local ethernet or a dial-up PPP connection.'
+		echo
+		prompt 'Interface to use' ether ppp
+		ifc=$rd
+	}
+	
+	ipinterface=$ifc
+	export ipinterface
+	
+	switch($ifc) {
+	case ether
+		exec configether go
+	case ppp
+		exec configppp go
+	}
+
+case checkdone
+	if(~ $#ipinterface 1)
+		switch($ipinterface) {
+		case ether
+			exec configether checkdone
+		case ppp
+			exec configppp checkdone
+		}
+	configarch=notdone
+	export configarch
+
+}
--- /dev/null
+++ b/rc/bin/inst/confignet
@@ -1,0 +1,67 @@
+#!/bin/rc
+
+# prereq: configdist
+# desc: configure the network to download the distribution
+
+switch($1){
+case checkready checkdone
+	if(! ~ $distisfrom net){
+		confignet=notdone
+		export confignet
+		exit
+	}
+	if(~ $distisfrom net && ~ $netisfrom ppp ether){
+		x=config$netisfrom
+		$x=done
+		config$netisfrom checkdone
+		confignet=$$x
+		export confignet
+		exit
+	}
+	confignet=ready
+	export confignet
+	exit
+
+case go
+	devs=''
+	if(test -d '#l/ether0' >[2]/dev/null)
+		devs=$devs^ether
+	if(test -f '#t'/eia? >[2]/dev/null)
+		devs=$devs^ppp
+	
+	switch($devs){
+	case ''
+		echo
+		echo 'Could not find ethernet card nor serial port nor modem.'
+		echo 'Please use a local copy of the distribution archive.'
+		echo
+		netisfrom=none
+	
+	case ppp
+		echo
+		echo 'No ethernet card was detected, but there is a serial port or modem.'
+		echo 'We will configure PPP.'
+		echo
+		netisfrom=ppp
+	
+	case ether
+		echo
+		echo 'No serial port or modem detected, but there is an ethernet card.'
+		echo 'We will configure the ethernet.'
+		echo
+		netisfrom=ether
+	
+	case etherppp
+		echo
+		echo 'You can connect to the internet via'
+		echo 'a local ethernet or a dial-up PPP connection.'
+		echo
+		prompt 'Interface to use' ether ppp
+		netisfrom=$rd
+	}
+	
+	export netisfrom
+	if(~ $netisfrom ether ppp)
+		exec config$netisfrom go
+}
+
--- /dev/null
+++ b/rc/bin/inst/configppp
@@ -1,0 +1,63 @@
+#!/bin/rc
+
+# desc: configure your internet connection via ppp over a modem
+
+switch($1) {
+case go
+	devs=`{ls -p '#t/'eia? >[2]/dev/null}
+	if(~ $#devs 0) {
+		echo 'No serial port found; this can''t happen.'	# because configip checks
+		exit
+	}
+	
+	# not going to use the mouse for PPP
+	if(~ eia^$mouseport $devs)
+		devs=`{echo $devs | sed 's/eia'^$mouseport^'//'}
+	
+	if(~ $#devs 0) {
+		echo 'The only serial port you have is your mouse.'
+		echo 'Cannot configure PPP.'
+		exit
+	}
+	
+	echo
+	echo 'Please choose the serial port or modem to use to connect to your ISP.'
+	echo
+	for(i in $devs) {
+		n=`{echo $i | sed 's/eia//'}
+		n=`{hoc -e 1+$n}
+		echo '	'^$i^'(Windows'' COM'^$n^')'
+	}
+	echo
+	prompt 'Serial device' $devs
+	pppdev=$rd
+	
+	echo
+	echo 'Pick a baud rate for the PPP connection.'
+	echo
+	prompt -d 115200 'Baud rate'
+	pppbaud=$rd
+	
+	echo
+	echo 'You can specify your dialup phone number, username, and password,'
+	echo 'or you can log in manually by typing the modem commands yourself.'
+	echo
+	prompt 'Dialing method' auto manual
+	pppmethod=$rd
+	
+	switch($pppmethod){
+	case auto
+		prompt 'PPP phone number'; pppphone=$rd
+		prompt 'PPP phone username'; pppuser=$rd
+		prompt 'PPP phone password'; ppppasswd=$rd
+	}
+	
+	export pppdev pppmethod pppphone ppppasswd pppuser pppbaud
+	exec startppp go
+
+case checkdone
+	if(! ~ $#pppmethod 1 || ! test -f /dev/$pppdev){
+		configppp=notdone
+		export configppp
+	}
+}
--- /dev/null
+++ b/rc/bin/inst/copydist
@@ -1,0 +1,31 @@
+#!/bin/rc
+
+# prereq: mountdist
+# desc: copy the distribution into the file system
+
+switch($1){
+case checkready
+	if(! test -d /n/dist/dist/replica){
+		copydist=notdone
+		export copydist
+		exit
+	}
+	if(test -f /n/newfs/dist/replica/didplan9){
+		copydist=done
+		export copydist
+		exit
+	}
+case go
+	inst/watchfd applylog 0 `{ls -l /n/dist/dist/replica/plan9.log | awk '{print $6}'} 'Installing file system' &
+	replica/pull -c / /rc/bin/inst/replcfg
+	if(~ $status '' *conflicts || test -f /n/newfs/dist/replica/didplan9witherrors)
+		>/n/newfs/dist/replica/didplan9
+	if not
+		>/n/newfs/dist/replica/didplan9witherrors
+
+case checkdone
+	if(! test -f /n/newfs/dist/replica/didplan9){
+		copydist=notdone
+		export copydist
+	}
+}
--- /dev/null
+++ b/rc/bin/inst/defs
@@ -1,0 +1,162 @@
+nl='
+'
+tab='	'
+if(~ $#distname 0)
+	distname=plan9
+
+wctl=/dev/null
+if(test -w /dev/wctl)
+	wctl=/dev/wctl
+
+fn log {
+	echo $* >>/srv/log
+}
+
+fn logprog {
+	echo '% '^$"* >>/srv/log
+	$* >[2=1] >>/srv/log
+}
+
+fn sigint {
+	# nothing happens
+}
+
+fn prompt {
+	def=()
+	what=()
+	if(~ $1 -d && ! ~ $#* 1){
+		def=$2
+		shift
+		shift
+	}
+
+	optstr=()
+	if(~ $1 -w && ! ~ $#* 1){
+		optstr=$2
+		shift
+		shift
+	}
+
+	pr=$1
+	shift
+
+	opts=($*)
+	if(~ $#opts 0) {
+		suf=' '
+	}
+	if not if(! ~ $#optstr 0) {
+		if(~ $optstr '') 
+			suf=' '
+		if not {
+			pr=$pr^' ('^$"optstr^')'
+			suf=''
+		}
+	}
+	if not {
+		pr=$pr^' ('^$1
+		shift
+		for(i)
+			pr=$pr^', '^$i
+		pr=$pr^')'
+		suf=''
+	}
+
+	if(~ $#def 1)
+		pr=$pr^$suf^'['^$def^']'
+	if not
+		pr=$pr^$suf^'[no default]'
+
+	pr=$pr^': '
+
+
+	okay=no
+	while(~ $okay no) {
+		echo -n current >$wctl
+		echo -n top >$wctl
+		echo -n $pr >[1=2]
+		ifs='' {rd=`{read}}
+		if(~ $#rd 0)
+			exit notdone
+		if(~ $rd !*){
+			ifs='' {rd=`{echo $rd | sed 's/!//'}}
+			echo $rd
+			rc -c $rd
+			echo !$status
+		}
+		if not{
+			rd=`{echo $rd}
+			if(~ $#rd 0 || ~ $rd '')
+				rd=$def
+	
+			switch($#opts){
+			case 0
+				if(! ~ $rd '')
+					okay=yes
+			case *
+				if(~ $rd $opts)
+					okay=yes
+			}
+		}
+	}
+	echo -n $rd >/env/rd	# just in case
+}
+
+fn desc {
+	echo -n '	'^$1^'	- '
+	grep '^# desc: ' $1 | sed 's/# desc: //'
+}
+
+fn prereq {
+	grep '^# prereq:' $1 | sed 's/# prereq://'
+}
+
+fn mustdo {
+	echo You must `{grep '^# mustdo:' $1 | sed 's/# mustdo://'}
+}
+
+# there's no easy way to pass shell variables
+# up from children to parents; the parents have
+# to be coerced into noticing that the environment
+# changed, even when in the same environment group.
+#
+# instead, we explicitly export the variables we want
+# to percolate, and the parent calls coherence to reread
+# the variables.
+#
+# we just append to the vars file, so that later exports
+# override earlier ones; when we call coherence, 
+# the duplicates are thrown out.
+
+fn export {
+	null=()
+	nonnull=()
+	for(i in $*){
+		if(~ $#$i 0)
+			null=($null $i)
+		if not
+			nonnull=($nonnull $i)
+	}
+	if(! ~ $#nonnull 0)
+		whatis $nonnull |grep -v '^\./' >>/tmp/vars >[2]/dev/null
+	for(i in $null)
+		echo $i^'=()' >>/tmp/vars
+}
+
+fn coherence {
+	if(test -f /tmp/vars) {
+		grep '^[a-z]*=' /tmp/vars >/tmp/vars2
+		v=`{sed 's/^([a-z]*)=.*/\1/' /tmp/vars2 | sort -u}
+		. /tmp/vars2
+		rm /tmp/vars2
+		rm /tmp/vars
+		export $v
+	}
+}
+
+# ip device stats
+
+fn isipdevup {
+	grep -s $1 /net/ipifc/*/status >[2]/dev/null 
+}
+
+
--- /dev/null
+++ b/rc/bin/inst/download
@@ -1,0 +1,56 @@
+#!/bin/rc
+
+# prereq: mountfs
+# desc: download or continue to download the distribution archives
+
+switch($1) {
+case checkready
+	devs=(`{cat /net/ipifc/*/status >[2]/dev/null |
+		grep -v '127\.0\.0\.1' |
+		sed 's/ .*//'})
+	if(~ $#devs 0) {
+		download=notdone
+		export download
+	}
+	if(~ $mountdist done){
+		download=notdone
+		export download
+	}
+
+case go
+	if(! test -f /srv/cs) {
+		log starting cs, dns
+		logprog ndb/cs >>/srv/log >[2=1]
+		logprog ndb/dns -r >>/srv/log >[2=1]
+	}
+	if(! test -f /net/cs) {
+		logprog mount -a /srv/cs /net
+		logprog mount -a /srv/dns /net
+	}
+
+	# BUG make restartable
+	echo 'Downloading distribution package...'
+	baropt='-w 145,129,445,168'
+	if(~ $textinst 1)
+		baropt=-t
+	if(! hget -vo /n/newfs/dist/_plan9.iso.bz2 $installurl/plan9.iso.bz2 |[2] bargraph $baropt 'downloading '^plan9.iso.bz2)
+			exit
+	mv /n/newfs/dist/_plan9.iso.bz2 /n/newfs/dist/plan9.iso.bz2
+	if(~ $fstype fossil){
+		echo fsys main sync >>/srv/fscons
+	}
+
+	echo 'The distribution is downloaded.'
+
+	srvmedia=()
+	mountmedia=(mount /srv/fossil /n/distmedia)
+	distmediadir=/dist
+	export distmediadir mountmedia distmedia
+	
+case checkdone
+	if(! test -f /n/newfs/dist/plan9.iso.bz2) {
+		download=notdone
+		export download
+	}
+}
+
--- /dev/null
+++ b/rc/bin/inst/finish
@@ -1,0 +1,19 @@
+#!/bin/rc
+
+# desc: finish the installation and reboot
+# prereq: bootsetup
+# mustdo: 
+
+switch($1) {
+case checkdone
+	finish=ready
+	export finish
+
+case go
+	if(~ $cdboot yes){
+		echo 'Congratulations; you''ve completed the install.'
+		echo
+		halt
+	}
+	stop go finished
+}
--- /dev/null
+++ b/rc/bin/inst/fmtfossil
@@ -1,0 +1,91 @@
+#!/bin/rc
+
+# desc: initialize disks for a fossil server
+# prereq: configfs
+
+switch($1){
+case checkready checkdone
+	if(! ~ $fstype fossil+venti fossil){
+		fmtfossil=notdone
+		export fmtfossil
+		exit
+	}
+	ff=`{ls /dev/sd*/fossil* /dev/fs/fossil* >[2]/dev/null}
+	if(~ $#ff 0){
+		fmtfossil=notdone
+		export fmtfossil
+		exit
+	}
+	gg=()
+	for(f in $ff)
+		if(isfossil $f)
+			gg=($gg $f)
+	if(~ $#gg 0){
+		fmtfossil=ready
+		export fmtfossil
+		exit
+	}
+	fmtfossil=done
+	export fmtfossil
+	exit
+
+case go
+	ff=`{ls /dev/sd*/fossil* /dev/fs/fossil* >[2]/dev/null}
+	if(~ $#ff 0){
+		echo 'You need to create a partition or partitions to hold the Fossil write cache.'
+		echo 'The partition name must begin with "fossil".'
+		echo
+		fmtfossil=notdone
+		export fmtfossil
+		exit
+	}
+	default=()
+	if(~ $#ff 1){
+		default=(-d $ff)
+	}
+	echo You have the following fossil partitions.
+	echo
+	prompt $default 'Fossil partition to format' $ff
+	f=$rd
+
+	do=yes
+	if(isfossil $f){
+		echo $f appears to already be formatted as Fossil file system.
+		echo Do you really want to reformat it?
+		echo
+		prompt -d no 'Reformat '$f yes no
+		do=$rd
+	}
+	if(~ $do yes){
+		fossil/flfmt -y $f
+		n=`{cat /dev/swap | grep ' user' | sed 's/^[0-9]+\/([0-9]+) .*/\1/'}
+		if(test $n -gt 32768)
+			m=3000	# if have at least 128 user MB, use 24MB for fossil
+		if not if(test $n -gt 16384)
+			m=1500	# 64 user MB => 12MB for fossil
+		if not if(test $n -gt 8192)
+			m=750	# 32 user MB => 6MB for fossil
+		if not
+			m=256	# 2MB for fossil (this will be slow)
+
+		# if we're using a venti in the back, take hourly snapshots
+		# that retire after three days, in addition to the daily dumps at 5am
+		if(~ $fstype fossil+venti){
+			v=''
+			snap='fsys main snaptime -s 60 -a 0500 -t 2880'
+		}
+		# otherwise, take the daily dumps but nothing else --
+		# we can't retire snapshots unless dumps are being archived
+		if not{
+			v='-V'
+			snap=''
+		}
+		echo \
+'fsys main config '^$f^'
+fsys main open '^$v^' -c '^$m^'
+'^$snap^'
+'		| fossil/conf -w $f
+	}
+	
+	echo Done.
+}
--- /dev/null
+++ b/rc/bin/inst/fmtventi
@@ -1,0 +1,190 @@
+#!/bin/rc
+
+# desc: initialize disks for a venti server
+# prereq: mountdist
+
+switch($1){
+case checkready checkdone
+	if(! ~ $fstype fossil+venti){
+		fmtventi=notdone
+		export fmtventi
+		exit
+	}
+	if(! test -e /bin/venti/fmtarenas || ! test -e /bin/venti/fmtisect || ! test -e /bin/venti/fmtindex){
+		bind -a /n/dist/386/bin/venti /bin/venti
+		if(! test -e /bin/venti/fmtarenas || ! test -e /bin/venti/fmtisect || ! test -e /bin/venti/fmtindex){
+			fmtventi=notdone
+			export fmtventi
+			exit
+		}
+	}
+	ff=`{ls /dev/sd*/arenas* /dev/fs/arenas* >[2]/dev/null}
+	if(~ $#ff 0){
+		fmtventi=notdone
+		export fmtventi
+		exit
+	}
+	gg=()
+	for(f in $ff)
+		if(isventi $f)
+			gg=($gg $f)
+	if(~ $#gg 0){
+		fmtventi=ready
+		export fmtventi
+		exit
+	}
+
+	ventiarena=$gg(1)
+	export ventiarena
+
+	fmtventi=done
+	export fmtventi
+	exit
+
+case go
+	ff=`{ls /dev/sd*/arenas* /dev/fs/arenas* >[2]/dev/null}
+	if(~ $#ff 0){
+		echo 'You need to create a partition or partitions to hold the Venti arenas.'
+		echo 'The arena partition names must begin with "arenas".'
+		echo
+		fmtventi=notdone
+		export fmtventi
+		exit
+	}
+	default=(-d $"ff)
+	if(! ~ $#ventiarena 0){
+		default=(-d $"ventiarena)
+	}
+	echo You have the following Venti arena partitions.
+	ls -l $ff
+	echo
+
+	prompt $default 'Venti arena partitions to use'
+	aa=`{echo $rd}
+	bad=no
+	for(a in $aa){
+		if(! ~ $a $ff){
+			echo 'Bad venti arena partition' $a
+			fmtventi=notdone
+			export fmtventi
+			exit
+		}
+	}
+	ventiarena=$aa
+	export ventiarena
+
+	gg=`{ls /dev/sd*/isect* /dev/fs/isect* >[2]/dev/null}
+	if(~ $#gg 0){
+		echo 'You need to create a partition or partitions to hold the Venti indices.'
+		echo 'The index partition names must begin with "isect".'
+		echo
+		fmtventi=notdone
+		export fmtventi
+		exit
+	}
+	default=(-d $"gg)
+	if(! ~ $#ventiindex 0){
+		default=(-d $"ventiindex)
+	}
+
+	echo You have the following Venti index partitions.
+	ls -l $gg
+	echo
+
+	prompt $default 'Venti index partitions to use'
+	aa=`{echo $rd}
+	bad=no
+	for(a in $aa){
+		if(! ~ $a $gg){
+			echo 'Bad venti index partition' $a
+			fmtventi=notdone
+			export fmtventi
+			exit
+		}
+	}
+	ventiindex=$aa
+	export ventiindex
+
+	n=-1
+	fmta=()
+	for(a in $ventiarena){
+		do=yes
+		n=`{hoc -e 1+$n}
+		if(isventiarenas $a){
+			echo File $a is already formatted as a Venti arenas partition.
+			prompt -d no 'Reformat '$a yes no
+			do=$rd
+		}
+		if(~ $do yes)
+			fmta=($fmta arenas$n:$a)
+	}
+
+	n=-1
+	fmti=()
+	for(a in $ventiindex){
+		do=yes
+		n=`{hoc -e 1+$n}
+		if(isventiisect $a){
+			echo File $a is already formatted as a Venti index section.
+			prompt -d no 'Reformat '$a yes no
+			do=$rd
+		}
+		if(~ $do yes)
+			fmti=($fmti isect$n:$a)
+	}
+
+	echo Formatting Venti arenas and indices (this takes a while).
+	# do each disk in parallel
+	echo good >/tmp/fmt
+	dd=()
+	for(a in $fmta $fmti){
+		d=`{echo $a | sed 's!.*:(/.*/).*!\1!'}
+		if(! ~ $d $dd)
+			dd=($dd $d)
+	}
+	for(d in $dd){
+		{
+			for(a in $fmta){
+				i=`{echo $a | sed 's!(.*):(/.*/)(.*)!\1 \2 \2\3!'}
+				if(~ $i(2) $d){
+					echo $i(3) ...
+					venti/fmtarenas $i(1) $i(3) || echo bad >/tmp/fmt
+					echo done with $i(3)
+				}
+			}
+			for(a in $fmti){
+				i=`{echo $a | sed 's!(.*):(/.*/)(.*)!\1 \2 \2\3!'}
+				if(~ $i(2) $d){
+					echo $i(3) ...
+					venti/fmtisect $i(1) $i(3) || echo bad >/tmp/fmt
+					echo done with $i(3)
+				}
+			}
+		} &
+	}
+	wait
+	if(~ bad `{cat /tmp/fmt}){
+		echo There were errors formatting the indices and arenas.
+		fmtventi=ready
+		export fmtventi
+		exit errors
+	}
+
+	echo Done formatting Venti arenas and indices.
+
+	v=$ventiarena(1)
+	echo Storing Venti config on $v...
+	{
+		echo index main
+		for(i in $ventiindex)
+			echo isect $i
+		for(a in $ventiarena)
+			echo arenas $a
+	} | venti/conf -w $v
+
+	echo Initializing index...
+	venti/fmtindex $v
+
+	echo Done with Venti!
+}
+
--- /dev/null
+++ b/rc/bin/inst/gui
@@ -1,0 +1,7 @@
+#!/bin/rc
+
+cd /bin/inst
+echo blanktime 0 >/dev/vgactl
+. defs
+
+startwin 640 480
--- /dev/null
+++ b/rc/bin/inst/halt
@@ -1,0 +1,18 @@
+#!/bin/rc
+
+echo -n 'Halting file systems...'
+
+if(ps | grep -s ' venti$')
+	venti/sync -h tcp!127.0.0.1!17034
+if(ps | grep -s ' fossil$'){
+	echo fsys all halt >>/srv/fscons
+	slay fossil|rc
+}
+
+echo done
+echo
+echo Remember to take the install disk out of the drive.
+echo Feel free to turn off your computer.
+while()
+	sleep 3600
+
--- /dev/null
+++ b/rc/bin/inst/hasmbr
@@ -1,0 +1,12 @@
+#!/bin/rc
+
+if(! ~ $#* 1) {
+	echo 'usage: hasmbr /dev/sdC0/part' >[1=2]
+	exit usage
+}
+
+x=`{xd -b $1 | sed -n '32p;32q'}
+if(~ $x(16) 55 && ~ $x(17) aa) 
+	exit ''
+exit nope
+
--- /dev/null
+++ b/rc/bin/inst/hdrs
@@ -1,0 +1,7 @@
+#!/bin/rc
+
+if(! ~ $#* 1) {
+	echo 'usage: hdrs file.9gz' >[1=2]
+	exit usage
+}
+gunzip < $1 | disk/mkext -h 
--- /dev/null
+++ b/rc/bin/inst/is9660
@@ -1,0 +1,12 @@
+#!/bin/rc
+
+# 0000000  01  C  D  0  0  1 01 00  P  L  A  N     9
+   
+if(! ~ $#* 1) {
+	echo 'usage: is9660 /dev/sdC0/part' >[1=2]
+	exit usage
+}
+
+ifs=$nl {id=`{dd -if $1 -bs 2048 -skip 16>[2]/dev/null | xd -c | sed 1q | sed 's/.........(....................).*/\1/'}}
+~ $id '01  C  D  0  0  1 01'
+exit $status
--- /dev/null
+++ b/rc/bin/inst/isext2
@@ -1,0 +1,11 @@
+#!/bin/rc
+
+if(! ~ $#* 1) {
+	echo 'usage: isext2 /dev/sdC0/part' >[1=2]
+	exit usage
+}
+
+cmp -s <{dd -if $1 -bs 1 -count 2 -skip 1080 >[2]/dev/null | xd -b |sed 1q} \
+	<{echo '0000000  53 ef'}
+
+exit $status
--- /dev/null
+++ b/rc/bin/inst/isfat
@@ -1,0 +1,22 @@
+#!/bin/rc
+
+rfork e
+
+# 0000000  eb 3c 90  P  l  a  n  9  .  0  0 00 02 04 02 00
+# 0000010  02 00 02 02  P f8 14 00  ? 00 ff 00  ~ 04  } 00
+# 0000020  02  P 00 00 80 00  ) a8 04  } 00  C  Y  L  I  N
+# 0000030   D  R  I  C  A  L  F  A  T  1  6          fa 8c
+
+if(! ~ $#* 1) {
+	echo 'usage: isfat /dev/sdC0/part' >[1=2]
+	exit usage
+}
+
+arg=$1
+fn fat {
+	cmp -s <{dd -if $arg -bs 1 -count 3 -skip $1 >[2]/dev/null} <{echo -n FAT}
+}
+
+fat 54 || fat 82
+exit $status
+
--- /dev/null
+++ b/rc/bin/inst/isfossil
@@ -1,0 +1,16 @@
+#!/bin/rc
+
+if(! ~ $#* 1){
+	echo 'usage: isfossil /dev/sdC0/part' >[1=2]
+	exit usage
+}
+
+arg=$1
+if(! cmp -s <{dd -quiet 1 -if $arg -bs 1024 -iseek 127 |
+	dd -quiet 1 -bs 14 -count 1} <{echo 'fossil config'})
+	exit noconfig
+if(! cmp -s <{dd -quiet 1 -if $arg -bs 1024 -iseek 128 |
+	dd -quiet 1 -bs 4 -count 1 | xd -b | sed 1q} <{echo '0000000  37 76 ae 89'})
+	exit notwritebuffer
+exit 0
+
--- /dev/null
+++ b/rc/bin/inst/isventi
@@ -1,0 +1,13 @@
+#!/bin/rc
+
+if(! ~ $#* 1){
+	echo 'usage: isventi /dev/sdC0/part' >[1=2]
+	exit usage
+}
+
+arg=$1
+if(! cmp -s <{dd -quiet 1 -if $arg -bs 1024 -iseek 248 |
+	dd -quiet 1 -bs 13 -count 1} <{echo 'venti config'})
+	exit noconfig
+exit 0
+
--- /dev/null
+++ b/rc/bin/inst/isventiarenas
@@ -1,0 +1,13 @@
+#!/bin/rc
+
+if(! ~ $#* 1){
+	echo 'usage: isventiarenas /dev/sdC0/part' >[1=2]
+	exit usage
+}
+
+arg=$1
+if(! cmp -s <{dd -quiet 1 -if $arg -bs 1024 -iseek 256 |
+	dd -quiet 1 -bs 4 -count 1 | xd -b | sed 1q} <{echo '0000000  a9 e4 a5 e7'})
+	exit notarenas
+exit 0
+
--- /dev/null
+++ b/rc/bin/inst/isventiisect
@@ -1,0 +1,13 @@
+#!/bin/rc
+
+if(! ~ $#* 1){
+	echo 'usage: isventiisect /dev/sdC0/part' >[1=2]
+	exit usage
+}
+
+arg=$1
+if(! cmp -s <{dd -quiet 1 -if $arg -bs 1024 -iseek 256 |
+	dd -quiet 1 -bs 4 -count 1 | xd -b | sed 1q} <{echo '0000000  d1 5c 5e c7'})
+	exit notisect
+exit 0
+
--- /dev/null
+++ b/rc/bin/inst/main
@@ -1,0 +1,115 @@
+#!/bin/rc
+
+. defs
+
+while()
+{
+div=--------------------------------------
+echo
+echo $div
+echo
+echo -n 'Preparing menu...'
+
+# must be topologically sorted (by prereq)
+tasks=(\
+	configfs\
+	partdisk prepdisk\
+	fmtfossil\
+	mountfs\
+	configdist\
+	confignet\
+	mountdist\
+	fmtventi\
+	download\
+	copydist\
+	bootsetup finish stop\
+	stopether stopppp\
+)
+#	startether startppp stopether stopppp download\
+
+# these don't show up in the menu but still matter
+pseudotasks=(configip havefiles etherup etherdown pppup pppdown)
+
+for(i in $tasks $pseudotasks)
+	$i=notdone
+
+coherence
+
+for(i in $tasks $pseudotasks)
+	if(~ $#$i 0)
+		$i=notdone
+
+#
+# we believe the environment about what is done
+# only if we've confirmed it.  since the tasks list is sorted so that
+# prereqs of xxx come before xxx, it's okay to assume xxx
+# is done until proven otherwise -- either a prereq or checkdone
+# will say so.
+#
+
+done=()
+ready=()
+rm /env/done
+rm /env/ready
+for(i in $tasks) {
+	$i=done
+	for(j in `{prereq $i})
+		if(! ~ $$j done)
+			$i=notdone
+	if(~ $$i done) {
+		export $i
+		$i checkdone
+		$i=`{grep '^'$i^'=' /tmp/vars | sed -n '$p' | sed 's/.*=//'}
+	}
+
+	if(~ $$i notdone ready) {
+		okay=yes
+		for(j in `{prereq $i}) 
+			if(! ~ $$j done)
+				okay=no
+		switch($okay){
+		case yes
+			$i=ready
+			export $i
+			$i checkready
+			$i=`{grep '^'$i^'=' /tmp/vars | sed -n '$p' | sed 's/.*=//'}
+		case no
+			$i=notdone
+		}
+	}
+
+	if(~ $$i done ready)
+		$$i=($$$i $i)		# rc can be just as complicated as perl!
+}
+
+export $tasks $pseudotasks done ready
+coherence
+echo
+
+if(! ~ $#done 0) {
+	echo 'The following tasks are done: '
+	for(i in $done)
+		desc $i
+	echo
+}
+
+echo 'The following unfinished tasks are ready to be done:'
+for(i in $ready)
+	desc $i
+echo
+
+if(~ $#ready 0) {
+	echo hey you finished everything!  not supposed to happen.
+	sleep 100
+	exit
+}
+
+prompt -d $ready(1) -w '' 'Task to do' $done $ready
+
+echo
+echo $div
+
+$rd go
+$rd=done		# if it's not, the check will figure that out
+export $rd
+}
--- /dev/null
+++ b/rc/bin/inst/mainloop
@@ -1,0 +1,23 @@
+#!/bin/rc
+
+sleep 86400 &
+cd /bin/inst
+. defs
+fn sigint { }
+
+coherence
+
+disks=`{ls /dev/sd*/data >[2]/dev/null | sed 's!/dev/(sd..)/data!\1!'}
+for (i in /dev/sd*/data)
+	if(test -f $i)
+		disk/fdisk -p $i>`{basename -d $i}^/ctl >[2]/dev/null
+for(i in /dev/sd*/plan9*)
+	if(test -f $i)
+		disk/prep -p $i >`{basename -d $i}^/ctl >[2]/dev/null
+
+# we run this while() here so that ctl-d won''t exit from us -- it''ll only exit main!
+# main contains a while() loop too, to avoid the hit of 
+# continually reexecing from here.
+
+while()
+	main
--- /dev/null
+++ b/rc/bin/inst/mkini.awk
@@ -1,0 +1,59 @@
+BEGIN{
+	m = "common"
+	haveold = 0;
+	while(getline <"/n/9fat/plan9-3e.ini" > 0){
+		haveold = 1
+		if($0 ~ /\[.*\]/){
+			m = substr($0, 2, length($0)-2)
+			continue
+		}
+		if(m=="menu" && $0 ~ /^menuitem=4e,/)
+			continue
+		a[m] = a[m] $0 "\n"
+	}
+
+	a["4e"] = ""
+	while(getline <"/tmp/plan9.ini" > 0)
+		a["4e"] = a["4e"] $0 "\n"
+
+	if(a["menu"] == "" && haveold){
+		a["menu"] = "menuitem=3e, Plan 9 Third Edition\n"
+		a["3e"] = ""
+	}
+
+	if(a["common"] != ""){
+		for(i in a)
+			if(i != "4e" && i != "common" && i != "menu")
+				a[i] = a["common"] a[i]
+		delete a["common"]
+	}
+
+	bootdisk4e=ENVIRON["fs"]
+	gsub("/dev/", "boot(args|disk|file)=local!#S/", bootdisk4e)
+
+	if(!haveold)
+		print a["4e"]
+	else{
+		print "[menu]"
+		print "menuitem=4e, Plan 9 Fourth Edition"
+		print a["menu"]
+		print ""
+		delete a["menu"]
+	
+		print "[4e]"
+		print a["4e"]
+		print ""
+		delete a["4e"]
+	
+		for(i in a){
+			# BUG: if rootdir is already there we should rewrite it 
+			# sometimes into /3e/whatwasthere
+			if(a[i] ~ bootdisk4e && !(a[i] ~ /rootdir=/))
+				a[i] = "rootdir=/root/3e\n" a[i]
+			print "[" i "]"
+			gsub(/9fat!9pcdisk/, "9fat!9pc3e", a[i])
+			print a[i]
+			print ""
+		}
+	}
+}
--- /dev/null
+++ b/rc/bin/inst/mountdist
@@ -1,0 +1,222 @@
+#!/bin/rc
+
+# prereq: mountfs configdist
+# desc: locate and mount the distribution
+
+fn domount{
+	if(! test -e $mountmedia(2))
+		logprog $srvmedia
+	unmount /n/distmedia >[2]/dev/null
+	logprog $mountmedia
+}
+
+fn exitifdone{
+	if(test -f /n/dist/dist/replica/plan9.db)
+		exit
+}
+
+fn trycdimage{
+	if(test -f $1){
+		rm -f /srv/9660.dist
+		unmount /n/dist
+		9660srv 9660.dist >[2]/dev/null
+		logprog mount /srv/9660.dist /n/dist $1
+		exitifdone
+		mountdist=notdone
+		export mountdist
+		exit notdone
+	}
+}
+
+fn trycdimagebz2 {
+	if(test -f $1){
+		echo -n 'bunzip2 < '^$1^' >/n/newfs/dist/plan9.iso'
+		bunzip2 < $1 >/n/newfs/dist/_plan9.iso &&
+		mv /n/newfs/dist/_plan9.iso /n/newfs/dist/plan9.iso
+		echo
+		trycdimage /n/newfs/dist/plan9.iso
+		mountdist=notdone
+		export mountdist
+		exit notdone
+	}
+}
+
+fn havedist {
+	test -f $1/dist/replica/plan9.db ||
+	test -f $1/plan9.iso ||
+	test -f $1/plan9.iso.bz2
+}
+
+switch($1){
+case checkready
+	if(! ~ $distisfrom local && ! ~ $download done){
+		mountdist=notdone
+		export mountdist
+	}
+	if(! ~ $#mountmedia 0 1){
+		if(domount){
+			mountdist=done
+			export mountdist
+			if(mountdist checkdone)
+				exit
+		}
+		srvmedia=()
+		mountmedia=()
+		mountdist=ready
+		export srvmedia mountmedia mountdist
+	}
+		
+case go
+	fat=()
+	ext2=()
+	x9660=()
+	fossil=()
+
+	echo Please wait... Scanning storage devices...
+
+	parts=`{ls /dev/sd??/* >[2]/dev/null | grep -v '/(plan9.*|ctl|log|raw)$'}
+	for (i in $parts) {
+		echo -n '	'^$i
+		n=`{echo $i | sed 's;/;_;g'}
+		if(! test -f /tmp/localpart.$n)
+			dd -if $i -bs 2048 -count 32 -of /tmp/localpart.$n >[2]/dev/null
+		if(isfat /tmp/localpart.$n)
+			fat=($fat $i)
+		if(isext2 /tmp/localpart.$n)
+			ext2=($ext2 $i)
+		if(is9660 /tmp/localpart.$n)
+			x9660=($x9660 $i)
+		if(isfossil $i)
+			fossil=($fossil $i)
+		echo
+	}
+	echo
+	echo The following storage media were detected.
+	echo Choose the one containing the distribution.
+	echo
+	for(i in $parts){
+		switch($i){
+		case $fat
+			echo 	'	'^$i^' (microsoft fat)'
+		case $ext2
+			echo 	'	'^$i^' (linux ext2)'
+		case $x9660
+			echo 	'	'^$i^' (iso9660 cdrom)'
+		case $fossil
+			echo 	'	'^$i^' (plan9 fossil)'
+		}
+	}
+	echo
+
+	mountstatus=x
+	while(! ~ $mountstatus ''){
+		prompt -w '' 'Distribution disk' $fat $x9660 $fossil
+		disk=$rd
+
+		srvmedia=()
+		mountmedia=()
+		switch($disk){
+		case $fs
+			mountmedia=(bind /n/newfs /n/distmedia)
+		case $fat
+			srvmedia=(dossrv)
+			mountmedia=(mount /srv/dos /n/distmedia $disk)
+		case $ext2
+			srvmedia=(ext2srv -r)
+			mountmedia=(mount /srv/ext2 /n/distmedia $disk)
+		case $x9660
+			srvmedia=(9660srv)
+			mountmedia=(mount /srv/9660 /n/distmedia $disk)
+		case $fossil
+			echo 'srv fossil.mountdist' > /tmp/fossi.conf
+			echo 'fsys main config '^$disk >> /tmp/fossil.conf
+			echo 'fsys main open -AWVP' >> /tmp/fossil.conf
+			echo 'fsys main' >> /tmp/fossil.conf
+			srvmedia=(fossil/fossil -c '. /tmp/fossil.conf')
+			mountmedia=(mount /srv/fossil.mountdist /n/distmedia)
+		case *
+			echo Unknown disk type '(cannot happen)'
+			exit oops
+		}
+		export srvmedia mountmedia
+		domount
+		mountstatus=$status
+	}
+
+	first=yes
+	dir=/
+	while(~ $first yes || ! havedist /n/distmedia/$dir){
+		if(~ $first yes){
+			echo
+			echo Which directory contains the distribution?
+			echo 'Any of the following will suffice (in order of preference):'
+			echo '	- the root directory of the cd image'
+			echo '	- the directory containing plan9.iso'
+			echo '	- the directory containing plan9.iso.bz2'
+			echo 'Typing `browse'' will put you in a shell that you can use to'
+			echo 'look for the directory.'
+			echo
+			first=no
+		}
+
+		prompt -d browse 'Location of archives'
+		dir=$rd
+		if(~ $dir browse){
+			echo This is a simple shell.  Commands are:
+			echo '	cd directory	- change to directory'
+			echo '	lc				- list contents of current directory'
+			echo '	exit			- exit shell'
+			echo 
+			echo 'Move to the directory containing the distribution'
+			echo 'and then exit.'
+			echo
+			oifs=$ifs
+			ifs=$nl
+			dir=`{cdsh -r /n/distmedia}
+			ifs=$oifs
+		}
+		if(~ $#dir 0)
+			dir=safdsfdsfdsf
+		if(! ~ $#dir 1)
+			dir=$"dir
+		if(! havedist /n/distmedia/$dir)
+			echo 'No distribution found in '^`{cleanname /$dir}
+	}
+
+	distmediadir=$dir
+	export distmediadir
+
+case checkdone
+	if(! ~ $#distmediadir 1){
+		mountdist=notdone
+		export mountdist
+		exit notdone
+	}
+	if(! havedist /n/distmedia/$distmediadir && ! havedist /n/newfs/dist){
+		mountdist=notdone
+		export mountdist
+		exit notdone
+	}
+
+	exitifdone
+
+	if(test -f /n/distmedia/$distmediadir/dist/replica/plan9.db){
+		bind /n/distmedia/$distmediadir /n/dist
+		bind -a /n/dist/386/bin /bin
+		bind -a /n/dist/rc/bin /bin
+		exitifdone
+		mountdist=notdone
+		export mountdist
+		exit notdone
+	}
+
+	trycdimage /n/distmedia/$distmediadir/plan9.iso
+	trycdimage /n/newfs/dist/plan9.iso
+
+	trycdimagebz2 /n/distmedia/$distmediadir/plan9.iso.bz2
+	trycdimagebz2 /n/newfs/dist/plan9.iso.bz2
+
+	mountdist=notdone
+	export mountdist
+	exit notdone
+}
--- /dev/null
+++ b/rc/bin/inst/mountfossil
@@ -1,0 +1,104 @@
+#!/bin/rc
+
+switch($1){
+case checkready checkdone
+	if(! ~ $fmtfossil done){
+		mountfs=notdone
+		export mountfs
+		exit
+	}
+	if(! test -f /dev/sd*/fossil* && ! test -f /dev/fs/fossil*){
+		mountfs=notdone
+		export mountfs
+		exit
+	}
+	if(! ~ $#fossil 1 || ! test -f $fossil){
+		mountfs=ready
+		export mountfs
+		exit
+	}
+	if(! ps | grep -s ' fossil$'){
+		echo 'srv -p fscons' > /env/fossilconf
+		echo 'srv -AP fossil' >> /env/fossilconf
+		fossil/conf $fossil | sed 's/^fsys main open .*/& -AWVP/' |
+			sed 's/^fsys main snaptime .*//' >> /env/fossilconf
+		if(! logprog fossil/fossil -c .' /env/fossilconf'>>[2]/srv/log){
+			echo 'fossil: '^$status
+			mountfs=ready
+			export mountfs
+			exit oops
+		}
+		if(! test -f /srv/fossil){
+			echo 'fossil did not create /srv/fossil'
+			mountfs=ready
+			exit oops
+		}
+		cat /srv/fscons >>/srv/log &
+		if(! logprog mount -c /srv/fossil /n/newfs){
+			echo 'mount: '^$status
+			mountfs=ready
+			export mountfs
+			exit oops
+		}
+		fs=$fossil
+		export fs
+	}
+	if(! test -s /n/newfs/adm/users){
+		echo fsys main create /active/adm adm sys d775 >>/srv/fscons
+		echo fsys main create /active/adm/users adm sys 664 >>/srv/fscons
+		echo uname upas :upas >>/srv/fscons
+		echo users -w >>/srv/fscons
+		sleep 2
+	}
+	if(! test -s /n/newfs/adm/users){
+		echo 'could not create /adm/users'
+		mountfs=ready
+		export mountfs
+		exit oops
+	}
+	for(i in dist dist/replica dist/replica/client){
+		if(! test -d /n/newfs/$i)
+			echo fsys main create /active/$i sys sys d775 >>/srv/fscons
+		sleep 2
+	}
+	if(! test -d /n/newfs/dist/replica/client){
+		echo 'could not create /dist/replica/client'
+		mountfs=ready
+		export mountfs
+		exit oops
+	}
+	if(! test -e /n/newfs/dist/replica/client/plan9.db){
+		echo fsys main create /active/dist/replica/client/plan9.db sys sys 664 >>/srv/fscons
+		echo fsys main create /active/dist/replica/client/plan9.log sys sys a664 >>/srv/fscons
+	}
+	if(test -d /n/newfs/dist/replica/client && test -f /n/newfs/adm/users){
+		mountfs=done
+		export mountfs
+		exit
+	}
+	mountfs=ready
+	export mountfs
+	exit
+
+case go
+	echo 'The following partitions named fossil* were found.'
+	echo
+	echo 'Please choose one to use as the installation file system'
+	echo 'for your Plan 9 installation.'
+	echo
+	files=(`{ls /dev/sd*/fossil* /dev/fs/fossil* >[2]/dev/null})
+	ls -l $files
+	echo
+	if(~ $#fossil 1 && ~ $fossil $files)
+		default=(-d $fossil)
+	if not if(~ $#files 1)
+		default=(-d $files)
+	if not
+		default=()
+	prompt $default 'Fossil partition' $files
+	slay fossil|rc
+	fossil=$rd
+	export fossil
+}
+
+
--- /dev/null
+++ b/rc/bin/inst/mountfs
@@ -1,0 +1,14 @@
+#!/bin/rc
+
+# desc: choose and mount file system partition
+# prereq: configfs
+
+switch($fstype){
+case fossil fossil+venti
+	exec mountfossil $*
+case *
+	mountfs=notdone
+	export mountfs
+	exit
+}
+
--- /dev/null
+++ b/rc/bin/inst/moveoldfs
@@ -1,0 +1,72 @@
+#!/bin/rc
+
+# desc: move an old third edition plan 9 file system out of the way
+# prereq: mountfs
+
+rootfiles=(\
+	386\
+	68000\
+	68020\
+	LICENSE\
+	NOTICE\
+	acme\
+	adm\
+	alpha\
+	arm\
+	cron\
+	dist\
+	fd\
+	lib\
+	lp\
+	mail\
+	mips\
+	mnt\
+	n\
+	power\
+	rc\
+	sparc\
+	sys\
+	tmp\
+	usr/glenda\
+	wrap\
+)
+
+switch($1){
+case checkready
+	if(! test -d /n/kfs/wrap){
+		moveoldfs=done
+		export moveoldfs
+	}
+
+case go
+	if(test -d /n/kfs/wrap){
+		echo 'You have a Third Edition Plan 9 installation on '^$fs^'.'
+		echo 'We need to move the old file system out of the way (into /3e)'
+		echo 'in order to continue.'
+		echo
+		prompt 'Move old file system' y n
+		switch($rd){
+		case y
+			kname=`{kfsname $fs}
+			log Moving old Plan 9 installation into /3e on kfs
+			logprog disk/kfscmd -n$kname 'create /3e sys sys 555 d' >>[2]/srv/log
+			logprog disk/kfscmd -n$kname 'create /3e/usr sys sys 555 d' >>[2]/srv/log
+			for(i in $rootfiles)
+				if(test -e /n/kfs/$i)
+					logprog disk/kfscmd -n$kname 'rename /'^$i^' /3e/'^$i
+			# copy extant /adm/users in case there have been modifications
+			logprog disk/kfscmd -n$kname 'create /adm adm adm 555 d' >>[2]/srv/log
+			logprog cp /n/kfs/3e/adm/users /n/kfs/adm/users >>[2]/srv/log
+
+		case n
+			echo 'Okay, but we can''t continue.'
+			echo
+		}
+	}
+
+case checkdone
+	if(test -d /n/kfs/wrap){
+		moveoldfs=notdone
+		export moveoldfs
+	}
+}
--- /dev/null
+++ b/rc/bin/inst/partdisk
@@ -1,0 +1,73 @@
+#!/bin/rc
+
+# desc: edit partition tables (e.g., to create a plan 9 partition)
+# prereq: configfs
+
+switch($1){
+case go
+	disks=`{ls /dev/sd*/data >[2]/dev/null | sed 's!/dev/(sd..)/data!\1!'}
+	if(~ $#disks 0) {
+		echo 'No disk devices were found on your system.'
+		echo 'The installation process cannot continue.'
+		exit giveup
+	}
+	
+	echo 'The following disk devices were found.'
+	echo
+	for(i in $disks) {
+		desc=`{cat /dev/$i/ctl | sed 1q | sed 's/inquiry //'}
+		echo $i '-' $desc
+		echo e | disk/fdisk -r /dev/$i/data >[2]/dev/null | grep -v '^   mbr'
+		echo
+	}
+	
+	okay=no
+	defdisk=$disks(1)
+
+	if(~ $#disks 1)
+		default=(-d $disks)
+	if not
+		default=()
+	prompt $default 'Disk to partition' $disks
+	disk=$rd
+
+	if(! hasmbr /dev/$disk/data) {
+		echo 'The disk you selected HAS NO master boot record on its first sector.'
+		echo '(Perhaps it is a completely blank disk.)'
+		echo 'You need a master boot record to use the disk.'
+		echo 'Should we install a default master boot record?'
+		echo
+		prompt 'Install mbr' y n
+		switch($rd) {
+		case y
+			disk/mbr -m /386/mbr /dev/$disk/data
+			pickdisk=done
+		}
+	}
+	echo
+	echo 'This is disk/fdisk; use it to create a Plan 9 partition.'
+	echo 'If there is enough room, a Plan 9 partition will be'
+	echo 'suggested; you can probably just type ''w'' and then ''q''.'
+	echo
+	disk/fdisk -a /dev/$disk/data
+	disk/fdisk -p /dev/$disk/data >/dev/$disk/ctl >[2]/dev/null
+	for(i in /dev/sd*/plan9*){
+		if(test -f $i){
+			d=`{basename -d $i}
+			disk/prep -p $i >$d/ctl >[2]/dev/null
+		}
+	}
+
+case checkdone
+	# we want at least one disk with both an mbr and a plan9 partition
+	mbrandplan9=0
+	disks=`{ls /dev/sd*/plan9 >[2]/dev/null | sed 's!/dev/(sd..)/plan9!\1!'}
+	for(disk in $disks) {
+		if(hasmbr /dev/$disk/data)
+			mbrandplan9=1
+	}
+	if(~ $mbrandplan9 0){
+		partdisk=notdone
+		export partdisk
+	}
+}
--- /dev/null
+++ b/rc/bin/inst/prepdisk
@@ -1,0 +1,63 @@
+#!/bin/rc
+
+# desc: subdivide plan 9 disk partition
+# prereq: partdisk
+
+fn autotype {
+	if(~ $fstype fossil)
+		echo -a 9fat -a nvram -a fossil -a swap
+	if(~ $fstype fossil+venti)
+		echo -a 9fat -a nvram -a arenas -a isect -a fossil -a swap # -a other
+}
+
+switch($1) {
+case checkready
+	if(! test -f /dev/sd*/plan9*){
+		prepdisk=notdone
+		export prepdisk
+	}
+
+case go
+	echo 'The following Plan 9 disk partitions were found.'
+	echo
+	disks=(/dev/sd*/plan9*)
+	for (i in $disks){
+		echo $i
+		echo q | disk/prep -r $i >[2]/dev/null
+		echo
+	}
+	if(~ $#disks 1)
+		default=(-d $disks)
+	if not
+		default=()
+	prompt $default 'Plan 9 partition to subdivide' $disks
+	disk=$rd
+
+	echo 'This is disk/prep; use it to subdivide the Plan 9 partition.'
+	echo 'If it is not yet subdivided, a sensible layout will be suggested;'
+	echo 'you can probably just type ''w'' and then ''q''.'
+	echo
+	disk/prep `{autotype} $disk
+	disk/prep -p $disk >`{basename -d $disk}^/ctl >[2]/dev/null
+
+case checkdone
+	if(! test -f /dev/sd*/9fat)
+		prepdisk=ready
+
+	if(! ~ $prepdisk ready){
+		prepdisk=done
+		switch($fstype){
+		case fossil
+			if(! test -f /dev/sd*/fossil* && ! test -f /dev/fs/fossil*)
+				prepdisk=ready
+		case fossil+venti
+			if(! test -f /dev/sd*/fossil* && ! test -f /dev/fs/fossil*)
+				prepdisk=ready
+			if(! test -f /dev/sd*/arenas && ! test -f /dev/fs/arenas*)
+				prepdisk=ready
+			if(! test -f /dev/sd*/isect && ! test -f /dev/fs/isect*)
+				prepdisk=ready
+		}
+	}
+	export prepdisk
+}
--- /dev/null
+++ b/rc/bin/inst/replcfg
@@ -1,0 +1,18 @@
+#!/bin/rc
+
+s=/n/dist/dist/replica
+serverroot=/n/dist
+serverlog=$s/plan9.log
+serverproto=$s/plan9.proto
+fn servermount { status='' } 
+fn serverupdate { status='' }
+
+fn clientmount { status='' }
+c=/n/newfs/dist/replica
+clientroot=/n/newfs
+clientproto=$c/plan9.proto
+clientdb=$c/client/plan9.db
+clientexclude=(dist/replica/client)
+clientlog=$c/client/plan9.log
+
+applyopt=(-t -u -T$c/client/plan9.time)
--- /dev/null
+++ b/rc/bin/inst/startether
@@ -1,0 +1,30 @@
+#!/bin/rc
+
+# desc: activate ethernet card
+# prereq: configether
+
+switch($1) {
+case checkready
+	if(isipdevup /net/ether0) {
+		startether=done
+		export startether
+	}
+
+case go
+	if(isipdevup /net/ether0)
+		exit
+
+	log starting ethernet $ethermethod config
+	switch($ethermethod) {
+	case manual
+		ip/ipconfig -g $gwaddr ether /net/ether0 $ipaddr $ipmask >>[2]/srv/log
+	case dhcp
+		ip/ipconfig $dhcphost -D >>/srv/log >[2=1]
+	}
+
+case checkdone
+	if(! isipdevup /net/ether0) {
+		startether=notdone
+		export startether
+	}
+}
--- /dev/null
+++ b/rc/bin/inst/startppp
@@ -1,0 +1,30 @@
+#!/bin/rc
+
+# desc: activate ppp connection
+# prereq: configppp
+
+switch($1) {
+case checkready checkdone
+	if (isipdevup '^pkt[0-9]')
+		startppp=done
+	export startppp
+
+case go
+	if(isipdevup '^pkt[0-9]')
+		exit
+
+	ctl=$pppdev^ctl
+	echo b115200 >$ctl
+
+	switch($pppmethod) {
+	case manual
+		echo 
+		echo 'Please dial the modem, and type ctl-d when PPP has started.'
+		echo 'You may need to type ctl-m to send modem commands.'
+		echo
+		ip/ppp -f -u -b b^$pppbaud -p /dev/^$pppdev
+
+	case auto
+		ip/ppp -f -b b^$pppbaud -p /dev/^$pppdev -s $"pppuser:$"ppppasswd -t 'atdt'^$"pppphone
+	}
+}
--- /dev/null
+++ b/rc/bin/inst/startwin
@@ -1,0 +1,46 @@
+#!/bin/rc
+
+fn time { date | sed 's/.........$//'}
+
+rm -f /srv/log
+
+if(~ $#* 2) {
+	wid=$1
+	ht=$2
+} 
+if not {
+	scr=(`{cat /dev/draw/new >[2]/dev/null || status=''})
+	wid=$scr(7)
+	ht=$scr(8)
+}
+
+if(test $ht -gt 800)
+	ht=800
+
+if(test $wid -gt 800)
+	wid=800
+
+statwid=`{hoc -e $wid^'*.2'}
+if(test $statwid -lt 180)
+	statwid=180
+if(test $statwid -gt 300)
+	statwid=300
+
+logwid=`{hoc -e $wid^-$statwid}
+if(test $logwid -gt 1000)
+	logwid=1000
+
+loght=`{hoc -e $ht^'*.25'}
+if(test $loght -lt 130)
+	loght=130
+
+textht=`{hoc -e $ht^-$loght}
+
+window 0,$textht,$statwid,$ht stats -lmisce
+window $statwid,$textht,^`{hoc -e $logwid+$statwid}^,$ht tailfsrv
+window 0,0,^`{hoc -e $logwid+$statwid}^,$textht inst/mainloop
+
+while(! test -f /srv/log)
+	sleep 1
+
+log `{time} Installation process started
--- /dev/null
+++ b/rc/bin/inst/stop
@@ -1,0 +1,50 @@
+#!/bin/rc
+
+# desc: save the current installation state, to be resumed later
+# prereq: 
+# mustdo: 
+
+switch($1) {
+case checkdone
+	stop=notdone
+	export stop
+
+case checkready
+	if(~ $cdboot yes){
+		stop=notdone
+		export stop
+	}
+
+case go
+	coherence
+	switch($2){
+	case finished
+		echo 'We need to write the state of the current installation to the install floppy,'
+		echo 'so that you can pick up from here if, for example, you want to set up'
+		echo 'more boot methods.'
+		echo
+	case *
+		echo 'We need to write the state of the current installation to the install floppy.'
+		echo 'so that you can pick up from here when you wish to continue.'
+		echo
+	}
+	echo -n 'Please make sure the install floppy is in the floppy drive and press enter.'
+	read >/dev/null >[2]/dev/null
+
+	if(! a:) {
+		echo 'Couldn''t mount the floppy disk; sorry.'
+		exit
+	}
+
+	if(cp /tmp/vars /n/a:/9inst.cnf || cp /tmp/vars /n/a:/9inst.cnf) {
+		echo 'Your install state has been saved to the install floppy.'
+		if(~ $2 finished){
+			echo
+			echo 'Congratulations; you''ve completed the install.'
+		}
+		echo
+		halt
+	}
+
+	echo 'Couldn''t save the state to your install floppy.  Sorry.'
+}
--- /dev/null
+++ b/rc/bin/inst/stopether
@@ -1,0 +1,20 @@
+#!/bin/rc
+
+# desc: shut down the ethernet connection
+# prereq:
+
+
+switch($1) {
+case checkready
+	if(! isipdevup /net/ether0) {
+		stopether=notdone
+		export stopether
+	}
+
+case go
+	ip/ipconfig ether /net/ether0 unbind
+
+case checkdone
+	stopether=notdone
+	export stopether
+}
--- /dev/null
+++ b/rc/bin/inst/stopppp
@@ -1,0 +1,19 @@
+#!/bin/rc
+
+# desc: shut down the ppp connection
+# prereq:
+
+switch($1) {
+case checkready
+	if(! ~ $#pppdev 1 || ! isipdevup '^pkt[0-9]') {
+		stopppp=notdone
+		export stopppp
+	}
+
+case go
+	kill ppp | rc
+
+case checkdone
+	stopppp=notdone
+	export stopppp
+}
--- /dev/null
+++ b/rc/bin/inst/textonly
@@ -1,0 +1,15 @@
+#!/bin/rc
+
+# text-only install
+cd /bin/inst
+. defs
+
+textinst=1
+export textinst
+
+tailfsrv &
+while(! test -f /srv/log)
+	sleep 1
+log `{date} Installation process started
+inst/mainloop
+
--- /dev/null
+++ b/rc/bin/inst/watchfd
@@ -1,0 +1,17 @@
+#!/bin/rc
+
+p=`{ps | grep $1 | sed 's/[^ ]* +([^ ]+) .*/\1/' }
+while(! ~ $#p 1) {
+	sleep 1
+	p=`{ps | grep $1 | sed 's/[^ ]* +([^ ]+) .*/\1/'}
+}
+p=$p(1)
+
+baropt='-w 145,129,445,168'
+if(~ $textinst 1)
+	baropt=-t
+
+{
+	while(test -f /proc/$p/fd)
+		grep '^ *'^$2^' ' /proc/$p/fd >[2]/dev/null
+} | awk '{print $9 " '^$3^'"; fflush("/dev/stdout")}' | bargraph $baropt $4
--- /dev/null
+++ b/rc/bin/inst/xxx
@@ -1,0 +1,9 @@
+#!/bin/rc
+
+ip/ipconfig
+echo '	auth=204.178.31.3
+	authdom=cs.bell-labs.com' >>/net/ndb
+ndb/cs
+auth/factotum
+bind -a /bin/auth /
+cpu -e clear -h tcp!204.178.31.2
--- a/sys/lib/dist/mkfile
+++ b/sys/lib/dist/mkfile
@@ -5,6 +5,3 @@
 	bind pc/plan9.ini.cd /n/src9/cfg/plan9.ini
 	disk/mk9660 -9cj -B 386/9bootiso -p pc/cdproto -s /n/src9 -v 'Plan 9 Front' $target
 	unmount /n/src9/cfg/plan9.ini
-
-%.bz2: %
-	bzip2 $prereq
--- a/sys/lib/dist/pc/glenda/bin/rc/riostart
+++ /dev/null
@@ -1,4 +1,0 @@
-#!/bin/rc
-
-window '0 0 100 100' games/clock
-window '80 80 610 360' /usr/glenda/lib/first.window
--- a/sys/lib/dist/pc/glenda/lib/first.window
+++ /dev/null
@@ -1,11 +1,0 @@
-#!/bin/rc
-echo -n readme > /dev/label
-echo 'You have completed the Installation Process.'
-
-cat<<'!'
-
-Welcome to Plan 9.
-This is rc.
-!
-
-exec rc
--- a/sys/lib/dist/pc/glenda/lib/profile
+++ /dev/null
@@ -1,16 +1,0 @@
-if(test -f '#m/mousectl') {
-	echo -n accelerated > '#m/mousectl'
-	echo -n 'res 3' > '#m/mousectl'
-}
-user=`{cat /dev/user}
-home=/usr/$user
-bind -a $home/bin/rc /bin
-bind -a $home/bin/$cputype /bin
-bind -c $home/tmp /tmp
-rio -si inst/gui
-echo 
-echo
-echo 'failed to start rio.  you can start a text-based installation by running'
-echo
-echo '	inst/textonly'
-echo
--- a/sys/lib/dist/pc/inst/bootfloppy
+++ /dev/null
@@ -1,47 +1,0 @@
-#!/bin/rc
-
-rfork e
-
-echo
-echo 'Insert a disk other than your installation boot disk'
-echo 'into your floppy drive; it will be erased to create'
-echo 'the boot floppy.'
-echo
-echo -n 'Press enter when ready.'
-read >/dev/null >[2]/dev/null
-
-if(~ $#adisk 1)
-	;	# do nothing
-if not if(~ $#bootfile 0)
-	adisk=/dev/fd0disk
-if not {
-	switch($bootfile) {
-	case sd*
-		adisk=`{echo $bootfile | sed 's#(sd..).*#/dev/\1/data#'}
-	case fd*
-		adisk=`{echo $bootfile | sed 's#(fd.).*#/dev/\1disk#'}
-	case *
-		echo 'unknown bootfile '^$bootfile^'; mail 9trouble@plan9.bell-labs.com'
-		exit oops
-	}
-}
-
-if(! ~ `{ls -l $adisk | awk '{print $6}'} 1474560){
-	echo 'Will not format non-floppy disk '^$"adisk. >[1=2]
-	exit 'bad adisk'
-}
-
-log Formatting boot floppy
-if (test -e  /n/newfs/386/9loadnousb)
-	bind /n/newfs/386/9loadnousb /n/newfs/386/9load	# cater to old bioses
-disk/format -b /386/pbs \
-	-fd $adisk /n/newfs/386/9load /n/newfs/386/9pcdisk.gz \
-	/tmp/plan9ini.bak
-x=$status
-
-if(~ $x ''){
-	echo 
-	echo 'Done!'
-	echo
-}
-exit $x
--- a/sys/lib/dist/pc/inst/bootplan9
+++ /dev/null
@@ -1,55 +1,0 @@
-#!/bin/rc
-
-first=`{ls -p '#S' | sed 1q}
-if(! ~ $first $disk) {
-	echo 'warning: The plan 9 partition is not on the boot disk,'
-	echo 'so making it the active partition will have no effect.'
-}
-
-p9offset=`{grep '^part 9fat ' /dev/$disk/ctl |awk '{print $3}'}
-if(! ~ $#p9offset 1) {
-	echo 'could not find plan 9 partition.'
-	echo 'cannot happen'
-	exit bad
-}
-
-if(test $p9offset -gt 4128695) {	# 65536 * 63 - 10
-	echo 
-	echo 'Your Plan 9 partition is more than 2GB into your disk,'
-	echo 'and the master boot records used by Windows 9x/ME'
-	echo 'cannot access it (and thus cannot boot it).'
-	echo
-	echo 'You can install the Plan 9 master boot record, which can load'
-	echo 'partitions far into the disk.'
-	echo 
-}
-
-echo 'If you use the Windows NT/2000/XP master boot record'
-echo 'or a master boot record from a Unix clone (e.g., LILO or'
-echo 'FreeBSD bootmgr), it is probably safe to continue using'
-echo 'that boot record rather than install the Plan 9 boot record.'
-echo
-prompt 'Install the Plan 9 master boot record' y n 
-switch($rd) {
-case n
-	;
-case y
-	disk/mbr -m /386/mbr /dev/$disk/data
-}
-
-log Setting Plan 9 partition active.
-p9part=`{disk/fdisk /dev/$disk/data >[2]/dev/null </dev/null | 
-		grep PLAN9 | sed 1q | sed 's/ *(p.) .*/\1/'}
-if(~ $#p9part 0){
-	echo 'You have no Plan 9 partitions (How could this happen?)' >[1=2]
-	exit 'no plan 9 partition found'
-}
-p9part=$p9part(1)
-{ echo 'A '^$p9part; echo w } | disk/fdisk /dev/$disk/data >[2]/dev/null >/dev/null
-x=$status
-if(~ $x '' '|'){
-	echo
-	echo 'The Plan 9 partition is now marked as active.'
-	exit ''
-}
-exit $x
--- a/sys/lib/dist/pc/inst/bootsetup
+++ /dev/null
@@ -1,125 +1,0 @@
-#!/bin/rc
-
-# desc: create a boot floppy or configure hard disk to boot plan 9
-# prereq: copydist
-
-switch($1) {
-case go
-	echo
-	echo 'Initializing Plan 9 FAT configuration partition (9fat)'
-	echo
-	
-	fat=(/dev/sd*/9fat)
-	fat=$fat(1)
-	disk=`{echo $fat | sed 's:/dev/::;s:/9fat::'}
-	bootfs=`{echo $fs | sed 's:/dev/(sd..)/(.*):\1!\2:'}
-	bootfat=`{echo $fs | sed 's:/dev/(sd..)/(.*):\1!9fat:'}
-	if(! test -f /dev/$disk/9fat) {
-		echo 'You have no 9fat partition.  Can''t setup booting.'
-		exit
-	}
-
-	if(! test -f /tmp/plan9.ini) {
-		{
-			sfs=`{echo $fs | sed 's;/dev;#S;'}
-			if(~ $fstype fossil fossil+venti){
-				echo bootfile'='$bootfat!9pcf
-				echo 'bootargs=local!'^$sfs
-				echo 'bootdisk=local!'^$sfs
-			}
-			if not {
-				echo bootfile'='$bootfs!/386/9pcdisk
-				echo 'bootdisk=local!'^$sfs
-			}
-			if(~ $fstype fossil+venti){
-				venti=`{echo $ventiarena | sed 's;/dev;#S;'}
-				echo venti'='^$venti
-			}
-			# sort -u avoids dups which could otherwise trigger
-			# pointless boot menus.
-			grep -v '(^\[)|menuitem|adisk|bootfile|bootdisk|bootargs|nobootprompt|mouseport|vgasize|monitor|cdboot' /tmp/plan9.orig |
-				sort -u
-			echo 'mouseport='^$mouseport
-			echo 'monitor='^$monitor
-			echo 'vgasize='^$vgasize
-		} >/tmp/plan9.ini
-	}
-	if(! test -f /tmp/plan9ini.bak)
-		cp /tmp/plan9.ini /tmp/plan9ini.bak
-
-	need9fatformat=no
-	if(! isfat /dev/$disk/9fat)
-		need9fatformat=yes
-	if not if(! mount -c /srv/dos /n/9fat /dev/$disk/9fat >[2]/dev/null)
-		need9fatformat=yes
-	if not if(! test -f /n/9fat/plan9.ini)
-		need9fatformat=yes
-
-	if (test -e  /n/newfs/386/9loadnousb)
-		bind /n/newfs/386/9loadnousb /n/newfs/386/9load	# cater to old bioses
-	if(~ $need9fatformat yes){
-		log Initializing Plan 9 FAT partition.
-		disk/format -r 2 -d -b /386/pbs \
-			/dev/$disk/9fat /n/newfs/386/9load
-		# silently install pbslba if the partition is way into the disk.
-		# it''s our only hope.  only need this for >8.5GB into the disk.
-		# but...
-		# there are so few non-LBA bioses out
-		# there anymore that we'll do this even if we're only 2GB into
-		# the disk.  it's just not worth the headaches of dealing with
-		# crappy bioses that don't address the whole 8.5GB properly
-
-		9fatoffset=`{grep '^part 9fat ' /dev/$disk/ctl | awk '{print $4}'}
-		if(! ~ $#9fatoffset 1) {
-			echo 'could not find plan 9 partition.'
-			echo 'cannot happen'
-			exit bad
-		}
-		if(test $9fatoffset -gt 2097152)	# 2GB
-			disk/format -b /386/pbslba /dev/$disk/9fat
-
-		mount -c /srv/dos /n/9fat /dev/$disk/9fat
-	}
-
-	if(! test -f /n/9fat/4e){
-		logprog cp /n/newfs/386/9load /n/9fat/9load
-		logprog cp /n/newfs/386/9pcf /n/9fat/9pcf
-		if(test -f /n/9fat/plan9.ini && ! test -f /n/9fat/plan9-3e.ini)
-			logprog mv /n/9fat/plan9.ini /n/9fat/plan9-3e.ini
-		if(test -f /n/9fat/9pcdisk && ! test -f /n/9fat/9pc3e)
-			logprog mv /n/9fat/9pcdisk /n/9fat/9pc3e
-
-		awk -f /bin/inst/mkini.awk >/n/9fat/plan9.ini
-		>/n/9fat/4e
-	}
-
-	echo
-	echo 'There are myriad ways to boot a Plan 9 system.'
-	echo 'You can use any of the following.'
-	echo
-	echo '  floppy - create a boot floppy'
-	echo '  plan9  - make the plan 9 disk partition the default for booting'
-	echo '  win9x  - add a plan 9 option to windows 9x boot menu'
-	echo '  winnt  - add a plan 9 option to windows nt/2000/xp boot manager'
-	echo
-	echo 'If you are upgrading an extant third edition installation and booting'
-	echo 'from something other than a floppy, you needn''t run anything here.'
-	echo 'Just type ctl-d.'
-
-	oldbootsetup=$didbootsetup
-	didbootsetup=1
-	export didbootsetup
-	prompt 'Enable boot method' floppy plan9 win9x winnt
-	
-	if(! boot$rd){
-		didbootsetup=$oldbootsetup
-		export didbootsetup
-	}
-
-case checkdone
-	xxxfat=(/dev/sd*/9fat)
-	if(! isfat $xxxfat(1) || ! ~ $didbootsetup 1){
-		bootsetup=ready
-		export bootsetup
-	}
-}
--- a/sys/lib/dist/pc/inst/bootwin9x
+++ /dev/null
@@ -1,117 +1,0 @@
-#!/bin/rc
-
-dosdisk=`{ls /dev/sd??/dos >[2]/dev/null | sed 1q | sed 's!.*/(.*)/dos!\1!'}
-if(~ $#dosdisk 0 || ! c: || ! test -f /n/c:/autoexec.bat || ! test -f /n/c:/config.sys) {
-	echo 'Could not find autoexec.bat or config.sys on the first FAT disk.'
-	exit bad
-}
-
-for (i in autoexec config msdos)
-	if(test -f /n/c:/$i.p9) {
-		echo 'A Plan 9 backup already exists; will not edit system files again.'
-		exit bad
-	}
-
-for (i in autoexec.bat config.sys msdos.sys)
-	if(! cp /n/c:/$i /n/c:/^`{echo $i | sed 's/\.(bat|sys)$/.p9/'}) {
-		echo 'Could not back up '^$i^'; will not continue.'
-		exit bad
-	}
-
-if(! test -d /n/c:/plan9 && ! mkdir /n/c:/plan9) {
-	echo 'Could not create directory /n/c:/plan9.'
-	exit bad
-}
-
-if(! cp /n/newfs/386/^(9load ld.com 9pcdisk) /tmp/plan9ini.bak /n/c:/plan9) {
-	echo 'Could not copy Plan 9 boot files into /n/c:/plan9.'
-	exit bad
-}
-
-chmod +w /n/c:/autoexec.bat /n/c:/config.sys /n/c:/msdos.sys
-
-if(grep -si 'Plan ?9' /n/c:/config.sys || grep -si 'Plan ?9' /n/c:/autoexec.bat) {
-	echo 'Plan 9 entries already in config.sys or autoexec.bat.'
-	echo 'Not changing them; refer to Plan 9 install documentation'
-	echo 'to configure manually.'
-	exit bad
-}
-
-if(! grep -si '\[menu\]' /n/c:/config.sys) {
-	{
-		echo 1
-		echo i
-		echo '[menu]
'
-		echo 'menuitem=windows, Windows
'
-		echo 'menudefault=windows
'
-		echo '
'
-		echo '[common]
'
-		echo '
'
-		echo '[windows]
'
-		echo .
-		echo w
-		echo q
-	} | ed /n/c:/config.sys >/dev/null >[2]/dev/null
-}
-
-{
-	echo 1
-	echo '/\[[Mm][Ee][Nn][Uu]\]'
-	echo '?^[Mm][Ee][Nn][Uu][Ii][Tt][Ee][Mm]='
-	echo a
-	echo 'menuitem=plan9, Plan 9 from Bell Labs
'
-	echo .
-	echo '$'
-	echo a
-	echo '
'
-	echo '[plan9]
'
-	echo '
'
-	echo .
-	echo w
-	echo q
-} | ed /n/c:/config.sys >/dev/null>[2]/dev/null
-
-{
-	echo 1
-	echo i
-	echo '@echo off
'
-	echo 'if %config%==plan9 goto plan9
'
-	echo 'goto notplan9
'
-	echo ':plan9
'
-	echo 'plan9\ld '^$dosdisk^'!dos!plan9/9load
'
-	echo ':notplan9
'
-	echo .
-	echo w
-	echo q
-} | ed /n/c:/autoexec.bat >/dev/null>[2]/dev/null
-
-fn zeroopt {
-	if(grep -s '^'^$1^'=1' /n/c:/msdos.sys) {
-		{
-			echo '/^'^$1^'=1/s/=1/=0/'
-			echo w
-			echo q
-		} | ed /n/c:/msdos.sys>/dev/null>[2]/dev/null
-	}
-	if not if (grep -s '^'^$1^'=0' /n/c:/msdos.sys)
-		;
-	if not {
-		{
-			echo 1
-			echo i
-			echo '[Options]
'
-			echo 'Logo=0
'
-			echo .
-			echo w
-			echo q
-		} | ed /n/c:/msdos.sys>/dev/null>[2]/dev/null
-	}
-}
-
-if(grep -si '^\[paths\]' /n/c:/msdos.sys){	# Windows 9x rather than DOS
-	zeroopt Logo
-#	zeroopt BootGUI
-}
-		
-echo 'Plan 9 added to Windows 9X boot menu.'
-exit ''
--- a/sys/lib/dist/pc/inst/bootwinnt
+++ /dev/null
@@ -1,47 +1,0 @@
-#!/bin/rc
-
-if(! c: || ! test -f /n/c:/boot.ini) {
-	echo 'Could not find NT''s boot.ini on the first FAT disk.'
-	exit bad
-}
-
-if(test -f /n/c:/boot.p9) {
-	echo 'A Plan 9 backup already exists; will not edit boot.ini again.'
-	exit bad
-}
-
-if(! cp /n/c:/boot.ini /n/c:/boot.p9) {
-	echo 'Could not back up boot.ini; will not continue.'
-	exit bad
-}
-
-chmod +w /n/c:/boot.ini
-
-if(! grep -si '\[operating systems\]' /n/c:/boot.ini) {
-	echo 'Could not parse boot.ini.'
-	exit bad
-}
-
-if(grep -si 'Plan 9' /n/c:/boot.ini) {
-	p9file=`{grep 'Plan 9' /n/c:/boot.ini | sed 1q | sed 's/=.*//'}
-	if(! ~ $p9file [Cc]:'\'*) {
-		echo 'Unexpected Plan 9 entry in boot.ini already; not continuing.'
-		exit bad
-	}
-}
-
-if not {
-	p9file='c:\bootsect.p9'
-	echo 'c:\bootsect.p9 = "Plan 9 from Bell Labs"
' >>/n/c:/boot.ini
-}
-
-p9file=/n/^`{echo $p9file | sed 's!\\!/!g'}
-
-
-if(dd -if /dev/$disk/plan9 -bs 512 -count 1 -of $p9file >/dev/null >[2]/dev/null) {
-	echo 'Plan 9 added to Windows NT boot menu.'
-	exit ''
-}
-
-echo 'Error copying Plan 9 boot sector to file.'
-exit bad
--- a/sys/lib/dist/pc/inst/configarch
+++ /dev/null
@@ -1,40 +1,0 @@
-#!/bin/rc
-
-# desc: set source of distribution archives
-# prereq: mountfs
-
-switch($1) {
-case go
-	echo
-	echo 'Will you be using a distribution archive on local media or the internet?'
-	echo
-
-	prompt 'Distribution is from' local internet
-	archmedium=$rd
-	export archmedium
-
-	switch($archmedium) {
-	case local
-		exec configlocal go
-	case internet
-		exec configip go
-	}
-
-case checkdone
-	switch($#archmedium) {
-	case 1
-		switch($archmedium) {
-		case local
-			exec configlocal checkdone
-		case internet
-			exec configip checkdone
-		case *
-			configarch=notdone
-			export configarch
-		}
-	case *
-		configarch=notdone
-		export configarch
-	}
-}
-		
--- a/sys/lib/dist/pc/inst/configdist
+++ /dev/null
@@ -1,22 +1,0 @@
-#!/bin/rc
-
-# prereq: mountfs
-# desc: choose the source of the distribution archive
-
-switch($1){
-case checkdone
-	if(! ~ $distisfrom net local){
-		configdist=ready
-		export configdist
-	}
-
-case go
-	echo 'Are you going to download the distribution'
-	echo 'from the internet or do you have it on local media?'
-	echo
-	prompt -d local 'Distribution is from' local net
-	distisfrom=$rd
-	export distisfrom
-}
-
-
--- a/sys/lib/dist/pc/inst/configether
+++ /dev/null
@@ -1,53 +1,0 @@
-#!/bin/rc
-
-# desc: configure your internet connection via an ethernet card
-
-switch($1) {
-case go
-	echo
-	echo 'Please choose a method for configuring your ethernet connection.'
-	echo
-	echo '	manual - specify IP address, network mask, gateway IP address'
-	echo '	dhcp - use DHCP to automatically configure'
-	echo
-	
-	prompt 'Configuration method' manual dhcp
-	ethermethod=$rd
-	gwaddr=xxx
-	ipaddr=xxx
-	ipmask=xxx
-	switch($ethermethod){
-	case dhcp
-		echo
-		echo 'Some ISPs, notably @HOME, require a host name passed with DHCP'
-		echo 'requests.  An example for @HOME would be "cc1018221-a".  If your'
-		echo 'ISP supplied you such a name, enter it.'
-		echo
-		prompt -d none 'host name'; dhcphost=$rd
-		switch($dhcphost){
-		case none
-			dhcphost=();
-		case *
-			dhcphost=(-h $dhcphost)
-		}
-		export dhcphost
-	case manual
-		prompt 'ip address'; ipaddr=$rd
-		prompt 'network mask'; ipmask=$rd
-		prompt 'gateway address'; gwaddr=$rd
-		export ipaddr ipmask gwaddr
-	}
-	
-	export ethermethod gwaddr ipaddr ipmask dhcphost
-	exec startether go
-
-case checkdone
-	if(! ~ $ethermethod manual dhcp) {
-		configether=notdone
-		export configether
-	}
-	if(~ $ethermethod manual && ~ 0 $#ipaddr $#ipmask $#gwaddr) {
-		configether=notdone
-		export configether
-	}
-}
--- a/sys/lib/dist/pc/inst/configfs
+++ /dev/null
@@ -1,23 +1,0 @@
-#!/bin/rc
-
-# desc: choose the type of file system to install
-
-switch($1){
-case checkdone
-	if(! ~ $fstype fossil fossil+venti){
-		configfs=ready
-		export configfs
-	}
-
-case go
-	echo 'You can install the following types of file systems:'
-	echo
-	echo '	fossil			the new Plan9 fileserver'
-	echo '	fossil+venti	fossil + a archival dump server'
-	echo
-	prompt -d fossil 'File system' fossil fossil+venti
-	fstype=$rd
-	export fstype
-}
-
-
--- a/sys/lib/dist/pc/inst/configip
+++ /dev/null
@@ -1,64 +1,0 @@
-#!/bin/rc
-
-switch($1) {
-case go
-
-	devs=''
-	if(test -d '#l/ether0' >[2]/dev/null)
-		devs=$devs^ether
-	if(test -f '#t'/eia? >[2]/dev/null)
-		devs=$devs^ppp
-	
-	switch($devs){
-	case ''
-		echo
-		echo 'Could not find ethernet card nor serial port nor modem.'
-		echo 'Please use a local copy of the distribution archive.'
-		echo
-		ifc=none
-	
-	case ppp
-		echo
-		echo 'No ethernet card was detected, but there is a serial port or modem.'
-		echo 'We will configure PPP.'
-		echo
-		ifc=ppp
-	
-	case ether
-		echo
-		echo 'No serial port or modem detected, but there is an ethernet card.'
-		echo 'We will configure the ethernet.'
-		echo
-		ifc=ether
-	
-	case etherppp
-		echo
-		echo 'You can connect to the internet via'
-		echo 'a local ethernet or a dial-up PPP connection.'
-		echo
-		prompt 'Interface to use' ether ppp
-		ifc=$rd
-	}
-	
-	ipinterface=$ifc
-	export ipinterface
-	
-	switch($ifc) {
-	case ether
-		exec configether go
-	case ppp
-		exec configppp go
-	}
-
-case checkdone
-	if(~ $#ipinterface 1)
-		switch($ipinterface) {
-		case ether
-			exec configether checkdone
-		case ppp
-			exec configppp checkdone
-		}
-	configarch=notdone
-	export configarch
-
-}
--- a/sys/lib/dist/pc/inst/confignet
+++ /dev/null
@@ -1,67 +1,0 @@
-#!/bin/rc
-
-# prereq: configdist
-# desc: configure the network to download the distribution
-
-switch($1){
-case checkready checkdone
-	if(! ~ $distisfrom net){
-		confignet=notdone
-		export confignet
-		exit
-	}
-	if(~ $distisfrom net && ~ $netisfrom ppp ether){
-		x=config$netisfrom
-		$x=done
-		config$netisfrom checkdone
-		confignet=$$x
-		export confignet
-		exit
-	}
-	confignet=ready
-	export confignet
-	exit
-
-case go
-	devs=''
-	if(test -d '#l/ether0' >[2]/dev/null)
-		devs=$devs^ether
-	if(test -f '#t'/eia? >[2]/dev/null)
-		devs=$devs^ppp
-	
-	switch($devs){
-	case ''
-		echo
-		echo 'Could not find ethernet card nor serial port nor modem.'
-		echo 'Please use a local copy of the distribution archive.'
-		echo
-		netisfrom=none
-	
-	case ppp
-		echo
-		echo 'No ethernet card was detected, but there is a serial port or modem.'
-		echo 'We will configure PPP.'
-		echo
-		netisfrom=ppp
-	
-	case ether
-		echo
-		echo 'No serial port or modem detected, but there is an ethernet card.'
-		echo 'We will configure the ethernet.'
-		echo
-		netisfrom=ether
-	
-	case etherppp
-		echo
-		echo 'You can connect to the internet via'
-		echo 'a local ethernet or a dial-up PPP connection.'
-		echo
-		prompt 'Interface to use' ether ppp
-		netisfrom=$rd
-	}
-	
-	export netisfrom
-	if(~ $netisfrom ether ppp)
-		exec config$netisfrom go
-}
-
--- a/sys/lib/dist/pc/inst/configppp
+++ /dev/null
@@ -1,63 +1,0 @@
-#!/bin/rc
-
-# desc: configure your internet connection via ppp over a modem
-
-switch($1) {
-case go
-	devs=`{ls -p '#t/'eia? >[2]/dev/null}
-	if(~ $#devs 0) {
-		echo 'No serial port found; this can''t happen.'	# because configip checks
-		exit
-	}
-	
-	# not going to use the mouse for PPP
-	if(~ eia^$mouseport $devs)
-		devs=`{echo $devs | sed 's/eia'^$mouseport^'//'}
-	
-	if(~ $#devs 0) {
-		echo 'The only serial port you have is your mouse.'
-		echo 'Cannot configure PPP.'
-		exit
-	}
-	
-	echo
-	echo 'Please choose the serial port or modem to use to connect to your ISP.'
-	echo
-	for(i in $devs) {
-		n=`{echo $i | sed 's/eia//'}
-		n=`{hoc -e 1+$n}
-		echo '	'^$i^'(Windows'' COM'^$n^')'
-	}
-	echo
-	prompt 'Serial device' $devs
-	pppdev=$rd
-	
-	echo
-	echo 'Pick a baud rate for the PPP connection.'
-	echo
-	prompt -d 115200 'Baud rate'
-	pppbaud=$rd
-	
-	echo
-	echo 'You can specify your dialup phone number, username, and password,'
-	echo 'or you can log in manually by typing the modem commands yourself.'
-	echo
-	prompt 'Dialing method' auto manual
-	pppmethod=$rd
-	
-	switch($pppmethod){
-	case auto
-		prompt 'PPP phone number'; pppphone=$rd
-		prompt 'PPP phone username'; pppuser=$rd
-		prompt 'PPP phone password'; ppppasswd=$rd
-	}
-	
-	export pppdev pppmethod pppphone ppppasswd pppuser pppbaud
-	exec startppp go
-
-case checkdone
-	if(! ~ $#pppmethod 1 || ! test -f /dev/$pppdev){
-		configppp=notdone
-		export configppp
-	}
-}
--- a/sys/lib/dist/pc/inst/copydist
+++ /dev/null
@@ -1,31 +1,0 @@
-#!/bin/rc
-
-# prereq: mountdist
-# desc: copy the distribution into the file system
-
-switch($1){
-case checkready
-	if(! test -d /n/dist/dist/replica){
-		copydist=notdone
-		export copydist
-		exit
-	}
-	if(test -f /n/newfs/dist/replica/didplan9){
-		copydist=done
-		export copydist
-		exit
-	}
-case go
-	inst/watchfd applylog 0 `{ls -l /n/dist/dist/replica/plan9.log | awk '{print $6}'} 'Installing file system' &
-	replica/pull -c / /rc/bin/inst/replcfg
-	if(~ $status '' *conflicts || test -f /n/newfs/dist/replica/didplan9witherrors)
-		>/n/newfs/dist/replica/didplan9
-	if not
-		>/n/newfs/dist/replica/didplan9witherrors
-
-case checkdone
-	if(! test -f /n/newfs/dist/replica/didplan9){
-		copydist=notdone
-		export copydist
-	}
-}
--- a/sys/lib/dist/pc/inst/defs
+++ /dev/null
@@ -1,162 +1,0 @@
-nl='
-'
-tab='	'
-if(~ $#distname 0)
-	distname=plan9
-
-wctl=/dev/null
-if(test -w /dev/wctl)
-	wctl=/dev/wctl
-
-fn log {
-	echo $* >>/srv/log
-}
-
-fn logprog {
-	echo '% '^$"* >>/srv/log
-	$* >[2=1] >>/srv/log
-}
-
-fn sigint {
-	# nothing happens
-}
-
-fn prompt {
-	def=()
-	what=()
-	if(~ $1 -d && ! ~ $#* 1){
-		def=$2
-		shift
-		shift
-	}
-
-	optstr=()
-	if(~ $1 -w && ! ~ $#* 1){
-		optstr=$2
-		shift
-		shift
-	}
-
-	pr=$1
-	shift
-
-	opts=($*)
-	if(~ $#opts 0) {
-		suf=' '
-	}
-	if not if(! ~ $#optstr 0) {
-		if(~ $optstr '') 
-			suf=' '
-		if not {
-			pr=$pr^' ('^$"optstr^')'
-			suf=''
-		}
-	}
-	if not {
-		pr=$pr^' ('^$1
-		shift
-		for(i)
-			pr=$pr^', '^$i
-		pr=$pr^')'
-		suf=''
-	}
-
-	if(~ $#def 1)
-		pr=$pr^$suf^'['^$def^']'
-	if not
-		pr=$pr^$suf^'[no default]'
-
-	pr=$pr^': '
-
-
-	okay=no
-	while(~ $okay no) {
-		echo -n current >$wctl
-		echo -n top >$wctl
-		echo -n $pr >[1=2]
-		ifs='' {rd=`{read}}
-		if(~ $#rd 0)
-			exit notdone
-		if(~ $rd !*){
-			ifs='' {rd=`{echo $rd | sed 's/!//'}}
-			echo $rd
-			rc -c $rd
-			echo !$status
-		}
-		if not{
-			rd=`{echo $rd}
-			if(~ $#rd 0 || ~ $rd '')
-				rd=$def
-	
-			switch($#opts){
-			case 0
-				if(! ~ $rd '')
-					okay=yes
-			case *
-				if(~ $rd $opts)
-					okay=yes
-			}
-		}
-	}
-	echo -n $rd >/env/rd	# just in case
-}
-
-fn desc {
-	echo -n '	'^$1^'	- '
-	grep '^# desc: ' $1 | sed 's/# desc: //'
-}
-
-fn prereq {
-	grep '^# prereq:' $1 | sed 's/# prereq://'
-}
-
-fn mustdo {
-	echo You must `{grep '^# mustdo:' $1 | sed 's/# mustdo://'}
-}
-
-# there's no easy way to pass shell variables
-# up from children to parents; the parents have
-# to be coerced into noticing that the environment
-# changed, even when in the same environment group.
-#
-# instead, we explicitly export the variables we want
-# to percolate, and the parent calls coherence to reread
-# the variables.
-#
-# we just append to the vars file, so that later exports
-# override earlier ones; when we call coherence, 
-# the duplicates are thrown out.
-
-fn export {
-	null=()
-	nonnull=()
-	for(i in $*){
-		if(~ $#$i 0)
-			null=($null $i)
-		if not
-			nonnull=($nonnull $i)
-	}
-	if(! ~ $#nonnull 0)
-		whatis $nonnull |grep -v '^\./' >>/tmp/vars >[2]/dev/null
-	for(i in $null)
-		echo $i^'=()' >>/tmp/vars
-}
-
-fn coherence {
-	if(test -f /tmp/vars) {
-		grep '^[a-z]*=' /tmp/vars >/tmp/vars2
-		v=`{sed 's/^([a-z]*)=.*/\1/' /tmp/vars2 | sort -u}
-		. /tmp/vars2
-		rm /tmp/vars2
-		rm /tmp/vars
-		export $v
-	}
-}
-
-# ip device stats
-
-fn isipdevup {
-	grep -s $1 /net/ipifc/*/status >[2]/dev/null 
-}
-
-
--- a/sys/lib/dist/pc/inst/download
+++ /dev/null
@@ -1,56 +1,0 @@
-#!/bin/rc
-
-# prereq: mountfs
-# desc: download or continue to download the distribution archives
-
-switch($1) {
-case checkready
-	devs=(`{cat /net/ipifc/*/status >[2]/dev/null |
-		grep -v '127\.0\.0\.1' |
-		sed 's/ .*//'})
-	if(~ $#devs 0) {
-		download=notdone
-		export download
-	}
-	if(~ $mountdist done){
-		download=notdone
-		export download
-	}
-
-case go
-	if(! test -f /srv/cs) {
-		log starting cs, dns
-		logprog ndb/cs >>/srv/log >[2=1]
-		logprog ndb/dns -r >>/srv/log >[2=1]
-	}
-	if(! test -f /net/cs) {
-		logprog mount -a /srv/cs /net
-		logprog mount -a /srv/dns /net
-	}
-
-	# BUG make restartable
-	echo 'Downloading distribution package...'
-	baropt='-w 145,129,445,168'
-	if(~ $textinst 1)
-		baropt=-t
-	if(! hget -vo /n/newfs/dist/_plan9.iso.bz2 $installurl/plan9.iso.bz2 |[2] bargraph $baropt 'downloading '^plan9.iso.bz2)
-			exit
-	mv /n/newfs/dist/_plan9.iso.bz2 /n/newfs/dist/plan9.iso.bz2
-	if(~ $fstype fossil){
-		echo fsys main sync >>/srv/fscons
-	}
-
-	echo 'The distribution is downloaded.'
-
-	srvmedia=()
-	mountmedia=(mount /srv/fossil /n/distmedia)
-	distmediadir=/dist
-	export distmediadir mountmedia distmedia
-	
-case checkdone
-	if(! test -f /n/newfs/dist/plan9.iso.bz2) {
-		download=notdone
-		export download
-	}
-}
-
--- a/sys/lib/dist/pc/inst/finish
+++ /dev/null
@@ -1,19 +1,0 @@
-#!/bin/rc
-
-# desc: finish the installation and reboot
-# prereq: bootsetup
-# mustdo: 
-
-switch($1) {
-case checkdone
-	finish=ready
-	export finish
-
-case go
-	if(~ $cdboot yes){
-		echo 'Congratulations; you''ve completed the install.'
-		echo
-		halt
-	}
-	stop go finished
-}
--- a/sys/lib/dist/pc/inst/fmtfossil
+++ /dev/null
@@ -1,91 +1,0 @@
-#!/bin/rc
-
-# desc: initialize disks for a fossil server
-# prereq: configfs
-
-switch($1){
-case checkready checkdone
-	if(! ~ $fstype fossil+venti fossil){
-		fmtfossil=notdone
-		export fmtfossil
-		exit
-	}
-	ff=`{ls /dev/sd*/fossil* /dev/fs/fossil* >[2]/dev/null}
-	if(~ $#ff 0){
-		fmtfossil=notdone
-		export fmtfossil
-		exit
-	}
-	gg=()
-	for(f in $ff)
-		if(isfossil $f)
-			gg=($gg $f)
-	if(~ $#gg 0){
-		fmtfossil=ready
-		export fmtfossil
-		exit
-	}
-	fmtfossil=done
-	export fmtfossil
-	exit
-
-case go
-	ff=`{ls /dev/sd*/fossil* /dev/fs/fossil* >[2]/dev/null}
-	if(~ $#ff 0){
-		echo 'You need to create a partition or partitions to hold the Fossil write cache.'
-		echo 'The partition name must begin with "fossil".'
-		echo
-		fmtfossil=notdone
-		export fmtfossil
-		exit
-	}
-	default=()
-	if(~ $#ff 1){
-		default=(-d $ff)
-	}
-	echo You have the following fossil partitions.
-	echo
-	prompt $default 'Fossil partition to format' $ff
-	f=$rd
-
-	do=yes
-	if(isfossil $f){
-		echo $f appears to already be formatted as Fossil file system.
-		echo Do you really want to reformat it?
-		echo
-		prompt -d no 'Reformat '$f yes no
-		do=$rd
-	}
-	if(~ $do yes){
-		fossil/flfmt -y $f
-		n=`{cat /dev/swap | grep ' user' | sed 's/^[0-9]+\/([0-9]+) .*/\1/'}
-		if(test $n -gt 32768)
-			m=3000	# if have at least 128 user MB, use 24MB for fossil
-		if not if(test $n -gt 16384)
-			m=1500	# 64 user MB => 12MB for fossil
-		if not if(test $n -gt 8192)
-			m=750	# 32 user MB => 6MB for fossil
-		if not
-			m=256	# 2MB for fossil (this will be slow)
-
-		# if we're using a venti in the back, take hourly snapshots
-		# that retire after three days, in addition to the daily dumps at 5am
-		if(~ $fstype fossil+venti){
-			v=''
-			snap='fsys main snaptime -s 60 -a 0500 -t 2880'
-		}
-		# otherwise, take the daily dumps but nothing else --
-		# we can't retire snapshots unless dumps are being archived
-		if not{
-			v='-V'
-			snap=''
-		}
-		echo \
-'fsys main config '^$f^'
-fsys main open '^$v^' -c '^$m^'
-'^$snap^'
-'		| fossil/conf -w $f
-	}
-	
-	echo Done.
-}
--- a/sys/lib/dist/pc/inst/fmtventi
+++ /dev/null
@@ -1,190 +1,0 @@
-#!/bin/rc
-
-# desc: initialize disks for a venti server
-# prereq: mountdist
-
-switch($1){
-case checkready checkdone
-	if(! ~ $fstype fossil+venti){
-		fmtventi=notdone
-		export fmtventi
-		exit
-	}
-	if(! test -e /bin/venti/fmtarenas || ! test -e /bin/venti/fmtisect || ! test -e /bin/venti/fmtindex){
-		bind -a /n/dist/386/bin/venti /bin/venti
-		if(! test -e /bin/venti/fmtarenas || ! test -e /bin/venti/fmtisect || ! test -e /bin/venti/fmtindex){
-			fmtventi=notdone
-			export fmtventi
-			exit
-		}
-	}
-	ff=`{ls /dev/sd*/arenas* /dev/fs/arenas* >[2]/dev/null}
-	if(~ $#ff 0){
-		fmtventi=notdone
-		export fmtventi
-		exit
-	}
-	gg=()
-	for(f in $ff)
-		if(isventi $f)
-			gg=($gg $f)
-	if(~ $#gg 0){
-		fmtventi=ready
-		export fmtventi
-		exit
-	}
-
-	ventiarena=$gg(1)
-	export ventiarena
-
-	fmtventi=done
-	export fmtventi
-	exit
-
-case go
-	ff=`{ls /dev/sd*/arenas* /dev/fs/arenas* >[2]/dev/null}
-	if(~ $#ff 0){
-		echo 'You need to create a partition or partitions to hold the Venti arenas.'
-		echo 'The arena partition names must begin with "arenas".'
-		echo
-		fmtventi=notdone
-		export fmtventi
-		exit
-	}
-	default=(-d $"ff)
-	if(! ~ $#ventiarena 0){
-		default=(-d $"ventiarena)
-	}
-	echo You have the following Venti arena partitions.
-	ls -l $ff
-	echo
-
-	prompt $default 'Venti arena partitions to use'
-	aa=`{echo $rd}
-	bad=no
-	for(a in $aa){
-		if(! ~ $a $ff){
-			echo 'Bad venti arena partition' $a
-			fmtventi=notdone
-			export fmtventi
-			exit
-		}
-	}
-	ventiarena=$aa
-	export ventiarena
-
-	gg=`{ls /dev/sd*/isect* /dev/fs/isect* >[2]/dev/null}
-	if(~ $#gg 0){
-		echo 'You need to create a partition or partitions to hold the Venti indices.'
-		echo 'The index partition names must begin with "isect".'
-		echo
-		fmtventi=notdone
-		export fmtventi
-		exit
-	}
-	default=(-d $"gg)
-	if(! ~ $#ventiindex 0){
-		default=(-d $"ventiindex)
-	}
-
-	echo You have the following Venti index partitions.
-	ls -l $gg
-	echo
-
-	prompt $default 'Venti index partitions to use'
-	aa=`{echo $rd}
-	bad=no
-	for(a in $aa){
-		if(! ~ $a $gg){
-			echo 'Bad venti index partition' $a
-			fmtventi=notdone
-			export fmtventi
-			exit
-		}
-	}
-	ventiindex=$aa
-	export ventiindex
-
-	n=-1
-	fmta=()
-	for(a in $ventiarena){
-		do=yes
-		n=`{hoc -e 1+$n}
-		if(isventiarenas $a){
-			echo File $a is already formatted as a Venti arenas partition.
-			prompt -d no 'Reformat '$a yes no
-			do=$rd
-		}
-		if(~ $do yes)
-			fmta=($fmta arenas$n:$a)
-	}
-
-	n=-1
-	fmti=()
-	for(a in $ventiindex){
-		do=yes
-		n=`{hoc -e 1+$n}
-		if(isventiisect $a){
-			echo File $a is already formatted as a Venti index section.
-			prompt -d no 'Reformat '$a yes no
-			do=$rd
-		}
-		if(~ $do yes)
-			fmti=($fmti isect$n:$a)
-	}
-
-	echo Formatting Venti arenas and indices (this takes a while).
-	# do each disk in parallel
-	echo good >/tmp/fmt
-	dd=()
-	for(a in $fmta $fmti){
-		d=`{echo $a | sed 's!.*:(/.*/).*!\1!'}
-		if(! ~ $d $dd)
-			dd=($dd $d)
-	}
-	for(d in $dd){
-		{
-			for(a in $fmta){
-				i=`{echo $a | sed 's!(.*):(/.*/)(.*)!\1 \2 \2\3!'}
-				if(~ $i(2) $d){
-					echo $i(3) ...
-					venti/fmtarenas $i(1) $i(3) || echo bad >/tmp/fmt
-					echo done with $i(3)
-				}
-			}
-			for(a in $fmti){
-				i=`{echo $a | sed 's!(.*):(/.*/)(.*)!\1 \2 \2\3!'}
-				if(~ $i(2) $d){
-					echo $i(3) ...
-					venti/fmtisect $i(1) $i(3) || echo bad >/tmp/fmt
-					echo done with $i(3)
-				}
-			}
-		} &
-	}
-	wait
-	if(~ bad `{cat /tmp/fmt}){
-		echo There were errors formatting the indices and arenas.
-		fmtventi=ready
-		export fmtventi
-		exit errors
-	}
-
-	echo Done formatting Venti arenas and indices.
-
-	v=$ventiarena(1)
-	echo Storing Venti config on $v...
-	{
-		echo index main
-		for(i in $ventiindex)
-			echo isect $i
-		for(a in $ventiarena)
-			echo arenas $a
-	} | venti/conf -w $v
-
-	echo Initializing index...
-	venti/fmtindex $v
-
-	echo Done with Venti!
-}
-
--- a/sys/lib/dist/pc/inst/gui
+++ /dev/null
@@ -1,7 +1,0 @@
-#!/bin/rc
-
-cd /bin/inst
-echo blanktime 0 >/dev/vgactl
-. defs
-
-startwin 640 480
--- a/sys/lib/dist/pc/inst/halt
+++ /dev/null
@@ -1,18 +1,0 @@
-#!/bin/rc
-
-echo -n 'Halting file systems...'
-
-if(ps | grep -s ' venti$')
-	venti/sync -h tcp!127.0.0.1!17034
-if(ps | grep -s ' fossil$'){
-	echo fsys all halt >>/srv/fscons
-	slay fossil|rc
-}
-
-echo done
-echo
-echo Remember to take the install disk out of the drive.
-echo Feel free to turn off your computer.
-while()
-	sleep 3600
-
--- a/sys/lib/dist/pc/inst/hasmbr
+++ /dev/null
@@ -1,12 +1,0 @@
-#!/bin/rc
-
-if(! ~ $#* 1) {
-	echo 'usage: hasmbr /dev/sdC0/part' >[1=2]
-	exit usage
-}
-
-x=`{xd -b $1 | sed -n '32p;32q'}
-if(~ $x(16) 55 && ~ $x(17) aa) 
-	exit ''
-exit nope
-
--- a/sys/lib/dist/pc/inst/hdrs
+++ /dev/null
@@ -1,7 +1,0 @@
-#!/bin/rc
-
-if(! ~ $#* 1) {
-	echo 'usage: hdrs file.9gz' >[1=2]
-	exit usage
-}
-gunzip < $1 | disk/mkext -h 
--- a/sys/lib/dist/pc/inst/is9660
+++ /dev/null
@@ -1,12 +1,0 @@
-#!/bin/rc
-
-# 0000000  01  C  D  0  0  1 01 00  P  L  A  N     9
-   
-if(! ~ $#* 1) {
-	echo 'usage: is9660 /dev/sdC0/part' >[1=2]
-	exit usage
-}
-
-ifs=$nl {id=`{dd -if $1 -bs 2048 -skip 16>[2]/dev/null | xd -c | sed 1q | sed 's/.........(....................).*/\1/'}}
-~ $id '01  C  D  0  0  1 01'
-exit $status
--- a/sys/lib/dist/pc/inst/isext2
+++ /dev/null
@@ -1,11 +1,0 @@
-#!/bin/rc
-
-if(! ~ $#* 1) {
-	echo 'usage: isext2 /dev/sdC0/part' >[1=2]
-	exit usage
-}
-
-cmp -s <{dd -if $1 -bs 1 -count 2 -skip 1080 >[2]/dev/null | xd -b |sed 1q} \
-	<{echo '0000000  53 ef'}
-
-exit $status
--- a/sys/lib/dist/pc/inst/isfat
+++ /dev/null
@@ -1,22 +1,0 @@
-#!/bin/rc
-
-rfork e
-
-# 0000000  eb 3c 90  P  l  a  n  9  .  0  0 00 02 04 02 00
-# 0000010  02 00 02 02  P f8 14 00  ? 00 ff 00  ~ 04  } 00
-# 0000020  02  P 00 00 80 00  ) a8 04  } 00  C  Y  L  I  N
-# 0000030   D  R  I  C  A  L  F  A  T  1  6          fa 8c
-
-if(! ~ $#* 1) {
-	echo 'usage: isfat /dev/sdC0/part' >[1=2]
-	exit usage
-}
-
-arg=$1
-fn fat {
-	cmp -s <{dd -if $arg -bs 1 -count 3 -skip $1 >[2]/dev/null} <{echo -n FAT}
-}
-
-fat 54 || fat 82
-exit $status
-
--- a/sys/lib/dist/pc/inst/isfossil
+++ /dev/null
@@ -1,16 +1,0 @@
-#!/bin/rc
-
-if(! ~ $#* 1){
-	echo 'usage: isfossil /dev/sdC0/part' >[1=2]
-	exit usage
-}
-
-arg=$1
-if(! cmp -s <{dd -quiet 1 -if $arg -bs 1024 -iseek 127 |
-	dd -quiet 1 -bs 14 -count 1} <{echo 'fossil config'})
-	exit noconfig
-if(! cmp -s <{dd -quiet 1 -if $arg -bs 1024 -iseek 128 |
-	dd -quiet 1 -bs 4 -count 1 | xd -b | sed 1q} <{echo '0000000  37 76 ae 89'})
-	exit notwritebuffer
-exit 0
-
--- a/sys/lib/dist/pc/inst/isventi
+++ /dev/null
@@ -1,13 +1,0 @@
-#!/bin/rc
-
-if(! ~ $#* 1){
-	echo 'usage: isventi /dev/sdC0/part' >[1=2]
-	exit usage
-}
-
-arg=$1
-if(! cmp -s <{dd -quiet 1 -if $arg -bs 1024 -iseek 248 |
-	dd -quiet 1 -bs 13 -count 1} <{echo 'venti config'})
-	exit noconfig
-exit 0
-
--- a/sys/lib/dist/pc/inst/isventiarenas
+++ /dev/null
@@ -1,13 +1,0 @@
-#!/bin/rc
-
-if(! ~ $#* 1){
-	echo 'usage: isventiarenas /dev/sdC0/part' >[1=2]
-	exit usage
-}
-
-arg=$1
-if(! cmp -s <{dd -quiet 1 -if $arg -bs 1024 -iseek 256 |
-	dd -quiet 1 -bs 4 -count 1 | xd -b | sed 1q} <{echo '0000000  a9 e4 a5 e7'})
-	exit notarenas
-exit 0
-
--- a/sys/lib/dist/pc/inst/isventiisect
+++ /dev/null
@@ -1,13 +1,0 @@
-#!/bin/rc
-
-if(! ~ $#* 1){
-	echo 'usage: isventiisect /dev/sdC0/part' >[1=2]
-	exit usage
-}
-
-arg=$1
-if(! cmp -s <{dd -quiet 1 -if $arg -bs 1024 -iseek 256 |
-	dd -quiet 1 -bs 4 -count 1 | xd -b | sed 1q} <{echo '0000000  d1 5c 5e c7'})
-	exit notisect
-exit 0
-
--- a/sys/lib/dist/pc/inst/main
+++ /dev/null
@@ -1,115 +1,0 @@
-#!/bin/rc
-
-. defs
-
-while()
-{
-div=--------------------------------------
-echo
-echo $div
-echo
-echo -n 'Preparing menu...'
-
-# must be topologically sorted (by prereq)
-tasks=(\
-	configfs\
-	partdisk prepdisk\
-	fmtfossil\
-	mountfs\
-	configdist\
-	confignet\
-	mountdist\
-	fmtventi\
-	download\
-	copydist\
-	bootsetup finish stop\
-	stopether stopppp\
-)
-#	startether startppp stopether stopppp download\
-
-# these don't show up in the menu but still matter
-pseudotasks=(configip havefiles etherup etherdown pppup pppdown)
-
-for(i in $tasks $pseudotasks)
-	$i=notdone
-
-coherence
-
-for(i in $tasks $pseudotasks)
-	if(~ $#$i 0)
-		$i=notdone
-
-#
-# we believe the environment about what is done
-# only if we've confirmed it.  since the tasks list is sorted so that
-# prereqs of xxx come before xxx, it's okay to assume xxx
-# is done until proven otherwise -- either a prereq or checkdone
-# will say so.
-#
-
-done=()
-ready=()
-rm /env/done
-rm /env/ready
-for(i in $tasks) {
-	$i=done
-	for(j in `{prereq $i})
-		if(! ~ $$j done)
-			$i=notdone
-	if(~ $$i done) {
-		export $i
-		$i checkdone
-		$i=`{grep '^'$i^'=' /tmp/vars | sed -n '$p' | sed 's/.*=//'}
-	}
-
-	if(~ $$i notdone ready) {
-		okay=yes
-		for(j in `{prereq $i}) 
-			if(! ~ $$j done)
-				okay=no
-		switch($okay){
-		case yes
-			$i=ready
-			export $i
-			$i checkready
-			$i=`{grep '^'$i^'=' /tmp/vars | sed -n '$p' | sed 's/.*=//'}
-		case no
-			$i=notdone
-		}
-	}
-
-	if(~ $$i done ready)
-		$$i=($$$i $i)		# rc can be just as complicated as perl!
-}
-
-export $tasks $pseudotasks done ready
-coherence
-echo
-
-if(! ~ $#done 0) {
-	echo 'The following tasks are done: '
-	for(i in $done)
-		desc $i
-	echo
-}
-
-echo 'The following unfinished tasks are ready to be done:'
-for(i in $ready)
-	desc $i
-echo
-
-if(~ $#ready 0) {
-	echo hey you finished everything!  not supposed to happen.
-	sleep 100
-	exit
-}
-
-prompt -d $ready(1) -w '' 'Task to do' $done $ready
-
-echo
-echo $div
-
-$rd go
-$rd=done		# if it's not, the check will figure that out
-export $rd
-}
--- a/sys/lib/dist/pc/inst/mainloop
+++ /dev/null
@@ -1,23 +1,0 @@
-#!/bin/rc
-
-sleep 86400 &
-cd /bin/inst
-. defs
-fn sigint { }
-
-coherence
-
-disks=`{ls /dev/sd*/data >[2]/dev/null | sed 's!/dev/(sd..)/data!\1!'}
-for (i in /dev/sd*/data)
-	if(test -f $i)
-		disk/fdisk -p $i>`{basename -d $i}^/ctl >[2]/dev/null
-for(i in /dev/sd*/plan9*)
-	if(test -f $i)
-		disk/prep -p $i >`{basename -d $i}^/ctl >[2]/dev/null
-
-# we run this while() here so that ctl-d won''t exit from us -- it''ll only exit main!
-# main contains a while() loop too, to avoid the hit of 
-# continually reexecing from here.
-
-while()
-	main
--- a/sys/lib/dist/pc/inst/mkini.awk
+++ /dev/null
@@ -1,59 +1,0 @@
-BEGIN{
-	m = "common"
-	haveold = 0;
-	while(getline <"/n/9fat/plan9-3e.ini" > 0){
-		haveold = 1
-		if($0 ~ /\[.*\]/){
-			m = substr($0, 2, length($0)-2)
-			continue
-		}
-		if(m=="menu" && $0 ~ /^menuitem=4e,/)
-			continue
-		a[m] = a[m] $0 "\n"
-	}
-
-	a["4e"] = ""
-	while(getline <"/tmp/plan9.ini" > 0)
-		a["4e"] = a["4e"] $0 "\n"
-
-	if(a["menu"] == "" && haveold){
-		a["menu"] = "menuitem=3e, Plan 9 Third Edition\n"
-		a["3e"] = ""
-	}
-
-	if(a["common"] != ""){
-		for(i in a)
-			if(i != "4e" && i != "common" && i != "menu")
-				a[i] = a["common"] a[i]
-		delete a["common"]
-	}
-
-	bootdisk4e=ENVIRON["fs"]
-	gsub("/dev/", "boot(args|disk|file)=local!#S/", bootdisk4e)
-
-	if(!haveold)
-		print a["4e"]
-	else{
-		print "[menu]"
-		print "menuitem=4e, Plan 9 Fourth Edition"
-		print a["menu"]
-		print ""
-		delete a["menu"]
-	
-		print "[4e]"
-		print a["4e"]
-		print ""
-		delete a["4e"]
-	
-		for(i in a){
-			# BUG: if rootdir is already there we should rewrite it 
-			# sometimes into /3e/whatwasthere
-			if(a[i] ~ bootdisk4e && !(a[i] ~ /rootdir=/))
-				a[i] = "rootdir=/root/3e\n" a[i]
-			print "[" i "]"
-			gsub(/9fat!9pcdisk/, "9fat!9pc3e", a[i])
-			print a[i]
-			print ""
-		}
-	}
-}
--- a/sys/lib/dist/pc/inst/mountdist
+++ /dev/null
@@ -1,222 +1,0 @@
-#!/bin/rc
-
-# prereq: mountfs configdist
-# desc: locate and mount the distribution
-
-fn domount{
-	if(! test -e $mountmedia(2))
-		logprog $srvmedia
-	unmount /n/distmedia >[2]/dev/null
-	logprog $mountmedia
-}
-
-fn exitifdone{
-	if(test -f /n/dist/dist/replica/plan9.db)
-		exit
-}
-
-fn trycdimage{
-	if(test -f $1){
-		rm -f /srv/9660.dist
-		unmount /n/dist
-		9660srv 9660.dist >[2]/dev/null
-		logprog mount /srv/9660.dist /n/dist $1
-		exitifdone
-		mountdist=notdone
-		export mountdist
-		exit notdone
-	}
-}
-
-fn trycdimagebz2 {
-	if(test -f $1){
-		echo -n 'bunzip2 < '^$1^' >/n/newfs/dist/plan9.iso'
-		bunzip2 < $1 >/n/newfs/dist/_plan9.iso &&
-		mv /n/newfs/dist/_plan9.iso /n/newfs/dist/plan9.iso
-		echo
-		trycdimage /n/newfs/dist/plan9.iso
-		mountdist=notdone
-		export mountdist
-		exit notdone
-	}
-}
-
-fn havedist {
-	test -f $1/dist/replica/plan9.db ||
-	test -f $1/plan9.iso ||
-	test -f $1/plan9.iso.bz2
-}
-
-switch($1){
-case checkready
-	if(! ~ $distisfrom local && ! ~ $download done){
-		mountdist=notdone
-		export mountdist
-	}
-	if(! ~ $#mountmedia 0 1){
-		if(domount){
-			mountdist=done
-			export mountdist
-			if(mountdist checkdone)
-				exit
-		}
-		srvmedia=()
-		mountmedia=()
-		mountdist=ready
-		export srvmedia mountmedia mountdist
-	}
-		
-case go
-	fat=()
-	ext2=()
-	x9660=()
-	fossil=()
-
-	echo Please wait... Scanning storage devices...
-
-	parts=`{ls /dev/sd??/* >[2]/dev/null | grep -v '/(plan9.*|ctl|log|raw)$'}
-	for (i in $parts) {
-		echo -n '	'^$i
-		n=`{echo $i | sed 's;/;_;g'}
-		if(! test -f /tmp/localpart.$n)
-			dd -if $i -bs 2048 -count 32 -of /tmp/localpart.$n >[2]/dev/null
-		if(isfat /tmp/localpart.$n)
-			fat=($fat $i)
-		if(isext2 /tmp/localpart.$n)
-			ext2=($ext2 $i)
-		if(is9660 /tmp/localpart.$n)
-			x9660=($x9660 $i)
-		if(isfossil $i)
-			fossil=($fossil $i)
-		echo
-	}
-	echo
-	echo The following storage media were detected.
-	echo Choose the one containing the distribution.
-	echo
-	for(i in $parts){
-		switch($i){
-		case $fat
-			echo 	'	'^$i^' (microsoft fat)'
-		case $ext2
-			echo 	'	'^$i^' (linux ext2)'
-		case $x9660
-			echo 	'	'^$i^' (iso9660 cdrom)'
-		case $fossil
-			echo 	'	'^$i^' (plan9 fossil)'
-		}
-	}
-	echo
-
-	mountstatus=x
-	while(! ~ $mountstatus ''){
-		prompt -w '' 'Distribution disk' $fat $x9660 $fossil
-		disk=$rd
-
-		srvmedia=()
-		mountmedia=()
-		switch($disk){
-		case $fs
-			mountmedia=(bind /n/newfs /n/distmedia)
-		case $fat
-			srvmedia=(dossrv)
-			mountmedia=(mount /srv/dos /n/distmedia $disk)
-		case $ext2
-			srvmedia=(ext2srv -r)
-			mountmedia=(mount /srv/ext2 /n/distmedia $disk)
-		case $x9660
-			srvmedia=(9660srv)
-			mountmedia=(mount /srv/9660 /n/distmedia $disk)
-		case $fossil
-			echo 'srv fossil.mountdist' > /tmp/fossi.conf
-			echo 'fsys main config '^$disk >> /tmp/fossil.conf
-			echo 'fsys main open -AWVP' >> /tmp/fossil.conf
-			echo 'fsys main' >> /tmp/fossil.conf
-			srvmedia=(fossil/fossil -c '. /tmp/fossil.conf')
-			mountmedia=(mount /srv/fossil.mountdist /n/distmedia)
-		case *
-			echo Unknown disk type '(cannot happen)'
-			exit oops
-		}
-		export srvmedia mountmedia
-		domount
-		mountstatus=$status
-	}
-
-	first=yes
-	dir=/
-	while(~ $first yes || ! havedist /n/distmedia/$dir){
-		if(~ $first yes){
-			echo
-			echo Which directory contains the distribution?
-			echo 'Any of the following will suffice (in order of preference):'
-			echo '	- the root directory of the cd image'
-			echo '	- the directory containing plan9.iso'
-			echo '	- the directory containing plan9.iso.bz2'
-			echo 'Typing `browse'' will put you in a shell that you can use to'
-			echo 'look for the directory.'
-			echo
-			first=no
-		}
-
-		prompt -d browse 'Location of archives'
-		dir=$rd
-		if(~ $dir browse){
-			echo This is a simple shell.  Commands are:
-			echo '	cd directory	- change to directory'
-			echo '	lc				- list contents of current directory'
-			echo '	exit			- exit shell'
-			echo 
-			echo 'Move to the directory containing the distribution'
-			echo 'and then exit.'
-			echo
-			oifs=$ifs
-			ifs=$nl
-			dir=`{cdsh -r /n/distmedia}
-			ifs=$oifs
-		}
-		if(~ $#dir 0)
-			dir=safdsfdsfdsf
-		if(! ~ $#dir 1)
-			dir=$"dir
-		if(! havedist /n/distmedia/$dir)
-			echo 'No distribution found in '^`{cleanname /$dir}
-	}
-
-	distmediadir=$dir
-	export distmediadir
-
-case checkdone
-	if(! ~ $#distmediadir 1){
-		mountdist=notdone
-		export mountdist
-		exit notdone
-	}
-	if(! havedist /n/distmedia/$distmediadir && ! havedist /n/newfs/dist){
-		mountdist=notdone
-		export mountdist
-		exit notdone
-	}
-
-	exitifdone
-
-	if(test -f /n/distmedia/$distmediadir/dist/replica/plan9.db){
-		bind /n/distmedia/$distmediadir /n/dist
-		bind -a /n/dist/386/bin /bin
-		bind -a /n/dist/rc/bin /bin
-		exitifdone
-		mountdist=notdone
-		export mountdist
-		exit notdone
-	}
-
-	trycdimage /n/distmedia/$distmediadir/plan9.iso
-	trycdimage /n/newfs/dist/plan9.iso
-
-	trycdimagebz2 /n/distmedia/$distmediadir/plan9.iso.bz2
-	trycdimagebz2 /n/newfs/dist/plan9.iso.bz2
-
-	mountdist=notdone
-	export mountdist
-	exit notdone
-}
--- a/sys/lib/dist/pc/inst/mountfossil
+++ /dev/null
@@ -1,104 +1,0 @@
-#!/bin/rc
-
-switch($1){
-case checkready checkdone
-	if(! ~ $fmtfossil done){
-		mountfs=notdone
-		export mountfs
-		exit
-	}
-	if(! test -f /dev/sd*/fossil* && ! test -f /dev/fs/fossil*){
-		mountfs=notdone
-		export mountfs
-		exit
-	}
-	if(! ~ $#fossil 1 || ! test -f $fossil){
-		mountfs=ready
-		export mountfs
-		exit
-	}
-	if(! ps | grep -s ' fossil$'){
-		echo 'srv -p fscons' > /env/fossilconf
-		echo 'srv -AP fossil' >> /env/fossilconf
-		fossil/conf $fossil | sed 's/^fsys main open .*/& -AWVP/' |
-			sed 's/^fsys main snaptime .*//' >> /env/fossilconf
-		if(! logprog fossil/fossil -c .' /env/fossilconf'>>[2]/srv/log){
-			echo 'fossil: '^$status
-			mountfs=ready
-			export mountfs
-			exit oops
-		}
-		if(! test -f /srv/fossil){
-			echo 'fossil did not create /srv/fossil'
-			mountfs=ready
-			exit oops
-		}
-		cat /srv/fscons >>/srv/log &
-		if(! logprog mount -c /srv/fossil /n/newfs){
-			echo 'mount: '^$status
-			mountfs=ready
-			export mountfs
-			exit oops
-		}
-		fs=$fossil
-		export fs
-	}
-	if(! test -s /n/newfs/adm/users){
-		echo fsys main create /active/adm adm sys d775 >>/srv/fscons
-		echo fsys main create /active/adm/users adm sys 664 >>/srv/fscons
-		echo uname upas :upas >>/srv/fscons
-		echo users -w >>/srv/fscons
-		sleep 2
-	}
-	if(! test -s /n/newfs/adm/users){
-		echo 'could not create /adm/users'
-		mountfs=ready
-		export mountfs
-		exit oops
-	}
-	for(i in dist dist/replica dist/replica/client){
-		if(! test -d /n/newfs/$i)
-			echo fsys main create /active/$i sys sys d775 >>/srv/fscons
-		sleep 2
-	}
-	if(! test -d /n/newfs/dist/replica/client){
-		echo 'could not create /dist/replica/client'
-		mountfs=ready
-		export mountfs
-		exit oops
-	}
-	if(! test -e /n/newfs/dist/replica/client/plan9.db){
-		echo fsys main create /active/dist/replica/client/plan9.db sys sys 664 >>/srv/fscons
-		echo fsys main create /active/dist/replica/client/plan9.log sys sys a664 >>/srv/fscons
-	}
-	if(test -d /n/newfs/dist/replica/client && test -f /n/newfs/adm/users){
-		mountfs=done
-		export mountfs
-		exit
-	}
-	mountfs=ready
-	export mountfs
-	exit
-
-case go
-	echo 'The following partitions named fossil* were found.'
-	echo
-	echo 'Please choose one to use as the installation file system'
-	echo 'for your Plan 9 installation.'
-	echo
-	files=(`{ls /dev/sd*/fossil* /dev/fs/fossil* >[2]/dev/null})
-	ls -l $files
-	echo
-	if(~ $#fossil 1 && ~ $fossil $files)
-		default=(-d $fossil)
-	if not if(~ $#files 1)
-		default=(-d $files)
-	if not
-		default=()
-	prompt $default 'Fossil partition' $files
-	slay fossil|rc
-	fossil=$rd
-	export fossil
-}
-
-
--- a/sys/lib/dist/pc/inst/mountfs
+++ /dev/null
@@ -1,14 +1,0 @@
-#!/bin/rc
-
-# desc: choose and mount file system partition
-# prereq: configfs
-
-switch($fstype){
-case fossil fossil+venti
-	exec mountfossil $*
-case *
-	mountfs=notdone
-	export mountfs
-	exit
-}
-
--- a/sys/lib/dist/pc/inst/moveoldfs
+++ /dev/null
@@ -1,72 +1,0 @@
-#!/bin/rc
-
-# desc: move an old third edition plan 9 file system out of the way
-# prereq: mountfs
-
-rootfiles=(\
-	386\
-	68000\
-	68020\
-	LICENSE\
-	NOTICE\
-	acme\
-	adm\
-	alpha\
-	arm\
-	cron\
-	dist\
-	fd\
-	lib\
-	lp\
-	mail\
-	mips\
-	mnt\
-	n\
-	power\
-	rc\
-	sparc\
-	sys\
-	tmp\
-	usr/glenda\
-	wrap\
-)
-
-switch($1){
-case checkready
-	if(! test -d /n/kfs/wrap){
-		moveoldfs=done
-		export moveoldfs
-	}
-
-case go
-	if(test -d /n/kfs/wrap){
-		echo 'You have a Third Edition Plan 9 installation on '^$fs^'.'
-		echo 'We need to move the old file system out of the way (into /3e)'
-		echo 'in order to continue.'
-		echo
-		prompt 'Move old file system' y n
-		switch($rd){
-		case y
-			kname=`{kfsname $fs}
-			log Moving old Plan 9 installation into /3e on kfs
-			logprog disk/kfscmd -n$kname 'create /3e sys sys 555 d' >>[2]/srv/log
-			logprog disk/kfscmd -n$kname 'create /3e/usr sys sys 555 d' >>[2]/srv/log
-			for(i in $rootfiles)
-				if(test -e /n/kfs/$i)
-					logprog disk/kfscmd -n$kname 'rename /'^$i^' /3e/'^$i
-			# copy extant /adm/users in case there have been modifications
-			logprog disk/kfscmd -n$kname 'create /adm adm adm 555 d' >>[2]/srv/log
-			logprog cp /n/kfs/3e/adm/users /n/kfs/adm/users >>[2]/srv/log
-
-		case n
-			echo 'Okay, but we can''t continue.'
-			echo
-		}
-	}
-
-case checkdone
-	if(test -d /n/kfs/wrap){
-		moveoldfs=notdone
-		export moveoldfs
-	}
-}
--- a/sys/lib/dist/pc/inst/partdisk
+++ /dev/null
@@ -1,73 +1,0 @@
-#!/bin/rc
-
-# desc: edit partition tables (e.g., to create a plan 9 partition)
-# prereq: configfs
-
-switch($1){
-case go
-	disks=`{ls /dev/sd*/data >[2]/dev/null | sed 's!/dev/(sd..)/data!\1!'}
-	if(~ $#disks 0) {
-		echo 'No disk devices were found on your system.'
-		echo 'The installation process cannot continue.'
-		exit giveup
-	}
-	
-	echo 'The following disk devices were found.'
-	echo
-	for(i in $disks) {
-		desc=`{cat /dev/$i/ctl | sed 1q | sed 's/inquiry //'}
-		echo $i '-' $desc
-		echo e | disk/fdisk -r /dev/$i/data >[2]/dev/null | grep -v '^   mbr'
-		echo
-	}
-	
-	okay=no
-	defdisk=$disks(1)
-
-	if(~ $#disks 1)
-		default=(-d $disks)
-	if not
-		default=()
-	prompt $default 'Disk to partition' $disks
-	disk=$rd
-
-	if(! hasmbr /dev/$disk/data) {
-		echo 'The disk you selected HAS NO master boot record on its first sector.'
-		echo '(Perhaps it is a completely blank disk.)'
-		echo 'You need a master boot record to use the disk.'
-		echo 'Should we install a default master boot record?'
-		echo
-		prompt 'Install mbr' y n
-		switch($rd) {
-		case y
-			disk/mbr -m /386/mbr /dev/$disk/data
-			pickdisk=done
-		}
-	}
-	echo
-	echo 'This is disk/fdisk; use it to create a Plan 9 partition.'
-	echo 'If there is enough room, a Plan 9 partition will be'
-	echo 'suggested; you can probably just type ''w'' and then ''q''.'
-	echo
-	disk/fdisk -a /dev/$disk/data
-	disk/fdisk -p /dev/$disk/data >/dev/$disk/ctl >[2]/dev/null
-	for(i in /dev/sd*/plan9*){
-		if(test -f $i){
-			d=`{basename -d $i}
-			disk/prep -p $i >$d/ctl >[2]/dev/null
-		}
-	}
-
-case checkdone
-	# we want at least one disk with both an mbr and a plan9 partition
-	mbrandplan9=0
-	disks=`{ls /dev/sd*/plan9 >[2]/dev/null | sed 's!/dev/(sd..)/plan9!\1!'}
-	for(disk in $disks) {
-		if(hasmbr /dev/$disk/data)
-			mbrandplan9=1
-	}
-	if(~ $mbrandplan9 0){
-		partdisk=notdone
-		export partdisk
-	}
-}
--- a/sys/lib/dist/pc/inst/prepdisk
+++ /dev/null
@@ -1,63 +1,0 @@
-#!/bin/rc
-
-# desc: subdivide plan 9 disk partition
-# prereq: partdisk
-
-fn autotype {
-	if(~ $fstype fossil)
-		echo -a 9fat -a nvram -a fossil -a swap
-	if(~ $fstype fossil+venti)
-		echo -a 9fat -a nvram -a arenas -a isect -a fossil -a swap # -a other
-}
-
-switch($1) {
-case checkready
-	if(! test -f /dev/sd*/plan9*){
-		prepdisk=notdone
-		export prepdisk
-	}
-
-case go
-	echo 'The following Plan 9 disk partitions were found.'
-	echo
-	disks=(/dev/sd*/plan9*)
-	for (i in $disks){
-		echo $i
-		echo q | disk/prep -r $i >[2]/dev/null
-		echo
-	}
-	if(~ $#disks 1)
-		default=(-d $disks)
-	if not
-		default=()
-	prompt $default 'Plan 9 partition to subdivide' $disks
-	disk=$rd
-
-	echo 'This is disk/prep; use it to subdivide the Plan 9 partition.'
-	echo 'If it is not yet subdivided, a sensible layout will be suggested;'
-	echo 'you can probably just type ''w'' and then ''q''.'
-	echo
-	disk/prep `{autotype} $disk
-	disk/prep -p $disk >`{basename -d $disk}^/ctl >[2]/dev/null
-
-case checkdone
-	if(! test -f /dev/sd*/9fat)
-		prepdisk=ready
-
-	if(! ~ $prepdisk ready){
-		prepdisk=done
-		switch($fstype){
-		case fossil
-			if(! test -f /dev/sd*/fossil* && ! test -f /dev/fs/fossil*)
-				prepdisk=ready
-		case fossil+venti
-			if(! test -f /dev/sd*/fossil* && ! test -f /dev/fs/fossil*)
-				prepdisk=ready
-			if(! test -f /dev/sd*/arenas && ! test -f /dev/fs/arenas*)
-				prepdisk=ready
-			if(! test -f /dev/sd*/isect && ! test -f /dev/fs/isect*)
-				prepdisk=ready
-		}
-	}
-	export prepdisk
-}
--- a/sys/lib/dist/pc/inst/replcfg
+++ /dev/null
@@ -1,18 +1,0 @@
-#!/bin/rc
-
-s=/n/dist/dist/replica
-serverroot=/n/dist
-serverlog=$s/plan9.log
-serverproto=$s/plan9.proto
-fn servermount { status='' } 
-fn serverupdate { status='' }
-
-fn clientmount { status='' }
-c=/n/newfs/dist/replica
-clientroot=/n/newfs
-clientproto=$c/plan9.proto
-clientdb=$c/client/plan9.db
-clientexclude=(dist/replica/client)
-clientlog=$c/client/plan9.log
-
-applyopt=(-t -u -T$c/client/plan9.time)
--- a/sys/lib/dist/pc/inst/startether
+++ /dev/null
@@ -1,30 +1,0 @@
-#!/bin/rc
-
-# desc: activate ethernet card
-# prereq: configether
-
-switch($1) {
-case checkready
-	if(isipdevup /net/ether0) {
-		startether=done
-		export startether
-	}
-
-case go
-	if(isipdevup /net/ether0)
-		exit
-
-	log starting ethernet $ethermethod config
-	switch($ethermethod) {
-	case manual
-		ip/ipconfig -g $gwaddr ether /net/ether0 $ipaddr $ipmask >>[2]/srv/log
-	case dhcp
-		ip/ipconfig $dhcphost -D >>/srv/log >[2=1]
-	}
-
-case checkdone
-	if(! isipdevup /net/ether0) {
-		startether=notdone
-		export startether
-	}
-}
--- a/sys/lib/dist/pc/inst/startppp
+++ /dev/null
@@ -1,30 +1,0 @@
-#!/bin/rc
-
-# desc: activate ppp connection
-# prereq: configppp
-
-switch($1) {
-case checkready checkdone
-	if (isipdevup '^pkt[0-9]')
-		startppp=done
-	export startppp
-
-case go
-	if(isipdevup '^pkt[0-9]')
-		exit
-
-	ctl=$pppdev^ctl
-	echo b115200 >$ctl
-
-	switch($pppmethod) {
-	case manual
-		echo 
-		echo 'Please dial the modem, and type ctl-d when PPP has started.'
-		echo 'You may need to type ctl-m to send modem commands.'
-		echo
-		ip/ppp -f -u -b b^$pppbaud -p /dev/^$pppdev
-
-	case auto
-		ip/ppp -f -b b^$pppbaud -p /dev/^$pppdev -s $"pppuser:$"ppppasswd -t 'atdt'^$"pppphone
-	}
-}
--- a/sys/lib/dist/pc/inst/startwin
+++ /dev/null
@@ -1,46 +1,0 @@
-#!/bin/rc
-
-fn time { date | sed 's/.........$//'}
-
-rm -f /srv/log
-
-if(~ $#* 2) {
-	wid=$1
-	ht=$2
-} 
-if not {
-	scr=(`{cat /dev/draw/new >[2]/dev/null || status=''})
-	wid=$scr(7)
-	ht=$scr(8)
-}
-
-if(test $ht -gt 800)
-	ht=800
-
-if(test $wid -gt 800)
-	wid=800
-
-statwid=`{hoc -e $wid^'*.2'}
-if(test $statwid -lt 180)
-	statwid=180
-if(test $statwid -gt 300)
-	statwid=300
-
-logwid=`{hoc -e $wid^-$statwid}
-if(test $logwid -gt 1000)
-	logwid=1000
-
-loght=`{hoc -e $ht^'*.25'}
-if(test $loght -lt 130)
-	loght=130
-
-textht=`{hoc -e $ht^-$loght}
-
-window 0,$textht,$statwid,$ht stats -lmisce
-window $statwid,$textht,^`{hoc -e $logwid+$statwid}^,$ht tailfsrv
-window 0,0,^`{hoc -e $logwid+$statwid}^,$textht inst/mainloop
-
-while(! test -f /srv/log)
-	sleep 1
-
-log `{time} Installation process started
--- a/sys/lib/dist/pc/inst/stop
+++ /dev/null
@@ -1,50 +1,0 @@
-#!/bin/rc
-
-# desc: save the current installation state, to be resumed later
-# prereq: 
-# mustdo: 
-
-switch($1) {
-case checkdone
-	stop=notdone
-	export stop
-
-case checkready
-	if(~ $cdboot yes){
-		stop=notdone
-		export stop
-	}
-
-case go
-	coherence
-	switch($2){
-	case finished
-		echo 'We need to write the state of the current installation to the install floppy,'
-		echo 'so that you can pick up from here if, for example, you want to set up'
-		echo 'more boot methods.'
-		echo
-	case *
-		echo 'We need to write the state of the current installation to the install floppy.'
-		echo 'so that you can pick up from here when you wish to continue.'
-		echo
-	}
-	echo -n 'Please make sure the install floppy is in the floppy drive and press enter.'
-	read >/dev/null >[2]/dev/null
-
-	if(! a:) {
-		echo 'Couldn''t mount the floppy disk; sorry.'
-		exit
-	}
-
-	if(cp /tmp/vars /n/a:/9inst.cnf || cp /tmp/vars /n/a:/9inst.cnf) {
-		echo 'Your install state has been saved to the install floppy.'
-		if(~ $2 finished){
-			echo
-			echo 'Congratulations; you''ve completed the install.'
-		}
-		echo
-		halt
-	}
-
-	echo 'Couldn''t save the state to your install floppy.  Sorry.'
-}
--- a/sys/lib/dist/pc/inst/stopether
+++ /dev/null
@@ -1,20 +1,0 @@
-#!/bin/rc
-
-# desc: shut down the ethernet connection
-# prereq:
-
-
-switch($1) {
-case checkready
-	if(! isipdevup /net/ether0) {
-		stopether=notdone
-		export stopether
-	}
-
-case go
-	ip/ipconfig ether /net/ether0 unbind
-
-case checkdone
-	stopether=notdone
-	export stopether
-}
--- a/sys/lib/dist/pc/inst/stopppp
+++ /dev/null
@@ -1,19 +1,0 @@
-#!/bin/rc
-
-# desc: shut down the ppp connection
-# prereq:
-
-switch($1) {
-case checkready
-	if(! ~ $#pppdev 1 || ! isipdevup '^pkt[0-9]') {
-		stopppp=notdone
-		export stopppp
-	}
-
-case go
-	kill ppp | rc
-
-case checkdone
-	stopppp=notdone
-	export stopppp
-}
--- a/sys/lib/dist/pc/inst/textonly
+++ /dev/null
@@ -1,15 +1,0 @@
-#!/bin/rc
-
-# text-only install
-cd /bin/inst
-. defs
-
-textinst=1
-export textinst
-
-tailfsrv &
-while(! test -f /srv/log)
-	sleep 1
-log `{date} Installation process started
-inst/mainloop
-
--- a/sys/lib/dist/pc/inst/watchfd
+++ /dev/null
@@ -1,17 +1,0 @@
-#!/bin/rc
-
-p=`{ps | grep $1 | sed 's/[^ ]* +([^ ]+) .*/\1/' }
-while(! ~ $#p 1) {
-	sleep 1
-	p=`{ps | grep $1 | sed 's/[^ ]* +([^ ]+) .*/\1/'}
-}
-p=$p(1)
-
-baropt='-w 145,129,445,168'
-if(~ $textinst 1)
-	baropt=-t
-
-{
-	while(test -f /proc/$p/fd)
-		grep '^ *'^$2^' ' /proc/$p/fd >[2]/dev/null
-} | awk '{print $9 " '^$3^'"; fflush("/dev/stdout")}' | bargraph $baropt $4
--- a/sys/lib/dist/pc/inst/xxx
+++ /dev/null
@@ -1,9 +1,0 @@
-#!/bin/rc
-
-ip/ipconfig
-echo '	auth=204.178.31.3
-	authdom=cs.bell-labs.com' >>/net/ndb
-ndb/cs
-auth/factotum
-bind -a /bin/auth /
-cpu -e clear -h tcp!204.178.31.2
--- a/sys/lib/dist/pc/mkfile
+++ /dev/null
@@ -1,100 +1,0 @@
-out=outside			# outside web server
-s=/sys/lib/dist/pc
-x=`{bind -b /sys/lib/dist/bin/$cputype /bin}
-default:V: ndisk
-	ls -l ndisk
-
-SUB=`{ls sub inst}
-boot.raw:Q: proto $SUB
-	rm -rf boot
-	mkdir boot
-	bind /dev/null /sys/log/timesync
-	# make files writable for now.
-	cat proto | sed 's!d000!d775!;s!000!664!;s!555!775!;s!444!664!' >proto.cp
-	disk/mkfs -a proto.cp | disk/mkext -d boot
-	@{
-		cd boot/386
-		strip init
-		cd bin
-		strip * */* >[2]/dev/null || status=''
-	}
-	cat proto | sed 's!/.*!!' >proto.cp
-	disk/mkfs -a -s boot proto.cp | tee >{wc -c >[1=2]} | 
-		touchfs 1000000000 >boot.raw
-
-boot.bz2:Q: boot.raw
-	ls -l boot.raw
-	bflz -n 32 < boot.raw >boot.bflz
-	ls -l boot.bflz
-	bzip2 -9 < boot.bflz >$target
-	ls -l $target
-
-root.bz2:Q: boot.bz2
-	{
-		echo bzfilesystem
-		cat boot.bz2
-		dd -if /dev/zero -bs 1024 -count 1 >[2]/dev/null
-	} >$target
-	ls -l $target
-
-/sys/src/9/pc/9pcflop.gz: root.bz2
-	@{
-		rfork n
-		cd /sys/src/9/pc
-		mk 'CONF=pcflop' 9pcflop.gz
-	}
-
-/sys/src/9/pc/9pccd.gz:
-	@{
-		cd /sys/src/9/pc
-		mk 'CONF=pccd' 9pccd.gz
-	}
-
-# disk/format apparently uses stat to obtain a file's real name, so
-# binding 9loadusb onto 9load will store the name 9loadusb in the
-# generated fat filesystem.  the same is true for plan9.ini.cd and plan9.ini.
-
-9load: /386/9loadlite
-#	cp $prereq $target
-	if (test -e /386/9loadnousb)
-		cp  /386/9loadnousb $target	# cater to old bioses
-	cp /386/9loadlitedebug 9loaddebug
-
-ndisk: 9load /sys/src/9/pc/9pcflop.gz plan9.ini /lib/vgadb
-	dd -if /dev/zero -of ndisk -bs 1024 -count 1440 >[2]/dev/null
-	disk/format -f -b /386/pbs -d ndisk \
-		9load /sys/src/9/pc/9pcflop.gz plan9.ini /lib/vgadb
-	ls -l ndisk
-
-# cannot list both 9pcflop.gz and 9pccd.gz because they cannot be built 
-# in parallel.  stupid mk
-cddisk:DV: 9load /sys/src/9/pc/9pcflop.gz plan9.ini.cd /lib/vgadb
-	mk -a /sys/src/9/pc/9pccd.gz
-	mk -a /sys/src/9/pc/9pcflop.gz
-	rfork n
-	cp -x plan9.ini.cd subst/plan9.ini
-	dd -if /dev/zero -of cddisk -bs 1024 -count 2880 >[2]/dev/null
-	disk/format -t 3½QD -f -b /386/pbs -d cddisk \
-		9load /sys/src/9/pc/^(9pcflop.gz 9pccd.gz) \
-		subst/plan9.ini /lib/vgadb
-	ls -l cddisk
-
-clean:V:
-	if (! unmount 9load >[2]/dev/null)
-		;
-	rm -rf boot boot.bz2 boot.bflz boot.raw root.bz2 9pcflop ndisk 9load cddisk proto.cp 9loaddebug
-
-install:V: ndisk 9loaddebug
-	9fs $out
-	dst=/n/$out/sys/lib/dist/web.protect
-	cp 9loaddebug $dst
-	gzip -9 < ndisk > $dst/plan9.flp.gz
-	# mk clean
-
-test:V: ndisk 9loaddebug
-	cp 9loaddebug ../web.protect2/n9loaddebug
-	cp ndisk ../web.protect2/ndisk
-
-cd0:D:	cddisk
-	rm -f cd0
-	disk/mk9660 -9cj -v 'Plan 9 4th Edition' -s . -p cd0.proto -b cddisk cd0
--- a/sys/lib/dist/pc/plan9.ini
+++ /dev/null
@@ -1,19 +1,0 @@
-# very cautious settings to get started.
-# will defeat booting from usb devices.
-*nomp=1
-# *noahciload=1
-# *debugload=1
-*nodumpstack=1
-# this would disable ether and usb probing.
-# *nousbprobe=1
-# *noetherprobe=1
-distname=plan9
-partition=new
-mouseport=ask
-monitor=ask
-vgasize=ask
-dmamode=ask
-# serial console on COM1
-#console=0
-bootargs=local!#S/sdD0/data
-bootfile=/386/9pccd
--- a/sys/lib/dist/pc/plan9.ini.blank
+++ /dev/null
@@ -1,10 +1,0 @@
-THIS IS A 512 byte BLANK PLAN9.INI
-                                                       
-                                                       
-                                                       
-                                                       
-                                                       
-                                                       
-                                                       
-                                                       
-                            
--- a/sys/lib/dist/pc/plan9.ini.vmware
+++ /dev/null
@@ -1,20 +1,0 @@
-# config for initial vmware booting
-
-# very cautious settings to get started.
-# will defeat booting from usb devices.
-*nomp=1
-*nobiosload=1
-# *noahciload=1
-# *debugload=1
-# *nodumpstack=1
-
-partition=new
-nobootprompt=local!/boot/bzroot
-bootfile=fd0!9pcflop.gz
-
-mouseport=ps2
-monitor=xga
-vgasize=1024x768x16
-#adisk=/dev/sdD0/cdboot
-console=0
-baud=9600
--- a/sys/lib/dist/pc/proto
+++ /dev/null
@@ -1,175 +1,0 @@
-386	d775 sys sys
-#	9load	555 sys sys
-	init	555 sys sys
-#	ld.com	555 sys sys
-	mbr	555 sys sys
-	pbs	555 sys sys
-	pbslba	555 sys sys
-	bin	d775 sys sys
-		auth d555 sys sys
-# i think factotum is only needed if we include cpu
-#			factotum	555 sys sys
-		aux	d555 sys sys
-			isvmware	555 sys sys
-			mouse	555 sys sys /sys/lib/dist/pc/multi/mouse
-			pcmcia	555 sys sys /sys/lib/dist/pc/multi/pcmcia
-		#	stub	555 sys sys
-			vga	555 sys sys /sys/lib/dist/pc/multi/vga
-			vmware	555 sys sys /sys/lib/dist/pc/sub/vmware
-		#	vmware	555 sys sys
-		#	vmwarefs	555 sys sys
-		#	vmmousepoll	555 sys sys
-			zerotrunc	555 sys sys /sys/lib/dist/pc/multi/zerotrunc
-		disk	d555 sys sys
-			fdisk	555 sys sys /sys/lib/dist/pc/multi/fdisk
-			format	555 sys sys /sys/lib/dist/pc/multi/format
-#			kfs	555 sys sys
-#			kfscmd	555 sys sys
-			mbr	555 sys sys /sys/lib/dist/pc/multi/mbr
-			prep	555 sys sys /sys/lib/dist/pc/multi/prep
-		fossil	d555 sys sys
-			fossil	555 sys sys
-			flfmt	555 sys sys
-			conf		555 sys sys
-		ip	d555 sys sys
-			ipconfig	555 sys sys /sys/lib/dist/pc/multi/ipconfig
-			ppp	555 sys sys /sys/lib/dist/pc/multi/ppp
-		ndb	d555 sys sys
-# csquery and dnsquery could go
-			cs	555 sys sys /sys/lib/dist/pc/multi/cs
-# 			csquery	555 sys sys
-			dns	555 sys sys /sys/lib/dist/pc/multi/dns
-# 			dnsquery	555 sys sys
-		replica	d555 sys sys
-			applylog	555 sys sys
-			changes	555 sys sys
-			compactdb	555 sys sys /sys/lib/dist/pc/sub/compactdb
-			pull		555 sys sys
-		venti	d555 sys sys
-#			venti	555 sys sys
-#			conf		555 sys sys
-#			fmtarenas	555 sys sys
-#			fmtindex	555 sys sys
-#			fmtisect	555 sys sys
-		9660srv	555 sys sys /sys/lib/dist/pc/multi/9660srv
-# acme could go
-#		acme	555 sys sys
-		awk	555 sys sys
-		bargraph	555 sys sys /sys/lib/dist/bin/386/bargraph
-		basename	555 sys sys /sys/lib/dist/pc/multi/basename
-		cat	555 sys sys /sys/lib/dist/pc/multi/cat
-		chgrp	555 sys sys /sys/lib/dist/pc/multi/chgrp
-		chmod	555 sys sys /sys/lib/dist/pc/multi/chmod
-		cleanname	555 sys sys /sys/lib/dist/pc/multi/cleanname
-		cmp	555 sys sys /sys/lib/dist/pc/multi/cmp
-		cdsh	555 sys sys /sys/lib/dist/bin/386/cdsh
-		cp	555 sys sys /sys/lib/dist/pc/multi/cp
-# cpu could go
-#		cpu	555 sys sys
-		date	555 sys sys /sys/lib/dist/pc/multi/date
-		dd	555 sys sys /sys/lib/dist/pc/multi/dd
-		dossrv 555 sys sys /sys/lib/dist/pc/multi/dossrv
-		echo	555 sys sys /sys/lib/dist/pc/multi/echo
-		ed	555 sys sys /sys/lib/dist/pc/multi/ed
-# if cpu goes, exportfs could go
-#		exportfs	555 sys sys
-		ext2srv	555 sys sys /sys/lib/dist/pc/multi/ext2srv
-		fcp		555	sys	sys
-		grep	555 sys sys /sys/lib/dist/pc/multi/grep
-		hget	555 sys sys /sys/lib/dist/pc/multi/hget
-		hoc	555 sys sys /sys/lib/dist/pc/multi/hoc
-		ls	555 sys sys /sys/lib/dist/pc/multi/ls
-		mc	555 sys sys /sys/lib/dist/pc/multi/mc
-		mount	555 sys sys /sys/lib/dist/pc/multi/mount
-		multi	555 sys sys /sys/lib/dist/bin/386/multi
-		mv	555 sys sys /sys/lib/dist/pc/multi/mv
-#		netkey	555 sys sys
-		ps	555 sys sys /sys/lib/dist/pc/multi/ps
-		rc	555 sys sys
-		read	555 sys sys /sys/lib/dist/pc/multi/read
-		rio	555 sys sys
-		rm	555 sys sys /sys/lib/dist/pc/multi/rm
-		sed	555 sys sys /sys/lib/dist/pc/multi/sed
-# snoopy could go
-# 		snoopy	555 sys sys
-		sort	555 sys sys /sys/lib/dist/pc/multi/sort
-		srv	555 sys sys /sys/lib/dist/pc/multi/srv
-#		ssh	555 sys sys
-		stats	555 sys sys
-		syscall	555 sys sys /sys/lib/dist/pc/multi/syscall
-		tail	555 sys sys /sys/lib/dist/pc/multi/tail
-		tailfsrv	555 sys sys /sys/lib/dist/bin/386/tailfsrv
-		tee	555 sys sys /sys/lib/dist/pc/multi/tee
-#		telnet	555 sys sys
-		test	555 sys sys /sys/lib/dist/pc/multi/test
-		wc	555 sys sys /sys/lib/dist/pc/multi/wc
-		xd	555 sys sys /sys/lib/dist/pc/multi/xd
-adm	d555 adm adm
-	timezone	d555 sys sys
-		local	555 sys sys
-lib	d777 sys sys
-	font	d555 sys sys
-		bit	d555 sys sys
-			lucidasans	d555 sys sys
-				lstr.12	444 sys sys
-				typelatin1.7.font	444 sys sys
-#			lucm	d555 sys sys
-#				latin1.9	444 sys sys
-#				latin1.9.font	444 sys sys
-	namespace	444 sys sys
-	ndb	d555 sys sys
-		common	444 sys sys /sys/lib/dist/pc/sub/common
-		local	444 sys sys /sys/lib/dist/pc/sub/local
-	vgadb	666 sys sys	/dev/null
-fd	d555 sys sys
-mnt	d777 sys sys
-	arch	d000 sys sys
-	temp d000 sys sys
-	vmware	d000 sys sys
-	wsys	d000 sys sys
-n	d777 sys sys
-	a:	d000 sys sys
-	a	d000 sys sys
-	c:	d000 sys sys
-	c	d000 sys sys
-	9fat	d000 sys sys
-	kremvax	d000 sys sys	/sys/lib/dist/pc/empty
-	newfs	d000 sys sys
-	dist	d000 sys sys	/sys/lib/dist/pc/empty
-	distmedia	d000 sys sys	/sys/lib/dist/pc/empty
-rc	d555 sys sys
-	bin	d775 sys sys
-		inst	d775 sys sys /sys/lib/dist/pc/empty
-			+	- sys sys /sys/lib/dist/pc/inst
-		9fat:	555 sys sys
-		a:	555 sys sys	 /sys/lib/dist/pc/sub/a:
-		bind	555 sys sys /sys/lib/dist/pc/sub/bind
-		boota:	555 sys sys	/sys/lib/dist/pc/sub/boota:
-		bunzip2	555 sys sys /sys/lib/dist/pc/sub/bunzip2
-		c:	555 sys sys
-		dosmnt	555 sys sys
-		kill	555 sys sys
-		lc	555 sys sys
-		mkdir	555 sys sys /sys/lib/dist/pc/sub/mkdir
-		pci	555 sys sys
-		pwd	555 sys sys /sys/lib/dist/pc/sub/pwd
-		ramfs	555 sys sys /sys/lib/dist/pc/sub/ramfs
-		replica	d555 sys sys
-			changes	555 sys sys
-			defs	555 sys sys
-			pull	555 sys sys
-		slay		555 sys sys
-		sleep	555 sys sys /sys/lib/dist/pc/sub/sleep
-		termrc	555 sys sys /sys/lib/dist/pc/sub/termrc
-		unmount	555 sys sys /sys/lib/dist/pc/sub/unmount
-		window	555 sys sys
-	lib	d555 sys sys
-		rcmain	444 sys sys
-sys	d555 sys sys
-	log	d555 sys sys
-		dns	444 sys sys	/sys/lib/dist/pc/emptyfile
-		timesync	444 sys sys	/sys/lib/dist/pc/emptyfile
-tmp	d555 sys sys
-usr	d555 sys sys
-	glenda	d775 glenda glenda
-		+	- glenda glenda	/sys/lib/dist/pc/glenda
--- a/sys/lib/dist/pc/sub/D003753
+++ /dev/null
@@ -1,22 +1,0 @@
-#!/bin/rc
-if(! test -f /srv/dos)
-	dossrv >/dev/null </dev/null >[2]/dev/null
-unmount /n/a:>[2]/dev/null
-
-if(~ $#adisk 1)
-	;	# do nothing
-if not if(~ $#bootfile 0)
-	adisk=/dev/fd0disk
-if not {
-	switch($bootfile) {
-	case sd*
-		adisk=`{echo $bootfile | sed 's#(sd..).*#/dev/\1/data#'}
-	case fd*
-		adisk=`{echo $bootfile | sed 's#(fd.).*#/dev/\1disk#'}
-	case *
-		echo 'unknown bootfile '^$bootfile^'; mail 9trouble@plan9.bell-labs.com'
-		exit oops
-	}
-}
-
-mount -c /srv/dos /n/a: $adisk
--- a/sys/lib/dist/pc/sub/F004116
+++ /dev/null
@@ -1,24 +1,0 @@
-#!/bin/rc
-
-rfork e
-if(! test -f /srv/dos)
-	dossrv >/dev/null </dev/null >[2]/dev/null
-unmount /n/a:>[2]/dev/null
-
-switch($bootfile) {
-case sd*!cdboot!*
-	# just look for the right file.  bootfile isn''t trustworthy
-	adisk=/dev/sd*/cdboot
-	if(! ~ $#adisk 1)
-		adisk=$adisk(1)
-case sd*
-	adisk=`{echo $bootfile | sed 's#(sd..).*#/dev/\1/dos#'}
-case fd*
-	adisk=`{echo $bootfile | sed 's#(fd.).*#/dev/\1disk#'}
-case *
-	echo 'unknown bootfile '^$bootfile^'; mail 9trouble@plan9.bell-labs.com'
-	exit oops
-}
-
-mount -c /srv/dos /n/a: $adisk
-
--- a/sys/lib/dist/pc/sub/bind
+++ /dev/null
@@ -1,21 +1,0 @@
-#!/bin/rc
-
-rfork e
-flag=0
-while(~ $1 -*){
-	switch($1){
-	case -b
-		flag=1
-	case -a
-		flag=2
-	case -c
-		flag=4
-	case -ac -ca
-		flag=6
-	case -bc -cb
-		flag=5
-	}
-	shift
-}
-
-syscall bind $1 $2 $flag >[2]/dev/null
--- a/sys/lib/dist/pc/sub/bunzip2
+++ /dev/null
@@ -1,4 +1,0 @@
-#!/bin/rc
-
-exec /boot/kfs BUNZIP
-# kfs is bzfs
\ No newline at end of file
--- a/sys/lib/dist/pc/sub/common
+++ /dev/null
@@ -1,123 +1,0 @@
-#
-#  services
-#
-tcp=cs port=1
-tcp=echo port=7
-tcp=discard port=9
-tcp=systat port=11
-tcp=daytime port=13
-tcp=netstat port=15
-tcp=chargen port=19
-tcp=ftp-data port=20
-tcp=ftp port=21
-tcp=ssh port=22
-tcp=telnet port=23
-tcp=smtp port=25
-tcp=time port=37
-tcp=whois port=43
-tcp=domain port=53
-tcp=uucp port=64
-tcp=gopher port=70
-tcp=rje port=77
-tcp=finger port=79
-tcp=http port=80
-tcp=link port=87
-tcp=supdup port=95
-tcp=hostnames port=101
-tcp=iso-tsap port=102
-tcp=x400 port=103
-tcp=x400-snd port=104
-tcp=csnet-ns port=105
-tcp=pop-2 port=109
-tcp=pop3 port=110
-tcp=sunrpc port=111
-tcp=uucp-path port=117
-tcp=nntp port=119
-tcp=netbios port=139
-tcp=NeWS port=144
-tcp=print-srv port=170
-tcp=z39.50 port=210
-tcp=fsb port=400
-tcp=sysmon port=401
-tcp=proxy port=402
-tcp=proxyd port=404
-tcp=https port=443
-tcp=ssmtp port=465
-tcp=snntp port=563
-tcp=rexec port=512 restricted=
-tcp=login port=513 restricted=
-tcp=shell port=514 restricted=
-tcp=printer port=515
-tcp=courier port=530
-tcp=cscan port=531
-tcp=uucp port=540
-tcp=9fs port=564
-tcp=whoami port=565
-tcp=guard port=566
-tcp=ticket port=567
-tcp=fmclient port=729
-tcp=ingreslock port=1524
-tcp=webster port=2627
-tcp=weather port=3000
-tcp=Xdisplay port=6000
-tcp=styx port=6666
-tcp=mpeg port=6667
-tcp=rstyx port=6668
-tcp=infdb port=6669
-tcp=infsigner port=6671
-tcp=infcsigner port=6672
-tcp=inflogin port=6673
-tcp=bandt port=7330
-tcp=face port=32000
-tcp=ocpu port=17005
-tcp=ocpunote port=17006
-tcp=exportfs port=17007
-tcp=rexexec port=17009
-tcp=ncpu port=17010
-tcp=ncpunote port=17011
-tcp=cpu port=17013
-tcp=video port=17028
-tcp=vgen port=17029
-tcp=alefnslook port=17030
-tcp=411 port=17031
-tcp=flyboy port=17032
-
-il=echo port=7
-il=discard port=9
-il=chargen port=19
-il=whoami port=565
-il=ticket port=566
-il=challbox port=567
-il=ocpu port=17005
-il=ocpunote port=17006
-il=exportfs port=17007
-il=9fs port=17008
-il=rexexec port=17009
-il=ncpu port=17010
-il=ncpunote port=17011
-il=tcpu port=17012
-il=cpu port=17013
-il=fsauth port=17020
-il=rexauth port=17021
-il=changekey port=17022
-il=chal port=17023
-il=check port=17024
-il=juke port=17026
-il=video port=17028
-il=vgen port=17029
-il=alefnslook port=17030
-il=ramfs port=17031
-
-udp=echo port=7
-udp=tacacs port=49
-udp=tftp port=69
-udp=bootpc port=68
-udp=bootp port=67
-udp=dns port=53
-udp=ntp port=123
-udp=rip port=520
-udp=bfs port=2201
-udp=virgil port=2202
-udp=bandt2 port=7331
-
-gre=ppp port=34827
--- a/sys/lib/dist/pc/sub/compactdb
+++ /dev/null
@@ -1,4 +1,0 @@
-#!/bin/rc
-
-exec cat $*
-
--- a/sys/lib/dist/pc/sub/local
+++ /dev/null
@@ -1,8 +1,0 @@
-
-#
-#  files comprising the database, use as many as you like
-#
-database=
-	file=/lib/ndb/local
-	file=/lib/ndb/common
-
--- a/sys/lib/dist/pc/sub/mkdir
+++ /dev/null
@@ -1,3 +1,0 @@
-#!/bin/rc
-
-syscall create $1 0 020000000775 >[2]/dev/null
--- a/sys/lib/dist/pc/sub/ndist
+++ /dev/null
@@ -1,16 +1,0 @@
-#!/bin/rc
-
-s=/n/dist/dist/replica
-serverroot=/n/dist
-serverlog=$s/plan9.log
-serverproto=$s/plan9.proto
-fn servermount { status='' } 
-fn serverupdate { status='' }
-
-fn clientmount { status='' }
-c=/n/kfs/dist/replica
-clientroot=/n/kfs
-clientproto=$c/plan9.proto
-clientdb=$c/client/plan9.db
-clientexclude=(dist/replica/client)
-clientlog=$c/client/plan9.log
--- a/sys/lib/dist/pc/sub/pci
+++ /dev/null
@@ -1,5 +1,0 @@
-#!/bin/rc
-
-rfork n
-bind '#$' /mnt
-cat /mnt/pci/*ctl
--- a/sys/lib/dist/pc/sub/pwd
+++ /dev/null
@@ -1,3 +1,0 @@
-#!/bin/rc
-
-syscall -o fd2path 0 buf 1024 < . >[2]/dev/null
--- a/sys/lib/dist/pc/sub/ramfs
+++ /dev/null
@@ -1,4 +1,0 @@
-#!/bin/rc
-
-exec boot/kfs RAMFS $*
-# kfs is bzfs
--- a/sys/lib/dist/pc/sub/sleep
+++ /dev/null
@@ -1,8 +1,0 @@
-#!/bin/rc
-
-if(! ~ $#* 1) {
-	echo 'usage: sleep n' >[1=2]
-	exit usage
-}
-
-syscall sleep $1^000 >/dev/null >[2]/dev/null
--- a/sys/lib/dist/pc/sub/termrc
+++ /dev/null
@@ -1,121 +1,0 @@
-#!/bin/rc
-
-if(~ $#debug 1 && ~ $debug yes)
-	flag x +
-if not
-	debug=0
-
-if(~ $debug yes) echo env...
-sysname=gnot
-font=/lib/font/bit/lucidasans/typelatin1.7.font
-
-for (i in '#P' '#f' '#m' '#t' '#v') {
-	if(~ $debug yes) echo bind $i
-	bind -a $i /dev >/dev/null >[2=1]
-}
-if(~ $debug yes) echo binddev done
-
-for(disk in /dev/sd??) {
-	if(test -f $disk/data && test -f $disk/ctl){
-		disk/fdisk -p $disk/data >$disk/ctl >[2]/dev/null
-#		if(~ $#nosddma 0)
-#			echo dma on >$disk/ctl
-#		if(~ $#nosdrwm 0)
-#			echo rwm on >$disk/ctl
-	}
-}
-
-for (i in /sys/log/*) {
-	if(~ $debug yes) echo bind $i
-	bind /dev/null $i
-}
-
-if(~ $debug yes) echo bindlog done
-
-bind -a '#l' /net >/dev/null >[2=1]
-
-dossrv
-boota:
-boota:	# again, just in case a timeout made the earlier one fail
-cp /n/a:/plan9.ini /tmp/plan9.orig
-if(! ~ $cdboot yes){
-	pci >/n/a:/pci.txt >[2]/dev/null
-	cp /dev/kmesg /n/a:/boot.txt >[2]/dev/null
-}
-
-# restore a partial install
-if(test -f /n/a:/9inst.cnf)
-	cp /n/a:/9inst.cnf /tmp/vars
-
-# make vgadb easier to edit
-if(test -f /n/a:/vgadb)
-	cp /n/a:/vgadb /lib/vgadb
-
-aux/vmware
-
-# configure loopback device without touching /net/ndb
-{
-	echo bind loopback /dev/null
-	echo add 127.0.0.1 255.255.255.0 
-} >/net/ipifc/clone
-
-if(~ $#dmamode 0)
-	dmamode=ask
-if(~ $dmamode ask){
-	echo -n 'use DMA for ide drives[yes]: '
-	dmamode=`{read}
-	if(~ $#dmamode 0)
-		dmamode=yes
-}
-if(~ $dmamode yes)
-	for(i in /dev/sd*/ctl)
-		if(test -f $i)
-			{echo dma on; echo rwm on >[2]/dev/null} >$i
-
-if(~ $installmode ask){
-	echo -n 'install mode is (text, graphics)[graphics]: '
-	installmode=`{read}
-	if(~ $#installmode 0)
-		installmode=graphics
-}
-if(~ $installmode text){
-	mouseport=()
-	vgasize=()
-	monitor=()
-}
-if not
-	installmode=graphics
-	
-if(~ $mouseport ask){
-	echo -n 'mouseport is (ps2, ps2intellimouse, 0, 1, 2)[ps2]: '
-	mouseport=`{read}
-	if(~ $#mouseport 0)
-		mouseport=ps2
-}
-if(~ $vgasize ask){
-	echo -n 'vgasize [640x480x8]: '
-	vgasize=`{read}
-	if(~ $#vgasize 0)
-		vgasize=640x480x8
-}
-if(~ $monitor ask){
-	echo -n 'monitor is [xga]: '
-	monitor=`{read}
-	if(~ $#monitor 0)
-		monitor=xga
-}
-if(~ $#mouseport 1) {
-	aux/mouse $mouseport
-	if(~ $#vgasize 1 && ! ~ $vgasize '') {
-		vgasize=`{echo $vgasize}
-		if(! ~ $cdboot yes)
-			aux/vga -vip $vgasize >/n/a:/vgainfo.txt
-		sleep 2	# wait for floppy to finish
-		aux/vga -l $vgasize
-		if(! ~ $#novgaaccel 0)
-			echo -n 'hwaccel off' >'#v/vgactl' >[2]/dev/null
-		if(! ~ $#novgablank 0)
-			echo -n 'hwblank off' >'#v/vgactl' >[2]/dev/null
-	}
-}
-
--- a/sys/lib/dist/pc/sub/unmount
+++ /dev/null
@@ -1,3 +1,0 @@
-#!/bin/rc
-
-syscall unmount 0 $1 >[2]/dev/null
--- a/sys/lib/dist/pc/sub/users
+++ /dev/null
@@ -1,7 +1,0 @@
--1:adm:adm:
-0:none:none:
-1:tor:tor:
-2:glenda:glenda:
-10000:sys::
-10001:upas:upas:
-10002:bootes:bootes:
--- a/sys/lib/dist/pc/sub/vmware
+++ /dev/null
@@ -1,10 +1,0 @@
-#!/bin/rc
-# vmware - if we're running in a vmware virtual machine, tweak set up
-if(aux/isvmware -s){
-	echo hwaccel off >'#v/vgactl'
-	echo -n off >'#P/i8253timerset'
-	for (ctl in '#S'/sd[C-H]?/ctl)
-		if (test -e $ctl && grep -s '^config .* dma ' $ctl &&
-		    ! grep -s '^config (848A|.* dma 00000000 )' $ctl)
-			echo 'dma on' >$ctl
-}
--- a/sys/lib/dist/pc/subst/plan9.ini
+++ /dev/null
@@ -1,40 +1,0 @@
-# config for initial cd booting
-
-[menu]
-menuitem=install, Install Plan 9 from this CD
-menuitem=cdboot, Boot Plan 9 from this CD
-# menuitem=debug, Boot Plan 9 from this CD and debug 9load
-
-[common]
-# very cautious settings to get started.
-# will defeat booting from usb devices.
-*nomp=1
-*nobiosload=1
-# *noahciload=1
-# *debugload=1
-*nodumpstack=1
-# this would disable ether and usb probing.
-# *nousbprobe=1
-# *noetherprobe=1
-partition=new
-mouseport=ask
-monitor=ask
-vgasize=ask
-dmamode=ask
-adisk=/dev/sdD0/cdboot
-cdboot=yes
-# console=0
-# baud=9600
-
-[install]
-nobootprompt=local!/boot/bzroot
-bootfile=sdD0!cdboot!9pcflop.gz
-
-[cdboot]
-bootargs=local!#S/sdD0/data
-bootfile=sdD0!cdboot!9pccd.gz
-
-# [debug]
-# bootargs=local!#S/sdD0/data
-# bootfile=sdD0!cdboot!9pccd.gz
-# *debugload=1
--- /dev/null
+++ b/sys/src/cmd/cwfs/64xbit.h
@@ -1,0 +1,22 @@
+/*
+ * fundamental constants and types of the implementation
+ * changing any of these changes the layout on disk
+ */
+
+/* the glorious new, incompatible (on disk) 64-bit world */
+
+/* keeping NAMELEN ≤ 50 bytes permits 3 Dentrys per mag disk sector */
+enum {
+	NAMELEN		= 144,		/* max size of file name components */
+	NDBLOCK		= 6,		/* number of direct blocks in Dentry */
+	NIBLOCK		= 4,		/* max depth of indirect blocks */
+};
+
+/*
+ * file offsets & sizes, in bytes & blocks.  typically long or vlong.
+ * vlong is used in the code where would be needed if Off were just long.
+ */
+typedef vlong Off;
+
+#undef COMPAT32
+#define swaboff swab8
--- a/sys/src/cmd/cwfs/con.c
+++ b/sys/src/cmd/cwfs/con.c
@@ -36,13 +36,10 @@
 	char *conline;
 
 	for (;;) {
-		/* conslock(); */
 		do {
-			print("%s: ", service);
-			if ((conline = Brdline(&bin, '\n')) == nil)
-				print("\n");
-			else {
+			if ((conline = Brdline(&bin, '\n')) != nil) {
 				conline[Blinelen(&bin)-1] = '\0';
+				print("%s: %s\n", service, conline);
 				cmd_exec(conline);
 			}
 		} while (conline != nil);
--- a/sys/src/cmd/cwfs/config.c
+++ b/sys/src/cmd/cwfs/config.c
@@ -82,6 +82,11 @@
 		case Devwren:
 		case Devworm:
 		case Devlworm:
+			if(d1->wren.file || d2->wren.file){
+				if(d1->wren.file == nil || d2->wren.file == nil)
+					return 1;
+				return !!strcmp(d1->wren.file, d2->wren.file);
+			}
 			if(d1->wren.ctrl == d2->wren.ctrl)
 			if(d1->wren.targ == d2->wren.targ)
 			if(d1->wren.lun == d2->wren.lun)
@@ -222,7 +227,7 @@
 {
 	int c, m;
 	Device *d;
-	char *icp;
+	char *icp, *s, *e;
 
 	if(f.error)
 		return devnone;
@@ -248,7 +253,41 @@
 		d->type = Devnone;
 		break;
 
+	case '/':	/* /path/to/file	mapped file */
+	case '"':	/* "/path/to/file"	mapped file */
+	case '\'':	/* '/path/to/file'	mapped file */
+	Mapped:
+		d->type = Devwren;
+		if(c == '/'){
+			s = f.charp-1;
+			for(e = s+1; *e; e++)
+				if(*e == ')' || *e == ']' || *e == '}')
+					break;
+			f.charp = e;
+		} else {
+			s = f.charp;
+			if((e = strchr(s, c)) == nil){
+				cdiag("unterminated string", c);
+				return devnone;
+			}
+			f.charp = e+1;
+		}
+		d->wren.ctrl = -1;
+		d->wren.targ = -1;
+		d->wren.lun = -1;
+		d->wren.file = malloc((e - s) + 1);
+		memmove(d->wren.file, s, e - s);
+		d->wren.file[e - s] = 0;
+		break;
+
 	case 'w':	/* w[#.]#[.#] wren	[ctrl] unit [lun] */
+		switch(*f.charp){
+		case '/':
+		case '"':
+		case '\'':
+			c = *f.charp++;
+			goto Mapped;
+		}
 	case 'r':	/* r# worm side */
 	case 'l':	/* l# labelled-worm side */
 		icp = f.charp;
--- /dev/null
+++ b/sys/src/cmd/cwfs/cwfs64/conf.c
@@ -1,0 +1,31 @@
+/* generic old-cw configuration */
+
+#include "all.h"
+
+#ifndef	DATE
+#define	DATE 1170808167L
+#endif
+
+Timet	fs_mktime = DATE;			/* set by mkfile */
+
+Startsb	startsb[] = {
+	"main",		2,
+	nil,
+};
+
+void
+localconfinit(void)
+{
+	conf.nfile = 40000;
+	conf.nodump = 0;
+//	conf.nodump = 1;		/* jukebox is r/o */
+	conf.firstsb = 13219302;
+	conf.recovsb = 0;
+	conf.nlgmsg = 100;
+	conf.nsmmsg = 500;
+}
+
+int (*fsprotocol[])(Msgbuf*) = {
+	serve9p2,
+	nil,
+};
--- /dev/null
+++ b/sys/src/cmd/cwfs/cwfs64/dat.h
@@ -1,0 +1,36 @@
+/* generic old-cw configuration: 16K blocks, 32-bit sizes */
+
+/*
+ * The most fundamental constant.
+ * The code will not compile with RBUFSIZE made a variable;
+ * for one thing, RBUFSIZE determines FEPERBUF, which determines
+ * the number of elements in a free-list-block array.
+ */
+#ifndef RBUFSIZE
+#define RBUFSIZE	(16*1024)	/* raw buffer size */
+#endif
+#include "64bit.h"
+/*
+ * setting this to zero permits the use of discs of different sizes, but
+ * can make jukeinit() quite slow while the robotics work through each disc
+ * twice (once per side).
+ */
+enum { FIXEDSIZE = 1 };
+
+
+#include "portdat.h"
+
+enum { MAXBANK = 2 };
+
+typedef struct Mbank {
+	ulong	base;
+	ulong	limit;
+} Mbank;
+
+typedef struct Mconf {
+	Lock;
+	Mbank	bank[MAXBANK];
+	int	nbank;
+	ulong	memsize;
+} Mconf;
+extern Mconf mconf;
--- /dev/null
+++ b/sys/src/cmd/cwfs/cwfs64/mkfile
@@ -1,0 +1,2 @@
+FS='64'
+<../portmkfile
--- /dev/null
+++ b/sys/src/cmd/cwfs/cwfs64x/conf.c
@@ -1,0 +1,31 @@
+/* generic old-cw configuration */
+
+#include "all.h"
+
+#ifndef	DATE
+#define	DATE 1170808167L
+#endif
+
+Timet	fs_mktime = DATE;			/* set by mkfile */
+
+Startsb	startsb[] = {
+	"main",		2,
+	nil,
+};
+
+void
+localconfinit(void)
+{
+	conf.nfile = 40000;
+	conf.nodump = 0;
+//	conf.nodump = 1;		/* jukebox is r/o */
+	conf.firstsb = 13219302;
+	conf.recovsb = 0;
+	conf.nlgmsg = 100;
+	conf.nsmmsg = 500;
+}
+
+int (*fsprotocol[])(Msgbuf*) = {
+	serve9p2,
+	nil,
+};
--- /dev/null
+++ b/sys/src/cmd/cwfs/cwfs64x/dat.h
@@ -1,0 +1,36 @@
+/* generic old-cw configuration: 16K blocks, 32-bit sizes */
+
+/*
+ * The most fundamental constant.
+ * The code will not compile with RBUFSIZE made a variable;
+ * for one thing, RBUFSIZE determines FEPERBUF, which determines
+ * the number of elements in a free-list-block array.
+ */
+#ifndef RBUFSIZE
+#define RBUFSIZE	(16*1024)	/* raw buffer size */
+#endif
+#include "64xbit.h"
+/*
+ * setting this to zero permits the use of discs of different sizes, but
+ * can make jukeinit() quite slow while the robotics work through each disc
+ * twice (once per side).
+ */
+enum { FIXEDSIZE = 1 };
+
+
+#include "portdat.h"
+
+enum { MAXBANK = 2 };
+
+typedef struct Mbank {
+	ulong	base;
+	ulong	limit;
+} Mbank;
+
+typedef struct Mconf {
+	Lock;
+	Mbank	bank[MAXBANK];
+	int	nbank;
+	ulong	memsize;
+} Mconf;
+extern Mconf mconf;
--- /dev/null
+++ b/sys/src/cmd/cwfs/cwfs64x/mkfile
@@ -1,0 +1,2 @@
+FS='64x'
+<../portmkfile
--- a/sys/src/cmd/cwfs/iobuf.c
+++ b/sys/src/cmd/cwfs/iobuf.c
@@ -204,12 +204,27 @@
 checktag(Iobuf *p, int tag, Off qpath)
 {
 	Tag *t;
-	static Off lastaddr;
+	ulong pc;
 
+	qpath &= ~QPDIR;
 	t = (Tag*)(p->iobuf+BUFSIZE);
+	if((tag != t->tag) || ((qpath != QPNONE) && (qpath != t->path))){
+		pc = getcallerpc(&p);
+
+		if(qpath == QPNONE){
+			print("checktag pc=%lux %Z(%llux) tag/path=%G/%llud; expected %G\n",
+				pc, p->dev, (Wideoff)p->addr, t->tag, (Wideoff)t->path, tag);
+		} else {
+			print("checktag pc=%lux %Z(%llux) tag/path=%G/%llud; expected %G/%llud\n",
+				pc, p->dev, (Wideoff)p->addr, t->tag, (Wideoff)t->path, tag, qpath);
+		}
+		return 1;
+	}
+
+	/*
 	if(t->tag != tag) {
 		if(p->flags & Bmod) {
-			print("\ttag = %d/%llud; expected %lld/%d -- not flushed\n",
+			print("\t%llux: tag = %G/%llud; expected %G/%d -- not flushed\n",
 				t->tag, (Wideoff)t->path, (Wideoff)qpath, tag);
 			return 2;
 		}
@@ -216,9 +231,9 @@
 		if(p->dev != nil && p->dev->type == Devcw)
 			cwfree(p->dev, p->addr);
 		if(p->addr != lastaddr)
-			print("\ttag = %G/%llud; expected %G/%lld -- flushed (%lld)\n",
-				t->tag, (Wideoff)t->path, tag, (Wideoff)qpath,
-				(Wideoff)p->addr);
+			print("\t%llux: tag = %G/%llud; expected %G/%lld -- flushed\n",
+				(Wideoff)p->addr, t->tag, (Wideoff)t->path, tag, (Wideoff)qpath);
+
 		lastaddr = p->addr;
 		p->dev = devnone;
 		p->addr = -1;
@@ -226,13 +241,14 @@
 		return 2;
 	}
 	if(qpath != QPNONE) {
-		if((qpath ^ t->path) & ~QPDIR) {
-			if(1 || CHAT(0))
-				print("\ttag/path = %llud; expected %d/%llux\n",
-					(Wideoff)t->path, tag, (Wideoff)qpath);
+		if(qpath ^ t->path) {
+			print("\t%llux: tag/path = %G/%llud; expected %G/%llux\n",
+				(Wideoff)p->addr, t->tag, (Wideoff)t->path, tag, (Wideoff)qpath);
 			return 0;
 		}
 	}
+	*/
+	
 	return 0;
 }
 
--- a/sys/src/cmd/cwfs/main.c
+++ b/sys/src/cmd/cwfs/main.c
@@ -7,6 +7,7 @@
 
 Map *devmap;
 
+int sfd, rfd;
 Biobuf bin;
 
 void
@@ -148,6 +149,57 @@
 		mapinit(conf.devmap);
 }
 
+static int
+srvfd(char *s, int mode, int sfd)
+{
+	int fd;
+	char buf[32];
+
+	fd = create(s, ORCLOSE|OWRITE, mode);
+	if(fd < 0){
+		remove(s);
+		fd = create(s, ORCLOSE|OWRITE, mode);
+		if(fd < 0)
+			panic(s);
+	}
+	sprint(buf, "%d", sfd);
+	if(write(fd, buf, strlen(buf)) != strlen(buf))
+		panic("srv write");
+	return sfd;
+}
+
+static void
+postservice(void)
+{
+	char buf[3*NAMELEN];
+	int p[2];
+
+	if(sfd < 0){
+		if(pipe(p) < 0)
+			panic("can't make a pipe");
+		sfd = p[0];
+		rfd = p[1];
+	}
+
+	/* post 9p service */
+	snprint(buf, sizeof(buf), "#s/%s", service);
+	srvfd(buf, 0666, sfd);
+	close(sfd);
+	srvchan(rfd, buf);
+
+	if(pipe(p) < 0)
+		panic("can't make a pipe");
+
+	/* post cmd service */
+	snprint(buf, sizeof(buf), "#s/%s.cmd", service);
+	srvfd(buf, 0222, p[0]);
+	close(p[0]);
+
+	/* use it as stdin */
+	dup(p[1], 0);
+	close(p[1]);
+}
+
 /*
  * compute BUFSIZE*(NDBLOCK+INDPERBUF+INDPERBUF⁲+INDPERBUF⁳+INDPERBUF⁴)
  * while watching for overflow; in that case, return 0.
@@ -224,8 +276,7 @@
 void
 usage(void)
 {
-	fprint(2, "usage: %s [-cf][-a ann-str][-m dev-map] config-dev\n",
-		argv0);
+	fprint(2, "usage: %s [ -csC ] [ -a ann-str ] [ -m dev-map ] [-f config-dev ]\n", argv0);
 	exits("usage");
 }
 
@@ -234,12 +285,14 @@
 {
 	int i, nets = 0;
 	char *ann;
-
+	
 	rfork(RFNOTEG);
 	formatinit();
 	machinit();
-	conf.confdev = "n";		/* Devnone */
+	conf.confdev = "/dev/sdC0/cwfs";
 
+	rfd = sfd = -1;
+
 	ARGBEGIN{
 	case 'a':			/* announce on this net */
 		ann = EARGF(usage());
@@ -250,12 +303,25 @@
 		}
 		annstrs[nets++] = ann;
 		break;
-	case 'c':			/* use new, faster cache layout */
+	case 's':
+		sfd = dup(0, -1);
+		rfd = dup(1, -1);
+		close(0);
+		if(open("/dev/cons", OREAD) < 0)
+			open("#c/cons", OREAD);
+		close(1);
+		if(open("/dev/cons", OWRITE) < 0)
+			open("#c/cons", OWRITE);
+		break;
+	case 'C':			/* use new, faster cache layout */
 		oldcachefmt = 0;
 		break;
-	case 'f':			/* enter configuration mode first */
+	case 'c':
 		conf.configfirst++;
 		break;
+	case 'f':			/* device / partition / file  */
+		conf.confdev = EARGF(usage());
+		break;
 	case 'm':			/* name device-map file */
 		conf.devmap = EARGF(usage());
 		break;
@@ -264,9 +330,8 @@
 		break;
 	}ARGEND
 
-	if (argc != 1)
+	if(argc != 0)
 		usage();
-	conf.confdev = argv[0];	/* config string for dev holding full config */
 
 	Binit(&bin, 0, OREAD);
 	confinit();
@@ -304,7 +369,14 @@
 	print("sysinit\n");
 	sysinit();
 
+	srvinit();
+
 	/*
+	 * post filedescriptors to /srv
+	 */
+	postservice();
+
+	/*
 	 * Ethernet i/o processes
 	 */
 	netstart();
@@ -326,16 +398,14 @@
 	newproc(wormcopy, 0, "wcp");
 
 	/*
-	 * processes to read the console
+	 * "sync" copy process
 	 */
-	consserve();
+	newproc(synccopy, 0, "scp");
 
 	/*
-	 * "sync" copy process
-	 * this doesn't return.
+	 * processes to read the console
 	 */
-	procsetname("scp");
-	synccopy();
+	consserve();
 }
 
 /*
@@ -541,7 +611,7 @@
  * to get up-to-date.
  */
 void
-synccopy(void)
+synccopy(void *)
 {
 	int f;
 
@@ -584,3 +654,4 @@
 	free(data);
 	return rv;
 }
+
--- a/sys/src/cmd/cwfs/mkfile
+++ b/sys/src/cmd/cwfs/mkfile
@@ -2,9 +2,14 @@
 
 all allall first default clean nuke install installall safeinstall safeinstallall update man:V:
 	cd cwfs && mk $target
+
 emelie.%:V:
 	cd emelie && mk $stem
 fs64.%:V:
 	cd fs64 && mk $stem
+cwfs64.%:V:
+	cd cwfs64 && mk $stem
+cwfs64x.%:V:
+	cd cwfs64x && mk $stem
 
-cleanall:V: clean emelie.clean fs64.clean
+cleanall:V: clean emelie.clean fs64.clean cwfs64.clean cwfs64x.clean
--- a/sys/src/cmd/cwfs/net.c
+++ b/sys/src/cmd/cwfs/net.c
@@ -2,17 +2,7 @@
 
 #include "all.h"
 #include "io.h"
-#include <fcall.h>		/* 9p2000 */
-#include <thread.h>
 
-enum {
-	Maxfdata	= 8192,
-	Nqueue		= 200,		/* queue size (tunable) */
-
-	Netclosed	= 0,		/* Connection state */
-	Netopen,
-};
-
 /*
  * the kernel file server read packets directly from
  * its ethernet(s) and did all the protocol processing.
@@ -40,14 +30,11 @@
  */
 
 typedef struct Network Network;
-typedef struct Netconn Netconn;
-typedef struct Conn9p Conn9p;
 
 /* a network, not necessarily an ethernet */
 struct Network {
 	int	ctlrno;
-	char	iname[NAMELEN];
-	char	oname[NAMELEN];
+	char	name[NAMELEN];
 
 	char	*dialstr;
 	char	anndir[40];
@@ -55,295 +42,18 @@
 	int	annfd;			/* fd from announce */
 };
 
-/* an open tcp (or other transport) connection */
-struct Netconn {
-	Queue*	reply;		/* network output */
-	char*	raddr;		/* remote caller's addr */
-	Chan*	chan;		/* list of tcp channels */
-
-	int	alloc;		/* flag: allocated */
-
-	int	state;
-	Conn9p*	conn9p;		/* not reference-counted */
-
-	Lock;
-};
-
-/*
- * incoming 9P network connection from a given machine.
- * typically will multiplex 9P sessions for multiple users.
- */
-struct Conn9p {
-	QLock;
-	Ref;
-	int	fd;
-	char*	dir;
-	Netconn*netconn;		/* cross-connection */
-	char*	raddr;
-};
-
 static Network netif[Maxnets];
-static struct {
-	Lock;
-	Chan*	chan;
-} netchans;
-static Queue *netoq;		/* only one network output queue is needed */
 
 char *annstrs[Maxnets] = {
 	"tcp!*!9fs",
 };
 
-/* never returns nil */
-static Chan*
-getchan(Conn9p *conn9p)
-{
-	Netconn *netconn;
-	Chan *cp, *xcp;
-
-	lock(&netchans);
-
-	/* look for conn9p's Chan */
-	xcp = nil;
-	for(cp = netchans.chan; cp; cp = netconn->chan) {
-		netconn = cp->pdata;
-		if(!netconn->alloc)
-			xcp = cp;		/* remember free Chan */
-		else if(netconn->raddr != nil &&
-		    strcmp(conn9p->raddr, netconn->raddr) == 0) {
-			unlock(&netchans);
-			return cp;		/* found conn9p's Chan */
-		}
-	}
-
-	/* conn9p's Chan not found; if no free Chan, allocate & fill in one */
-	cp = xcp;
-	if(cp == nil) {
-		cp = fs_chaninit(Devnet, 1, sizeof(Netconn));
-		netconn = cp->pdata;
-		netconn->chan = netchans.chan;
-		netconn->state = Netopen;	/* a guess */
-		/* cross-connect netconn and conn9p */
-		netconn->conn9p = conn9p;	/* not reference-counted */
-		conn9p->netconn = netconn;
-		netchans.chan = cp;
-	}
-
-	/* fill in Chan's netconn */
-	netconn = cp->pdata;
-	netconn->raddr = strdup(conn9p->raddr);
-
-	/* fill in Chan */
-	cp->send = serveq;
-	if (cp->reply == nil)
-		cp->reply = netoq;
-	netconn->reply = netoq;
-	cp->protocol = nil;
-	cp->msize = 0;
-	cp->whotime = 0;
-	strncpy(cp->whochan, conn9p->raddr, sizeof cp->whochan);
-//	cp->whoprint = tcpwhoprint;
-	netconn->alloc = 1;
-
-	unlock(&netchans);
-	return cp;
-}
-
-static char *
-fd2name(int fd)
-{
-	char data[128];
-
-	if (fd2path(fd, data, sizeof data) < 0)
-		return strdup("/GOK");
-	return strdup(data);
-}
-
 static void
-hangupdfd(int dfd)
-{
-	int ctlfd;
-	char *end, *data;
-
-	data = fd2name(dfd);
-	close(dfd);
-
-	end = strstr(data, "/data");
-	if (end != nil)
-		strcpy(end, "/ctl");
-	ctlfd = open(data, OWRITE);
-	if (ctlfd >= 0) {
-		hangup(ctlfd);
-		close(ctlfd);
-	}
-	free(data);
-}
-
-void
-closechan(int n)
-{
-	Chan *cp;
-
-	for(cp = chans; cp; cp = cp->next)
-		if(cp->whotime != 0 && cp->chan == n)
-			fileinit(cp);
-}
-
-void
-nethangup(Chan *cp, char *msg, int dolock)
-{
-	Netconn *netconn;
-
-	netconn = cp->pdata;
-	netconn->state = Netclosed;
-
-	if(msg != nil)
-		print("hangup! %s %s\n", msg, netconn->raddr);
-
-	fileinit(cp);
-	cp->whotime = 0;
-	strcpy(cp->whoname, "<none>");
-
-	if(dolock)
-		lock(&netchans);
-	netconn->alloc = 0;
-	free(netconn->raddr);
-	netconn->raddr = nil;
-	if(dolock)
-		unlock(&netchans);
-}
-
-void
-chanhangup(Chan *cp, char *msg, int dolock)
-{
-	Netconn *netconn = cp->pdata;
-	Conn9p *conn9p = netconn->conn9p;
-
-	if (conn9p->fd > 0)
-		hangupdfd(conn9p->fd);	/* drop it */
-	nethangup(cp, msg, dolock);
-}
-
-/*
- * returns length of next 9p message (including the length) and
- * leaves it in the first few bytes of abuf.
- */
-static long
-size9pmsg(int fd, void *abuf, uint n)
-{
-	int m;
-	uchar *buf = abuf;
-
-	if (n < BIT32SZ)
-		return -1;	/* caller screwed up */
-
-	/* read count */
-	m = readn(fd, buf, BIT32SZ);
-	if(m != BIT32SZ){
-		if(m < 0)
-			return -1;
-		return 0;
-	}
-	return GBIT32(buf);
-}
-
-static int
-readalloc9pmsg(int fd, Msgbuf **mbp)
-{
-	int m, len;
-	uchar lenbuf[BIT32SZ];
-	Msgbuf *mb;
-
-	*mbp = nil;
-	len = size9pmsg(fd, lenbuf, BIT32SZ);
-	if (len <= 0)
-		return len;
-	if(len <= BIT32SZ || len > IOHDRSZ+Maxfdata){
-		werrstr("bad length in 9P2000 message header");
-		return -1;
-	}
-	if ((mb = mballoc(len, nil, Mbeth1)) == nil)
-		panic("readalloc9pmsg: mballoc failed");
-	*mbp = mb;
-	memmove(mb->data, lenbuf, BIT32SZ);
-	len -= BIT32SZ;
-	m = readn(fd, mb->data+BIT32SZ, len);
-	if(m < len)
-		return 0;
-	return BIT32SZ+m;
-}
-
-static void
-connection(void *v)
-{
-	int n;
-	char buf[64];
-	Chan *chan9p;
-	Conn9p *conn9p = v;
-	Msgbuf *mb;
-	NetConnInfo *nci;
-
-	incref(conn9p);			/* count connections */
-	nci = getnetconninfo(conn9p->dir, conn9p->fd);
-	if (nci == nil)
-		panic("connection: getnetconninfo(%s, %d) failed",
-			conn9p->dir, conn9p->fd);
-	conn9p->raddr = nci->raddr;
-
-	chan9p = getchan(conn9p);
-	print("new connection on %s pid %d from %s\n",
-		conn9p->dir, getpid(), conn9p->raddr);
-
-	/*
-	 * reading from a pipe or a network device
-	 * will give an error after a few eof reads.
-	 * however, we cannot tell the difference
-	 * between a zero-length read and an interrupt
-	 * on the processes writing to us,
-	 * so we wait for the error.
-	 */
-	while (conn9p->fd > 0 && (n = readalloc9pmsg(conn9p->fd, &mb)) >= 0) {
-		if(n == 0)
-			continue;
-		mb->param = (uintptr)conn9p;	/* has fd for replies */
-		mb->chan = chan9p;
-
-		assert(mb->magic == Mbmagic);
-		incref(conn9p);			/* & count packets in flight */
-		fs_send(serveq, mb);		/* to 9P server processes */
-		/* mb will be freed by receiving process */
-	}
-
-	rerrstr(buf, sizeof buf);
-
-	qlock(conn9p);
-	print("connection hung up from %s\n", conn9p->dir);
-	if (conn9p->fd > 0)		/* not poisoned yet? */
-		hangupdfd(conn9p->fd);	/* poison the fd */
-
-	nethangup(chan9p, "remote hung up", 1);
-	closechan(chan9p->chan);
-
-	conn9p->fd = -1;		/* poison conn9p */
-	if (decref(conn9p) == 0) {	/* last conn.? turn the lights off */
-		free(conn9p->dir);
-		qunlock(conn9p);
-		free(conn9p);
-	} else
-		qunlock(conn9p);
-
-	freenetconninfo(nci);
-
-	if(buf[0] == '\0' || strstr(buf, "hungup") != nil)
-		exits("");
-	sysfatal("mount read, pid %d", getpid());
-}
-
-static void
 neti(void *v)
 {
 	int lisfd, accfd;
 	Network *net;
-	Conn9p *conn9p;
+	NetConnInfo *nci;
 
 	net = v;
 	print("net%di\n", net->ctlrno);
@@ -362,77 +72,23 @@
 			continue;
 		}
 
-		/* accepted that call */
-		conn9p = malloc(sizeof *conn9p);
-		conn9p->dir = strdup(net->lisdir);
-		conn9p->fd = accfd;
-		newproc(connection, conn9p, smprint("9P read %s", conn9p->dir));
+		nci = getnetconninfo(net->lisdir, accfd);
+		srvchan(accfd, nci->raddr);
+		freenetconninfo(nci);
 		close(lisfd);
 	}
 }
 
-/* only need one of these for all network connections, thus all interfaces */
-static void
-neto(void *)
-{
-	int len, datafd;
-	Msgbuf *mb;
-	Conn9p *conn9p;
-
-	print("neto\n");
-	for(;;) {
-		/* receive 9P answer from 9P server processes */
-		while((mb = fs_recv(netoq, 0)) == nil)
-			continue;
-
-		if(mb->data == nil) {
-			print("neto: pkt nil cat=%d free=%d\n",
-				mb->category, mb->flags&FREE);
-			if(!(mb->flags & FREE))
-				mbfree(mb);
-			continue;
-		}
-
-		/* send answer back over the network connection in the reply */
-		len = mb->count;
-		conn9p = (Conn9p *)mb->param;
-		assert(conn9p);
-
-		qlock(conn9p);
-		datafd = conn9p->fd;
-		assert(len >= 0);
-		/* datafd < 0 probably indicates poisoning by the read side */
-		if (datafd < 0 || write(datafd, mb->data, len) != len) {
-			print( "network write error (%r);");
-			print(" closing connection for %s\n", conn9p->dir);
-			nethangup(getchan(conn9p), "network write error", 1);
-			if (datafd > 0)
-				hangupdfd(datafd);	/* drop it */
-			conn9p->fd = -1;		/* poison conn9p */
-		}
-		mbfree(mb);
-		if (decref(conn9p) == 0)
-			panic("neto: zero ref count");
-		qunlock(conn9p);
-	}
-}
-
 void
 netstart(void)
 {
-	int netorun = 0;
 	Network *net;
 
-	if(netoq == nil)
-		netoq = newqueue(Nqueue, "network reply");
 	for(net = &netif[0]; net < &netif[Maxnets]; net++){
 		if(net->dialstr == nil)
 			continue;
-		sprint(net->oname, "neto");
-		if (netorun++ == 0)
-			newproc(neto, nil, net->oname);
-		sprint(net->iname, "net%di", net->ctlrno);
-		newproc(neti, net, net->iname);
+		sprint(net->name, "net%di", net->ctlrno);
+		newproc(neti, net, net->name);
 	}
 }
 
--- a/sys/src/cmd/cwfs/pc.c
+++ b/sys/src/cmd/cwfs/pc.c
@@ -33,7 +33,7 @@
 		}
 		Bterm(bp);
 		if (pgsize > 0 && userpgs > 0)
-			size = (((userpgs - userused)*3LL)/4)*pgsize;
+			size = (((userpgs - userused)*1LL)/4)*pgsize;
 	}
 	mconf.memsize = size;
 	mbp = mconf.bank;
--- a/sys/src/cmd/cwfs/portdat.h
+++ b/sys/src/cmd/cwfs/portdat.h
@@ -699,6 +699,7 @@
 	Devfloppy,		/* floppy drive */
 	Devswab,		/* swab data between mem and device */
 	Devmirr,		/* mirror devices */
+	Devsrv,		/* pipes and network connections */
 	MAXDEV
 };
 
--- a/sys/src/cmd/cwfs/portfns.h
+++ b/sys/src/cmd/cwfs/portfns.h
@@ -197,6 +197,7 @@
 int	scsiio(Device*, int, uchar*, int, void*, int);
 void	scsiinit(void);
 Off	scsiread(int, void*, long);
+Devsize	scsiseek(int, Devsize);
 Off	scsiwrite(int, void*, long);
 char*	sdof(Device*);
 void	sec2rtc(Timet, Rtc *);
@@ -229,7 +230,7 @@
 void	newproc(void(*)(void *), void*, char*);
 void	wormcopy(void *);
 void	wormprobe(void);
-void	synccopy(void);
+void	synccopy(void *);
 long	wormsearch(Device*, int, long, long);
 int	wormread(Device*, Off, void*);
 Devsize	wormsize(Device*);
@@ -243,3 +244,6 @@
 void	cmd_exec(char*);
 void	cmd_install(char*, char*, void (*)(int, char*[]));
 ulong	flag_install(char*, char*);
+void	srvinit(void);
+Chan	*srvchan(int, char *);
+
--- a/sys/src/cmd/cwfs/portmkfile
+++ b/sys/src/cmd/cwfs/portmkfile
@@ -27,10 +27,12 @@
 	time.$O\
 	uidgid.$O\
 	wren.$O\
+	srv.$O\
 
 HFILES=\
 	../32bit.h\
 	../64bit.h\
+	../64xbit.h\
 	../9p1.h\
 	../all.h\
 	dat.h\
--- /dev/null
+++ b/sys/src/cmd/cwfs/srv.c
@@ -1,0 +1,209 @@
+#include "all.h"
+#include "io.h"
+#include <fcall.h>		/* 9p2000 */
+#include <thread.h>
+
+enum {
+	Maxfdata	= 8192,
+	Nqueue	= 200,		/* queue size (tunable) */
+	Nsrvo	= 8,			/* number of write workers */
+};
+
+typedef struct Srv Srv;
+struct Srv
+{
+	Ref;
+	char		*name;
+	Chan	*chan;
+	int		fd;
+	char		buf[64];
+};
+
+static struct {
+	Lock;
+	Chan *hd;
+} freechans;
+
+static Queue *srvoq;
+
+void
+chanhangup(Chan *chan, char *msg, int dolock)
+{
+	Srv *srv;
+
+	USED(dolock);
+	USED(msg);
+
+	fileinit(chan);
+	if(chan->type != Devsrv)
+		return;
+	srv = chan->pdata;
+	if(srv == nil || srv->chan != chan)
+		return;
+	close(srv->fd);
+	srv->fd = -1;
+}
+
+static void
+srvput(Srv *srv)
+{
+	Chan *chan;
+
+	if(decref(srv))
+		return;
+
+	print("%s closed\n", srv->name);
+
+	chanhangup(srv->chan, "", 0);
+	memset(srv->buf, 0, sizeof(srv->buf));
+	chan = srv->chan;
+	lock(&freechans);
+	srv->chan = freechans.hd;
+	freechans.hd = chan;
+	unlock(&freechans);
+}
+
+static void
+srvo(void *)
+{
+	Srv *srv;
+	Msgbuf *mb;
+	char buf[ERRMAX];
+
+	print("srvo\n");
+
+	for(;;){
+		mb = fs_recv(srvoq, 0);
+		if(mb == nil)
+			continue;
+		if(mb->data == nil){
+			if(!(mb->flags & FREE))
+				mbfree(mb);
+			continue;
+		}
+		srv = (Srv*)mb->param;
+		while((srv->fd >= 0) && (write(srv->fd, mb->data, mb->count) != mb->count)){
+			rerrstr(buf, sizeof(buf));
+			if(strstr(buf, "interrupt"))
+				continue;
+
+			if(buf[0])
+				print("srvo %s: %s\n", srv->name, buf);
+			chanhangup(srv->chan, buf, 0);
+			break;
+		}
+		mbfree(mb);
+		srvput(srv);
+	}
+}
+
+static void
+srvi(void *aux)
+{
+	Srv *srv = aux;
+	Msgbuf *mb, *ms;
+	uchar *b, *p, *e;
+	int n, m;
+	char buf[ERRMAX];
+
+	print("srvi %s\n", srv->name);
+
+	if((mb = mballoc(IOHDRSZ+Maxfdata, srv->chan, Mbeth1)) == nil)
+		panic("srvi %s: mballoc failed", srv->name);
+	b = mb->data;
+	p = b;
+	e = b + mb->count;
+
+Read:
+	while((srv->fd >= 0) && ((n = read(srv->fd, p, e - p)) >= 0)){
+		p += n;
+		while((p - b) >= BIT32SZ){
+			m = GBIT32(b);
+			if((m < BIT32SZ) || (m > mb->count)){
+				werrstr("bad length in 9P2000 message header");
+				goto Error;
+			}
+			if((n = (p - b) - m) < 0){
+				e = b + m;
+				goto Read;
+			}
+			if(m <= SMALLBUF){
+				if((ms = mballoc(m, srv->chan, Mbeth1)) == nil)
+					panic("srvi %s: mballoc failed", srv->name);
+				memmove(ms->data, b, m);
+			} else {
+				ms = mb;
+				if((mb = mballoc(mb->count, srv->chan, Mbeth1)) == nil)
+					panic("srvi %s: mballoc failed", srv->name);
+				ms->count = m;
+			}
+			if(n > 0)
+				memmove(mb->data, b + m, n);
+			b = mb->data;
+			p = b + n;
+
+			incref(srv);
+			ms->param = (uint)srv;
+			fs_send(serveq, ms);
+		}
+		e = b + mb->count;
+	}
+
+Error:
+	rerrstr(buf, sizeof(buf));
+	if(strstr(buf, "interrupt"))
+		goto Read;
+
+	if(buf[0])
+		print("srvi %s: %s\n", srv->name, buf);
+	chanhangup(srv->chan, buf, 0);
+	srvput(srv);
+
+	mbfree(mb);
+}
+
+Chan*
+srvchan(int fd, char *name)
+{
+	Chan *chan;
+	Srv *srv;
+
+	lock(&freechans);
+	if(chan = freechans.hd){
+		srv = chan->pdata;
+		freechans.hd = srv->chan;
+		unlock(&freechans);
+	} else {
+		unlock(&freechans);
+		chan = fs_chaninit(Devsrv, 1, sizeof(*srv));
+		srv = chan->pdata;
+	}
+	chan->reply = srvoq;
+	if(chan->send == nil)
+		chan->send = serveq;
+	chan->protocol = nil;
+	chan->msize = 0;
+	chan->whotime = 0;
+
+	incref(srv);
+	srv->chan = chan;
+	srv->fd = fd;
+	snprint(srv->buf, sizeof(srv->buf), "srvi %s", name);
+	srv->name = strchr(srv->buf, ' ')+1;
+	newproc(srvi, srv, srv->buf);
+
+	return chan;
+}
+
+void
+srvinit(void)
+{
+	int i;
+
+	if(srvoq != nil)
+		return;
+
+	srvoq = newqueue(Nqueue, "srvoq");
+	for(i=0; i<Nsrvo; i++)
+		newproc(srvo, nil, "srvo");
+}
--- a/sys/src/cmd/cwfs/sub.c
+++ b/sys/src/cmd/cwfs/sub.c
@@ -614,7 +614,9 @@
 	case Devlworm:
 		if (c == '\0')
 			c = 'l';
-		if(d->wren.ctrl == 0 && d->wren.lun == 0)
+		if(d->wren.file)
+			snprint(s, sizeof(s), "%c\"%s\"", c, d->wren.file);
+		else if(d->wren.ctrl == 0 && d->wren.lun == 0)
 			sprint(s, "%c%d", c, d->wren.targ);
 		else
 			sprint(s, "%c%d.%d.%d", c, d->wren.ctrl, d->wren.targ,
--- a/sys/src/cmd/cwfs/wren.c
+++ b/sys/src/cmd/cwfs/wren.c
@@ -116,5 +116,6 @@
 		cons.nwrenwe++;
 		r = 1;
 	}
+
 	return r;
 }
--