changelog shortlog tags branches changeset files revisions annotate raw help

Mercurial > hg > plan9front / rc/bin/fstype

changeset 7243: 34f64dcbbc25
parent: beeff02ff503
author: cinap_lenrek@felloff.net
date: Fri, 17 May 2019 18:14:10 +0200
permissions: -rwxr-xr-x
description: 7l: don't hardcode 4k pagesize, use INITRND
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 dd -if $1 -count 1 >/env/block >[2]/dev/null
10 fn fat {
11  m=`{dd -if /env/block -bs 1 -count 3 -skip $1 >[2]/dev/null}
12  ~ $"m FAT
13 }
14 if(fat 54 || fat 82){
15  echo dos
16  exit
17 }
18 m=`{dd -if /env/block -bs 4 -count 1 >[2]/dev/null | xd | sed 's,0000000 ,,;q'}
19 if(~ $"m 529ab12b){
20  echo paqfs
21  exit
22 }
23 if(~ $"m 011ce50d){
24  echo hjfs
25  exit
26 }
27 m=`{dd -if /env/block -bs 16 -count 1 -skip 16 >[2]/dev/null}
28 if(~ $"m 'kfs wren device'){
29  echo kfs
30  exit
31 }
32 </env/block awk '
33 /^(blocksize|daddrbits|daddrbits|indirblks|dirblks|namelen)/{p[$1]=$2}
34 END{
35  ca["fs", "blocksize"] = 4*1024
36  ca["fs", "namelen"] = 28
37  ca["fs", "dirblks"] = 6
38  ca["fs", "indirblks"] = 2
39  ca["fs", "daddrbits"] = 32
40 
41  ca["fs64", "blocksize"] = 8*1024
42  ca["fs64", "namelen"] = 56
43  ca["fs64", "dirblks"] = 6
44  ca["fs64", "indirblks"] = 4
45  ca["fs64", "daddrbits"] = 64
46 
47  ca["cwfs", "blocksize"] = 16*1024
48  ca["cwfs", "namelen"] = 28
49  ca["cwfs", "dirblks"] = 6
50  ca["cwfs", "indirblks"] = 2
51  ca["cwfs", "daddrbits"] = 32
52 
53  ca["cwfs64", "blocksize"] = 16*1024
54  ca["cwfs64", "namelen"] = 56
55  ca["cwfs64", "dirblks"] = 6
56  ca["cwfs64", "indirblks"] = 4
57  ca["cwfs64", "daddrbits"] = 64
58 
59  ca["cwfs64x", "blocksize"] = 16*1024
60  ca["cwfs64x", "namelen"] = 144
61  ca["cwfs64x", "dirblks"] = 6
62  ca["cwfs64x", "indirblks"] = 4
63  ca["cwfs64x", "daddrbits"] = 64
64 
65  for(e in ca){
66  split(e, k, SUBSEP)
67  if(ca[k[1],k[2]] == p[k[2]])
68  fs[k[1]]++
69  }
70  for(i in fs)
71  if(fs[i] > fs[j])
72  j=i
73  if(fs[j]){
74  print j
75  exit
76  }
77  exit 1
78 }
79 '