Browse Source

Plan 9 from Bell Labs 2010-01-16

David du Colombier 14 years ago
parent
commit
30b9a428e5
2 changed files with 288 additions and 0 deletions
  1. 189 0
      sys/src/9/pc/boot.fs
  2. 99 0
      sys/src/9/pc/pcfs

+ 189 - 0
sys/src/9/pc/boot.fs

@@ -0,0 +1,189 @@
+#!/boot/rc -m /boot/rcmain
+# boot script for file servers, including standalone ones
+path=(/boot /$cputype/bin /rc/bin .)
+fn diskparts {
+	# set up any /dev/sd partitions
+	for(disk in /dev/sd*) {
+		if(test -f $disk/data && test -f $disk/ctl)
+			fdisk -p $disk/data >$disk/ctl >[2]/dev/null
+		if(test -f $disk/plan9)
+			parts=($disk/plan9*)
+		if not
+			parts=($disk/data)
+		for(part in $parts)
+			if(test -f $part)
+				prep -p $part >$disk/ctl >[2]/dev/null
+	}
+}
+
+cd /boot
+echo -n boot...
+if (! test -e /env/vmpc)
+	vmpc=23			# % of free memory for venti
+cp '#r/rtc' '#c/time'
+bind -a '#I0' /net
+bind -a '#l0' /net
+bind -a '#¤' /dev
+bind -a '#S' /dev
+bind -a '#k' /dev
+bind -a '#æ' /dev
+bind -a '#u' /dev	>[2]/dev/null
+bind -a '#U' /dev	>[2]/dev/null	# old usb implementation
+bind '#p' /proc
+bind '#d' /fd
+bind -c '#s' /srv
+# bind -a /boot /
+
+# start usb for keyboard, disks, etc.
+if (test -e /dev/usb/ctl) {
+	echo -n usb...
+	usbd
+}
+if not if (test -e /dev/usb0) {
+	echo -n old usb...
+	usbd
+	if (test -e '#m/mouse')
+		kb -a2
+	if not
+		kb -k
+	disk -l -s usbdisk -m /mnt	# mounts on /mnt/<lun>
+}
+
+echo -n disks...
+if(! ~ $dmaon no)
+	for (ctl in /dev/sd[C-H]?/ctl)
+		if (test -e $ctl)
+			echo 'dma on' >$ctl
+
+diskparts
+
+# set up any fs(3) partitions (HACK)
+# don't match AoE disks, as those may be shared.
+if (test ! -e /env/fscfg)
+	fscfg=`{ls -d /dev/sd[~e-h]?/fscfg >[2]/dev/null | sed 1q}
+if (~ $#fscfg 1 && test -r $fscfg)
+	zerotrunc <$fscfg | read -m >/dev/fs/ctl
+
+# figure out which arenas and fossil partitions to use.
+# don't match AoE disks, as those may be shared.
+if(! test -e /env/arena0){
+	if (test -e	/dev/fs/arena0)
+		arena0=	/dev/fs/arena0
+	if not if (test -e	/dev/sd[~e-h]?/arena0)
+		arena0=		/dev/sd[~e-h]?/arena0
+	if not
+		arena0=/dev/null
+}
+if (test -e	/dev/fs/fossil)
+	fossil=	/dev/fs/fossil
+if not if (test -e	/dev/sd[~e-h]?/fossil)
+	fossil=		/dev/sd[~e-h]?/fossil
+if not
+	fossil=/dev/null
+
+#
+# the local disks are now sorted out.
+# set up the network, auth, venti and fossil.
+#
+
+echo -n ip...
+if (~ $#ip 1 && ! ~ $ip '') {
+	# need to supply ip, ipmask and ipgw in plan9.ini to use this
+	ipconfig -g $ipgw ether /net/ether0 $ip $ipmask
+	echo 'add 0 0 '^$ipgw >>/net/iproute
+}
+if not
+	ipconfig
+switch (`{sed '/\.(0|255)[	 ]/d' /net/ipselftab}) {
+case 204.178.31.*
+	echo 'add 135.104.9.0 255.255.255.0 204.178.31.10' >>/net/iproute
+}
+ipconfig loopback /dev/null 127.1
+
+# local hackery: add extra sr luns
+if (test -e /dev/aoe/1.1)
+	echo config switch on spec f type aoe//dev/aoe/1.1 >/dev/sdctl
+if (test -e /dev/aoe/1.2)
+	echo config switch on spec g type aoe//dev/aoe/1.2 >/dev/sdctl
+diskparts
+
+# so far we're using the default key from $nvram, usually
+# for insideout.plan9.bell-labs.com on outside machines,
+# and have mounted our root over the net, if running diskless.
+# factotum always mounts itself (on /mnt by default).
+
+echo -n factotum...
+if(~ $#auth 1){
+	echo start factotum on $auth
+	factotum -sfactotum -S -a $auth
+}
+if not
+	factotum -sfactotum -S
+mount -b /srv/factotum /mnt
+
+# if a keys partition exists, add its contents to factotum's
+keys=`{ls -d /dev/sd*/keys >[2]/dev/null | sed 1q}
+if (~ $#keys 1 && test -r $keys) {
+	echo -n add keys...
+	zerotrunc <$keys | aescbc -n -d | read -m >/mnt/factotum/ctl
+}
+
+# get root from network if fsaddr set in plan9.ini, and bail out here
+if (test -e /env/fs) {
+	echo -n fs root...
+	if(! srv tcp!$fs!564 boot)
+		exec ./rc -m/boot/rcmain -i
+	if(! mount -c /srv/boot /root)
+		exec ./rc -m/boot/rcmain -i
+}
+
+# start venti store
+if (! ~ $arena0 /dev/null && test -r $arena0) {
+	echo -n start venti on $arena0...
+	venti=tcp!127.0.0.1!17034
+	vcfg=`{ls -d /dev/sd*/venticfg >[2]/dev/null | sed 1q}
+	if (~ $#vcfg 1 && test -r $vcfg)
+		venti -m $vmpc -c $vcfg
+	if not
+		venti -m $vmpc -c $arena0
+	sleep 10
+}
+if not if (! test -e /env/venti)
+	venti=tcp!135.104.9.33!17034		# local default
+
+# start root fossil, may serve /srv/boot
+if (! ~ $fossil /dev/null && test -r $fossil) {
+	echo -n root fossil on $fossil...
+	fossil -m 2 -f $fossil
+	sleep 3
+}
+
+#
+# normal start up on local fossil root
+#
+
+rootdir=/root
+rootspec=main/active
+
+# factotum is now mounted in /mnt; keep it visible.
+# newns() needs it, among others.
+
+# mount new root
+echo -n mount /srv/boot /root...
+mount -cC /srv/boot /root
+bind -a /root /
+
+bind -ac /root/mnt /mnt
+mount -b /srv/factotum /mnt
+
+# standard bin
+bind /$cputype/bin /bin
+bind -a /rc/bin /bin
+
+
+# run cpurc
+echo cpurc...
+path=(/bin . /boot)
+/$cputype/init -c
+
+exec ./rc -m/boot/rcmain -i

+ 99 - 0
sys/src/9/pc/pcfs

@@ -0,0 +1,99 @@
+# pcfs - pccpuf variant with venti, fossil, boot script & more compiled in.
+#	for use on file servers, including standalone ones
+dev
+	root
+	cons
+	arch
+	pnp		pci
+	env
+	pipe
+	proc
+	mnt
+	srv
+	dup
+	rtc
+	ssl
+	tls
+	cap
+	fs
+
+	ether		netif
+	ip		arp chandial ip ipv6 ipaux iproute netlog nullmedium pktmedium ptclbsum386 inferno
+
+	sd
+	floppy		dma
+	aoe
+
+	uart
+	usb
+	kbin
+
+link
+	ether82557	pci
+	ether82563	pci
+	etherdp83820	pci
+	etherga620	pci
+	etherigbe	pci ethermii
+	ethervt6105m
+	ethersink
+	ethermedium
+	netdevmedium
+	loopbackmedium
+	usbuhci
+	usbohci
+	usbehci
+
+misc
+	realmode
+	archmp		mp apic
+	mtrr
+
+	uarti8250
+
+	sdaoe
+	sdata		pci sdscsi
+	sdiahci		pci sdscsi
+	sd53c8xx	pci sdscsi
+	sdmylex		pci sdscsi
+
+ip
+	tcp
+	udp
+	rudp
+	ipifc
+	icmp
+	icmp6
+	ipmux
+	esp
+
+port
+	int cpuserver = 1;
+
+boot boot #S/sdC0/
+	tcp
+	local
+
+bootdir
+	boot.fs boot
+	/386/bin/rc
+	/rc/lib/rcmain
+	/386/bin/ip/ipconfig
+	/386/bin/auth/factotum
+	/386/bin/venti/venti
+	/386/bin/fossil/fossil
+	/386/bin/auth/aescbc
+	/386/bin/aux/zerotrunc
+	/386/bin/bind
+	/386/bin/cat
+	/386/bin/cp
+	/386/bin/disk/fdisk
+	/386/bin/disk/prep
+	/386/bin/echo
+	/386/bin/ls
+	/386/bin/mount
+	/386/bin/read
+	/386/bin/sed
+	/386/bin/sleep
+	/386/bin/srv
+	/386/bin/test
+	/386/bin/usb/usbd