]> git.lizzy.rs Git - plan9front.git/blob - rc/bin/fstype
crop /lib/face/48x48x8/n/nixie.1 to the right size (was 512x512)
[plan9front.git] / rc / bin / fstype
1 #!/bin/rc
2 rfork e
3 m=`{dd -if $1 -bs 2048 -skip 16 >[2]/dev/null | xd -c | sed 1q | \
4         sed 's/.........(....................).*/\1/; s/ //g'}
5 if(~ $"m 01CD00101){
6         echo 9660
7         exit
8 }
9 fn fat {
10         m=`{dd -if $1 -bs 1 -count 3 -skip $2 >[2]/dev/null}
11         ~ $"m FAT
12 }
13 if(fat $1 54 || fat $1 82){
14         echo dos
15         exit
16 }
17 m=`{dd -if $1 -bs 4 -count 1 >[2]/dev/null | xd | sed 's,0000000  ,,;q'}
18 if(~ $"m 529ab12b){
19         echo paqfs
20         exit
21 }
22 if(~ $"m 011ce50d){
23         echo hjfs
24         exit
25 }
26 dd -if $1 -count 1 >[2]/dev/null | \
27 awk '
28 /^kfs/{fs["kfs"]++}
29 /^(blocksize|daddrbits|daddrbits|indirblks|dirblks|namelen)/{p[$1]=$2}
30 END{
31         ca["fs", "blocksize"] = 4*1024
32         ca["fs", "namelen"] = 28
33         ca["fs", "dirblks"] = 6
34         ca["fs", "indirblks"] = 2
35         ca["fs", "daddrbits"] = 32
36
37         ca["fs64", "blocksize"] = 8*1024
38         ca["fs64", "namelen"] = 56
39         ca["fs64", "dirblks"] = 6
40         ca["fs64", "indirblks"] = 4
41         ca["fs64", "daddrbits"] = 64
42
43         ca["cwfs", "blocksize"] = 16*1024
44         ca["cwfs", "namelen"] = 28
45         ca["cwfs", "dirblks"] = 6
46         ca["cwfs", "indirblks"] = 2
47         ca["cwfs", "daddrbits"] = 32
48
49         ca["cwfs64", "blocksize"] = 16*1024
50         ca["cwfs64", "namelen"] = 56
51         ca["cwfs64", "dirblks"] = 6
52         ca["cwfs64", "indirblks"] = 4
53         ca["cwfs64", "daddrbits"] = 64
54
55         ca["cwfs64x", "blocksize"] = 16*1024
56         ca["cwfs64x", "namelen"] = 144
57         ca["cwfs64x", "dirblks"] = 6
58         ca["cwfs64x", "indirblks"] = 4
59         ca["cwfs64x", "daddrbits"] = 64
60
61         for(e in ca){
62                 split(e, k, SUBSEP)
63                 if(ca[k[1],k[2]] == p[k[2]])
64                         fs[k[1]]++
65         }
66         for(i in fs)
67                 if(fs[i] > fs[j])
68                         j=i
69         if(fs[j]){
70                 print j
71                 exit
72         }
73         exit 1
74 }
75 '