summaryrefslogtreecommitdiff
path: root/sys/src/9/boot/local.rc
blob: c99981042d7f310d1b496e91a89f9f87f219b16b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/rc

fn showlocaldev {
	echo $1'	' $2
	if(~ $#bootargs 0){
		if(! ~ $#cdboot 0){
			if(~ $2 9660)
				bootargs=local!$1
		}
		if not {
			if(! ~ $2 '' dos)
				bootargs=local!$1
		}
	}
}

fn showlocaldevs{
	for(d in /dev/sd*) if(test -r $d/ctl){
		q=`{sed 's,(inquiry|geometry),\
\1,g' $d/ctl | grep inquiry}
		echo $d':' $q(2-)
		for(i in `{ls -p $d}){
			p=$d/$i
			switch($i){
			case ctl raw log led
				;
			case plan9 nvram swap
				echo $p
			case *
				showlocaldev $p `{fstype $p}
			}
		}
	}
	for(d in /shr/sd*) if(test -d $d) {
		echo $d':'
		for(p in $d/*.^(iso paq)) if(test -f $p){
			t=`{fstype $p}
			~ $#t 0 || showlocaldev $p $t
		}
	}
}

fn configlocal{
	diskparts
}

fn bootfs{
	{$1 -s -f $*(2-) &} <[0=1] | echo 0 >/srv/boot
}

fn connectlocal{
	if(~ $#* 0){
		echo local method needs an argument
	}
	if not {
		if(test -f $1)
			t=`{fstype $1}
		if not {
			t=$1; shift
		}
		switch($t){
		case ''
			fatal unknown fstype $1
		case 9660
			bootfs 9660srv $*
		case dos
			bootfs dossrv $*
		case *
			bootfs $t $*
		}
	}
}

mlocal=(configlocal connectlocal)
mt=(mlocal $mt)