2 |
- |
1 |
#!/bin/rc
|
|
|
2 |
|
|
|
3 |
first=`{ls -p '#S' | sed 1q}
|
|
|
4 |
if(! ~ $first $disk) {
|
|
|
5 |
echo 'warning: The plan 9 partition is not on the boot disk,'
|
|
|
6 |
echo 'so making it the active partition will have no effect.'
|
|
|
7 |
}
|
|
|
8 |
|
|
|
9 |
p9offset=`{grep '^part 9fat ' /dev/$disk/ctl |awk '{print $3}'}
|
|
|
10 |
if(! ~ $#p9offset 1) {
|
|
|
11 |
echo 'could not find plan 9 partition.'
|
|
|
12 |
echo 'cannot happen'
|
|
|
13 |
exit bad
|
|
|
14 |
}
|
|
|
15 |
|
|
|
16 |
if(test $p9offset -gt 4128695) { # 65536 * 63 - 10
|
|
|
17 |
echo
|
|
|
18 |
echo 'Your Plan 9 partition is more than 2GB into your disk,'
|
|
|
19 |
echo 'and the master boot records used by Windows 9x/ME'
|
|
|
20 |
echo 'cannot access it (and thus cannot boot it).'
|
|
|
21 |
echo
|
|
|
22 |
echo 'You can install the Plan 9 master boot record, which can load'
|
|
|
23 |
echo 'partitions far into the disk.'
|
|
|
24 |
echo
|
|
|
25 |
}
|
|
|
26 |
|
|
|
27 |
echo 'If you use the Windows NT/2000/XP master boot record'
|
|
|
28 |
echo 'or a master boot record from a Unix clone (e.g., LILO or'
|
|
|
29 |
echo 'FreeBSD bootmgr), it is probably safe to continue using'
|
|
|
30 |
echo 'that boot record rather than install the Plan 9 boot record.'
|
|
|
31 |
echo
|
|
|
32 |
prompt 'Install the Plan 9 master boot record' y n
|
|
|
33 |
switch($rd) {
|
|
|
34 |
case n
|
|
|
35 |
;
|
|
|
36 |
case y
|
|
|
37 |
disk/mbr -m /386/mbr /dev/$disk/data
|
|
|
38 |
}
|
|
|
39 |
|
|
|
40 |
log Setting Plan 9 partition active.
|
|
|
41 |
p9part=`{disk/fdisk /dev/$disk/data >[2]/dev/null </dev/null |
|
|
|
42 |
grep PLAN9 | sed 1q | sed 's/ *(p.) .*/\1/'}
|
|
|
43 |
if(~ $#p9part 0){
|
|
|
44 |
echo 'You have no Plan 9 partitions (How could this happen?)' >[1=2]
|
|
|
45 |
exit 'no plan 9 partition found'
|
|
|
46 |
}
|
|
|
47 |
p9part=$p9part(1)
|
|
|
48 |
{ echo 'A '^$p9part; echo w } | disk/fdisk /dev/$disk/data >[2]/dev/null >/dev/null
|
|
|
49 |
x=$status
|
|
|
50 |
if(~ $x '' '|'){
|
|
|
51 |
echo
|
|
|
52 |
echo 'The Plan 9 partition is now marked as active.'
|
|
|
53 |
exit ''
|
|
|
54 |
}
|
|
|
55 |
exit $x
|