ref: a5e2b9ad4d0ab7c9e70af520abb8dc2d026308b6
parent: f6b8ecb26b0139514694d677ac01c7bdbc9b827a
author: cinap_lenrek <cinap_lenrek@localhost>
date: Thu Apr 21 06:40:03 EDT 2011
add fstype command to detect 9660, kfs and cwfs filesystems
--- /dev/null
+++ b/rc/bin/fstype
@@ -1,0 +1,57 @@
+#!/bin/rc
+m=`{dd -if $1 -bs 2048 -skip 16 >[2]/dev/null | xd -c | sed 1q | \+ sed 's/.........(....................).*/\1/; s/ //g'}
+if(~ $"m 01CD00101){+ echo 9660
+ exit
+}
+dd -if $1 -count 1 >[2]/dev/null | \
+awk '
+/^kfs/{fs["kfs"]++}+/^(blocksize|daddrbits|daddrbits|indirblks|dirblks|namelen)/{p[$1]=$2}+END{+ ca["fs", "blocksize"] = 4*1024
+ ca["fs", "namelen"] = 28
+ ca["fs", "dirblks"] = 6
+ ca["fs", "indirblks"] = 2
+ ca["fs", "daddrbits"] = 32
+
+ ca["fs64", "blocksize"] = 8*1024
+ ca["fs64", "namelen"] = 56
+ ca["fs64", "dirblks"] = 6
+ ca["fs64", "indirblks"] = 4
+ ca["fs64", "daddrbits"] = 64
+
+ ca["cwfs", "blocksize"] = 16*1024
+ ca["cwfs", "namelen"] = 28
+ ca["cwfs", "dirblks"] = 6
+ ca["cwfs", "indirblks"] = 2
+ ca["cwfs", "daddrbits"] = 32
+
+ ca["cwfs64", "blocksize"] = 16*1024
+ ca["cwfs64", "namelen"] = 56
+ ca["cwfs64", "dirblks"] = 6
+ ca["cwfs64", "indirblks"] = 4
+ ca["cwfs64", "daddrbits"] = 64
+
+ ca["cwfs64x", "blocksize"] = 16*1024
+ ca["cwfs64x", "namelen"] = 144
+ ca["cwfs64x", "dirblks"] = 6
+ ca["cwfs64x", "indirblks"] = 4
+ ca["cwfs64x", "daddrbits"] = 64
+
+ for(e in ca){+ split(e, k, SUBSEP)
+ if(ca[k[1],k[2]] == p[k[2]])
+ fs[k[1]]++
+ }
+ for(i in fs)
+ if(fs[i] > fs[j])
+ j=i
+ if(fs[j]){+ print j
+ exit
+ }
+ exit 1
+}
+'
--- a/sys/src/9/boot/local.rc
+++ b/sys/src/9/boot/local.rc
@@ -3,11 +3,13 @@
fn showlocaldevs{echo local devices found:
for(c in /dev/sd*/ctl){- d=`{echo $c | sed 's,/ctl,,g'}- echo $d':' `{sed 's/inquiry[ ]+//g; q' $c}- for(i in `{ls -p $d | grep -v -e 'ctl|raw'})- echo $d'/'$i
- echo
+ if(test -r $c){+ d=`{echo $c | sed 's,/ctl,,g'}+ echo $d':' `{sed 's/inquiry[ ]+//g; q' $c}+ for(i in `{ls -p $d | grep -v -e 'ctl|raw'})+ echo $d'/'$i `{fstype $d'/'$i}+ echo
+ }
}
}
@@ -24,16 +26,15 @@
}
fn connectlocal{- part=`{echo $* | sed 's,.*/([^ ]+),\1,g'}- part=$part(1)
- switch($part){- case kfs fs
- must disk/kfs -n boot -f $*
- case cwfs fscache fsworm w0 w1 w2 w3
- must cwfs64x -n boot -f $*
- case data
+ t=`{fstype $1}+ if(~ $#t 0)
+ fatal unknown fstype $1
+ switch($t){+ case 9660
must 9660srv -f $* boot
+ case kfs
+ must disk/kfs -n boot -f $*
case *
- fatal unknown partition $part
+ must $t -n boot -f $*
}
}
--- a/sys/src/9/port/bootfs.proto
+++ b/sys/src/9/port/bootfs.proto
@@ -39,6 +39,7 @@
local.rc 555 sys sys ../boot/local.rc
tcp.rc 555 sys sys ../boot/tcp.rc
bin
+ fstype
diskparts
bootrc 555 sys sys ../boot/bootrc
tmp
--
⑨