63 lines · 1.6 KB · Text
RawDownload
#!/bin/rc loader=9loadpbs=/386/pbslbambr=/386/mbr fn fail{	if(! ~ $#* 0)		echo mkfsboot: $*>[2=1]	exit fail} flagfmt='l loader,p pbs,m mbr'args='drive'if(! ifs=() eval `{aux/getflags $*} || ! ~ $#* 1){	aux/usage	exit usage}if(! test -d $1 || ! test -f $1/data){	fail disk $1 not found} if(! ~ $#flagl 0)	loader=$flaglif(! ~ $#flagp 0)	pbs=$flagpif(! ~ $#flagm 0)	mbr=$flagmif(! test -f fsconfig)	fail fsconfig missingif(! test -d 9fat || ! test -f 9fat/$loader)	fail invalid 9fat directoryd=$1 # format properly without passworddisk/mknvrsafe -c `{sed -n 's:^config (.*):\1:p' < fsconfig} | dd -quiet 1 -conv sync -of 9fat/fs.nvrif(! ~ $status '|')	exit mknvrsafe dd -if /dev/zero -of $d/data -count 1024 -bs 8192 -quiet 1 || faildisk/mbr -m $mbr $d/data || faildisk/fdisk -abw $d/data || fail{	echo a 9fat 0 0x5000	echo a nvram 0x5000 0x5001	echo a fsconfig 0x5040 0x5060	test -x extraparts && extraparts	echo w	echo q} | disk/prep $d/plan9 || failextra=`{ls -p 9fat/* | grep -v '^(' ^ $loader ^ '|plan9.ini|fs.nvr)$'}if(! test -f 9fat/$loader)	cp /386/$loader 9fat/$loader || failif(~ $#extra 0 || ! test -f 9fat/plan9.ini || ! test -f 9fat/fs.nvr)	fail missing required 9fat filesdisk/format -b $pbs -d -r 2 $d/9fat \	9fat/^($loader plan9.ini fs.nvr $extra) || fail# prep lies to us.  we need to get the real offset of# 9fat to put the config block on a 8k boundaryoffset=`{awk '$1=="part" && $2=="plan9" {print 8 - $3%8}' < $d/ctl} # add Tconfig taggrep -v '^config' fsconfig | disk/mkfsconf | dd -of $d/fsconfig -oseek $offset -quiet 1