source: trunk/minix/commands/scripts/DESCRIBE.sh@ 10

Last change on this file since 10 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

File size: 4.1 KB
RevLine 
[9]1#!/bin/sh
2#
3# DESCRIBE 2.2 - Describe the given devices. Author: Kees J. Bot
4#
5# BUGS
6# - Arguments may not contain shell metacharacters.
7
8case $# in
90) flag=; set -$- /dev ;;
10*) flag=d ;;
11esac
12
13ls -l$flag $* | \
14sed -e '/^total/d' \
15 -e '/^[^bc]/s/.* /BAD BAD /' \
16 -e '/^[bc]/s/.* \([0-9][0-9]*\), *\([0-9][0-9]*\).* /\1 \2 /' \
17| {
18ex=0 # exit code
19
20while read major minor path
21do
22 case $path in
23 /*) name=`expr $path : '.*/\\(.*\\)$'`
24 ;;
25 *) name=$path
26 esac
27 dev= des=
28
29 case $major in # One of the controllers? What is its controller nr?
30 3) ctrlr=0 ;;
31 8) ctrlr=1 ;;
32 10) ctrlr=2 ;;
33 12) ctrlr=3 ;;
34 esac
35
36 case $major,$minor in
37 1,0) des="RAM disk" dev=ram
38 ;;
39 1,1) des="memory" dev=mem
40 ;;
41 1,2) des="kernel memory" dev=kmem
42 ;;
43 1,3) des="null device, data sink" dev=null
44 ;;
45 2,*) drive=`expr $minor % 4`
46 case `expr $minor - $drive` in
47 0) des='auto density' dev="fd$drive"
48 ;;
49 4) des='360k, 5.25"' dev="pc$drive"
50 ;;
51 8) des='1.2M, 5.25"' dev="at$drive"
52 ;;
53 12) des='360k in 720k, 5.25"' dev="qd$drive"
54 ;;
55 16) des='720k, 3.5"' dev="ps$drive"
56 ;;
57 20) des='360k in 1.2M, 5.25"' dev="pat$drive"
58 ;;
59 24) des='720k in 1.2M, 5.25"' dev="qh$drive"
60 ;;
61 28) des='1.44M, 3.5"' dev="PS$drive"
62 ;;
63 112) des='auto partition 0' dev="fd${drive}p0"
64 ;;
65 116) des='auto partition 1' dev="fd${drive}p1"
66 ;;
67 120) des='auto partition 2' dev="fd${drive}p2"
68 ;;
69 124) des='auto partition 3' dev="fd${drive}p3"
70 ;;
71 *) dev=BAD
72 esac
73 des="floppy drive $drive ($des)"
74 ;;
75 [38],[05]|[38],[123][05]|1[02],[05]|1[02],[123][05])
76 drive=`expr $minor / 5`
77 des="controller $ctrlr disk $drive" dev=c${ctrlr}d${drive}
78 ;;
79 [38],?|[38],[123]?|1[02],?|1[02],[123]?)
80 drive=`expr $minor / 5`
81 par=`expr $minor % 5 - 1`
82 des="controller $ctrlr disk $drive partition $par"
83 dev=c${ctrlr}d${drive}p${par}
84 ;;
85 [38],12[89]|[38],1[3-9]?|[38],2??|1[02],12[89]|1[02],1[3-9]?|1[02],2??)
86 drive=`expr \\( $minor - 128 \\) / 16`
87 par=`expr \\( \\( $minor - 128 \\) / 4 \\) % 4`
88 sub=`expr \\( $minor - 128 \\) % 4`
89 des="hard disk $drive, partition $par, subpartition $sub"
90 des="controller $ctrlr disk $drive partition $par slice $sub"
91 #par=`expr $drive '*' 5 + $par`
92 dev=c${ctrlr}d${drive}p${par}s${sub}
93 ;;
94 [38],6[4-9]|[38],7?|1[02],6[4-9]|1[02],7?)
95 tape=`expr \\( $minor - 64 \\) / 2`
96 case $minor in
97 *[02468])
98 des="controller $ctrlr tape $tape (non-rewinding)"
99 dev=c${ctrlr}t${tape}n
100 ;;
101 *[13579])
102 des="controller $ctrlr tape $tape (rewinding)"
103 dev=c${ctrlr}t${tape}
104 esac
105 ;;
106 4,0) des="console device" dev=console
107 ;;
108 4,[1-7])des="virtual console $minor" dev=ttyc$minor
109 ;;
110 4,15) des="diagnostics device" dev=log
111 ;;
112 4,1[6-9])
113 line=`expr $minor - 16`
114 des="serial line $line" dev=tty0$line
115 ;;
116 4,12[89]|4,1[3-8]?|4,19[01])
117 p=`expr \\( $minor - 128 \\) / 16 | tr '0123' 'pqrs'`
118 n=`expr $minor % 16`
119 test $n -ge 10 && n=`expr $n - 10 | tr '012345' 'abcdef'`
120 des="pseudo tty `expr $minor - 128`" dev=tty$p$n
121 ;;
122 4,???)
123 p=`expr \\( $minor - 192 \\) / 16 | tr '0123' 'pqrs'`
124 n=`expr $minor % 16`
125 test $n -ge 10 && n=`expr $n - 10 | tr '012345' 'abcdef'`
126 des="controller of tty$p$n" dev=pty$p$n
127 ;;
128 5,0) des="anonymous tty" dev=tty
129 ;;
130 6,0) des="line printer, parallel port" dev=lp
131 ;;
132 7,*)
133 d=`expr $minor % 8`
134 n=`expr $minor / 8`
135 case $d in
136 0) case $name in
137 psip*)
138 des="Pseudo IP #$n" dev=psip
139 ;;
140 *) des="raw ethernet #$n" dev=eth
141 esac
142 ;;
143 1) des="raw IP #$n" dev=ip
144 ;;
145 2) des="TCP/IP #$n" dev=tcp
146 ;;
147 3) des="UDP #$n" dev=udp
148 esac
149 case $d in
150 [0123])
151 if [ "$name" = "$dev" ]
152 then
153 des="$des (default)"
154 else
155 dev=$dev$n
156 fi
157 esac
158 ;;
159 13,0)
160 des="audio" dev=audio
161 ;;
162 14,0)
163 des="audio mixer" dev=mixer
164 ;;
165 BAD,BAD)
166 des= dev=
167 ;;
168 *) dev=BAD
169 esac
170
171 case $name:$dev in
172 *:)
173 echo "$path: not a device" >&2
174 ex=1
175 ;;
176 *:*BAD*)
177 echo "$path: cannot describe: major=$major, minor=$minor" >&2
178 ex=1
179 ;;
180 $dev:*)
181 echo "$path: $des"
182 ;;
183 *:*) echo "$path: nonstandard name for $dev: $des"
184 esac
185done
186
187exit $ex
188}
Note: See TracBrowser for help on using the repository browser.