Plan 9 from Bell Labs’s /usr/web/sources/contrib/quanstro/root/386/bin/disk/mkfsboot

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#!/bin/rc

fn usage{
	echo usage: mkfsboot device >[1=2]
	exit usage
}

fn fail{
	if(! ~ $#* 0)
		echo $*>[2=1]
	exit fail
}

if(! ~ $#* 1 || ! test -d $1 || ! test -f $1/data)
	usage
if(! test -f fsconfig)
	fail fsconfig missing
if(! test -d 9fat || ! test -f 9fat/9load)
	fail invalid 9fat directory
d=$1

# format properly without password
disk/mknvrsafe -c `{sed -n 's:^config (.*):\1:p' < fsconfig} | dd -quiet 1 -conv sync -of 9fat/fs.nvr
if(! ~ $status '|')
	exit mknvrsafe

dd -if /dev/zero -of $d/data -count 1024 -bs 8192 -quiet 1 || fail
disk/mbr -m /386/mbr $d/data || fail
disk/fdisk -abw $d/data || fail
{
	echo a 9fat 0 0x5000
	echo a nvram 0x5000 0x5001
	echo a fsconfig 0x5040 0x5060
	echo w
	echo q
} | disk/prep $d/plan9 || fail
extra=`{ls -p 9fat/* | grep -v '^(9load|plan9.ini|fs.nvr)$'}
if(! test -f 9fat/9load)
	cp /386/9load 9fat/9load || fail
if(~ $#extra 0 || ! test -f 9fat/plan9.ini || ! test -f 9fat/fs.nvr)
	fail missing required 9fat files
disk/format -b /386/pbslba -d -r 2 $d/9fat \
	9fat/^(9load 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 boundary
offset=`{awk '$1=="part" && $2=="plan9" {print 8 - $3%8}' < $d/ctl}

# add Tconfig tag
grep -v '^config' fsconfig | disk/mkfsconf | dd -of $d/fsconfig -oseek $offset -quiet 1

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].