shithub: riscv

ref: 7dee296cc084756f355ea76bc4a7e9fc02c62f26
dir: /sys/src/9/boot/local.rc/

View raw version
#!/bin/rc

fn showlocaldevs{
	echo local devices found:
	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
				;
			case 9fat plan9 nvram
				echo $p
			case *
				t=`{fstype $p}
				if(~ $#bootargs 0 && ! ~ $t '')
					bootargs=local!$p
				echo $p $t
			}
		}
	}
	for(d in /shr/sd*) if(test -d $d) {
		echo $d':'
		for(p in $d/*.^(iso kfs paq)) if(test -f $p){
			t=`{fstype $p}
			if(! ~ $t ''){
				if(~ $#bootargs 0)
					bootargs=local!$p
				echo $p $t
			}
		}
	}
}

fn configlocal{
	diskparts
}

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

fn connectlocal{
	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 kfs
		bootfs disk/kfs $*
	case *
		bootfs $t $*
	}
}

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