pci: don't do sanity check for missing pci bus, the check can misfire.
[minix.git] / commands / scripts / MAKEDEV.sh
bloba35149864e5537b4403c2557cb7028ed86196d25
1 #!/bin/sh
3 # MAKEDEV 3.3 - Make special devices. Author: Kees J. Bot
5 case $1 in
6 -n) e=echo; shift ;; # Just echo when -n is given.
7 *) e=
8 esac
10 case $#:$1 in
11 1:std) # Standard devices.
12 set -$- mem fd0 fd1 fd0p0 fd1p0 \
13 c0d0 c0d0p0 c0d0p0s0 c0d1 c0d1p0 c0d1p0s0 \
14 c0d2 c0d2p0 c0d2p0s0 c0d3 c0d3p0 c0d3p0s0 \
15 c0d4 c0d4p0 c0d4p0s0 c0d5 c0d5p0 c0d5p0s0 \
16 c0d6 c0d6p0 c0d6p0s0 c0d7 c0d7p0 c0d7p0s0 \
17 c1d0 c1d0p0 c1d0p0s0 c1d1 c1d1p0 c1d1p0s0 \
18 c1d2 c1d2p0 c1d2p0s0 c1d3 c1d3p0 c1d3p0s0 \
19 c1d4 c1d4p0 c1d4p0s0 c1d5 c1d5p0 c1d5p0s0 \
20 c1d6 c1d6p0 c1d6p0s0 c1d7 c1d7p0 c1d7p0s0 \
21 tty ttyc1 ttyc2 ttyc3 tty00 tty01 tty02 tty03 \
22 ttyp0 ttyp1 ttyp2 ttyp3 ttyp4 ttyp5 ttyp6 ttyp7 ttyp8 ttyp9 \
23 ttypa ttypb ttypc ttypd ttype ttypf \
24 ttyq0 ttyq1 ttyq2 ttyq3 ttyq4 ttyq5 ttyq6 ttyq7 ttyq8 ttyq9 \
25 ttyqa ttyqb ttyqc ttyqd ttyqe ttyqf \
26 eth klog random filter hello
28 0:|1:-\?)
29 cat >&2 <<EOF
30 Usage: $0 [-n] key ...
31 Where key is one of the following:
32 ram mem kmem null boot zero # One of these makes all these memory devices
33 fd0 fd1 ... # Floppy devices for drive 0, 1, ...
34 fd0p0 fd1p0 ... # Make floppy partitions fd0p[0-3], fd1p[0-3], ...
35 c0d0 c0d1 ... # Make disks c0d0, c0d1, ...
36 c0d0p0 c0d1p0 ... # Make partitions c0d0p[0-3], c0d1p[0-3], ...
37 c0d0p0s0 c0d1p0s0 ... # Subparts c0d0p[0-3]s[0-3], c0d1p[0-3]s[0-3], ...
38 c1d0(p0)(s0) # Likewise for controller 1
39 c0t0 c0t1 c1t0 ... # Make tape devices c0t0, c0t0n, c0t1, ...
40 console lp tty log # One of these makes all four
41 ttyc1 ... ttyc7 # Virtual consoles
42 tty00 ... tty03 # Make serial lines
43 ttyp0 ... ttyq0 ... # Make tty, pty pairs
44 eth ip tcp udp # One of these makes some TCP/IP devices
45 audio mixer # Make audio devices
46 klog # Make /dev/klog
47 random # Make /dev/random, /dev/urandom
48 kbd # Make /dev/kbd
49 kbdaux # Make /dev/kbdaux
50 filter # Make /dev/filter
51 hello # Make /dev/hello
52 video # Make /dev/video
53 std # All standard devices
54 EOF
55 exit 1
56 esac
58 umask 077
59 ex=0
61 for dev
63 case $dev in # One of the controllers? Precompute major device nr.
64 c0*) maj=3 ;;
65 c1*) maj=8 ;;
66 c2*) maj=10 ;;
67 c3*) maj=12 ;;
68 esac
70 case $dev in
71 ram|mem|kmem|null|boot|zero|imgrd)
72 # Memory devices.
74 $e mknod ram b 1 0; $e chmod 600 ram
75 $e mknod mem c 1 1; $e chmod 640 mem
76 $e mknod kmem c 1 2; $e chmod 640 kmem
77 $e mknod null c 1 3; $e chmod 666 null
78 $e mknod boot b 1 4; $e chmod 600 ram
79 $e mknod zero c 1 5; $e chmod 644 zero
80 $e mknod imgrd b 1 6; $e chmod 644 zero
81 for n in 0 1 2 3 4 5
82 do $e mknod ram$n b 1 $((7+$n)); $e chmod 600 ram$n
83 done
84 $e chgrp kmem ram* mem kmem null boot zero imgrd
86 fd[0-3])
87 # Floppy disk drive n.
89 d=`expr $dev : '.*\\(.\\)'` # Drive number.
90 $e mknod $dev b 2 $d
91 $e chmod 666 $dev
93 pc[0-3]|at[0-3]|qd[0-3]|ps[0-3]|pat[0-3]|qh[0-3]|PS[0-3])
94 # Obsolete density locked floppy disk drive n.
96 d=`expr $dev : '.*\\(.\\)'` # Drive number.
97 m=$d # Minor device number.
99 $e mknod pc$d b 2 $m; m=`expr $m + 4`
100 $e mknod at$d b 2 $m; m=`expr $m + 4`
101 $e mknod qd$d b 2 $m; m=`expr $m + 4`
102 $e mknod ps$d b 2 $m; m=`expr $m + 4`
103 $e mknod pat$d b 2 $m; m=`expr $m + 4`
104 $e mknod qh$d b 2 $m; m=`expr $m + 4`
105 $e mknod PS$d b 2 $m; m=`expr $m + 4`
107 $e chmod 666 pc$d at$d qd$d ps$d pat$d qh$d PS$d
109 fd[0-3]p[0-3])
110 # Floppy disk partitions.
112 n=`expr $dev : '\\(.*\\)..'` # Name prefix.
113 d=`expr $dev : '..\\(.\\)'` # Drive number.
114 m=`expr 112 + $d` # Minor of partition 0.
115 alldev=
117 for p in 0 1 2 3
119 m=`expr 112 + $d + $p '*' 4` # Minor of partition $p.
120 $e mknod ${n}p${p} b 2 $m # Make e.g. fd0p0 - fd0p3
121 alldev="$alldev ${n}p${p}"
122 done
123 $e chmod 666 $alldev
125 c[0-3]d[0-7])
126 # Whole disk devices.
127 d=`expr $dev : '...\\(.\\)'` # Disk number.
128 m=`expr $d '*' 5` # Minor device number.
129 $e mknod $dev b $maj $m
130 $e chmod 600 $dev
132 c[0-3]d[0-7]p[0-3])
133 # Disk primary partitions.
134 n=`expr $dev : '\\(.*\\).'` # Name prefix.
135 d=`expr $dev : '...\\(.\\)'` # Disk number.
136 alldev=
138 for p in 0 1 2 3
140 m=`expr $d '*' 5 + 1 + $p` # Minor device number.
141 $e mknod $n$p b $maj $m
142 alldev="$alldev $n$p"
143 done
144 echo $alldev | xargs $e chmod 600
146 c[0-3]d[0-7]p[0-3]s[0-3])
147 # Disk subpartition.
148 n=`expr $dev : '\\(.*\\)...'` # Name prefix.
149 d=`expr $dev : '...\\(.\\)'` # Disk number.
150 alldev=
152 for p in 0 1 2 3
154 for s in 0 1 2 3
156 m=`expr 128 + $d '*' 16 + $p '*' 4 + $s` # Minor device nr.
157 $e mknod ${n}${p}s${s} b $maj $m
158 alldev="$alldev ${n}${p}s${s}"
159 done
160 done
161 echo $alldev | xargs $e chmod 600
163 c[0-3]t[0-7]|c[0-3]t[0-7]n)
164 # Tape devices.
165 n=`expr $dev : '\\(....\\)'` # Name prefix.
166 t=`expr $dev : '...\\(.\\)'` # Tape number.
167 m=`expr 64 + $t '*' 2` # Minor device number.
168 $e mknod ${n}n c $maj $m
169 $e mknod ${n} c $maj `expr $m + 1`
170 $e chmod 660 ${n}n ${n}
172 console|lp|tty|log|kbd|kbdaux|video)
173 # Console, line printer, anonymous tty, diagnostics device,
174 # raw keyboard, ps/2 mouse, video.
175 $e mknod console c 4 0
176 $e chmod 600 console
177 $e chgrp tty console
178 $e mknod tty c 5 0
179 $e chmod 666 tty
180 $e mknod lp c 6 0
181 $e chown daemon lp
182 $e chgrp daemon lp
183 $e chmod 200 lp
184 $e mknod log c 4 15
185 $e chmod 222 log
186 $e mknod kbd c 4 127
187 $e mknod kbdaux c 4 126
188 $e chmod 660 kbd kbdaux
189 $e chgrp operator kbd kbdaux
190 $e mknod video c 4 125
191 $e chmod 600 video
192 $e chgrp operator video
194 ttyc[1-7])
195 # Virtual consoles.
197 m=`expr $dev : '....\\(.*\\)'` # Minor device number.
198 $e mknod $dev c 4 $m
199 $e chgrp tty $dev
200 $e chmod 600 $dev
202 tty0[0-3])
203 # Serial lines.
205 n=`expr $dev : '.*\\(.\\)'`
206 $e mknod $dev c 4 `expr $n + 16`
207 $e chmod 666 $dev
208 $e chgrp tty $dev
210 tty[p-s][0-9a-f]|pty[p-s][0-9a-f])
211 # Pseudo ttys.
213 dev=`expr $dev : '...\\(..\\)'`
214 g=`expr $dev : '\\(.\\)'` # Which group.
215 g=`echo $g | tr 'pqrs' '0123'`
216 n=`expr $dev : '.\\(.\\)'` # Which pty in the group.
217 case $n in
218 [a-f]) n=1`/bin/echo $n | tr 'abcdef' '012345'`
219 esac
221 $e mknod tty$dev c 4 `expr $g '*' 16 + $n + 128`
222 $e mknod pty$dev c 4 `expr $g '*' 16 + $n + 192`
223 $e chgrp tty tty$dev pty$dev
224 $e chmod 666 tty$dev pty$dev
226 eth|ip|tcp|udp|eth0|ip0|tcp0|udp0)
227 # TCP/IP devices.
229 $e mknod eth0 c 7 0 # Network 0 (Ethernet)
230 $e mknod ip0 c 7 1
231 $e mknod tcp0 c 7 2
232 $e mknod udp0 c 7 3
233 $e chmod 600 eth0 ip0
234 $e chmod 666 tcp0 udp0
235 $e ln -f eth0 eth # Default interface
236 $e ln -f ip0 ip
237 $e ln -f tcp0 tcp
238 $e ln -f udp0 udp
240 audio|mixer)
241 # Audio devices.
243 $e mknod audio c 13 0
244 $e mknod mixer c 13 1
245 $e chmod 666 audio mixer
247 random|urandom)
248 # random data generator.
249 $e mknod random c 16 0; $e chmod 644 random
250 $e mknod urandom c 16 0; $e chmod 644 urandom
251 $e chgrp operator random urandom
253 klog)
254 # logging device.
255 $e mknod klog c 15 0
256 $e chmod 600 klog
258 filter)
259 # filter driver
260 $e mknod filter b 11 0
261 $e chmod 644 filter
263 hello)
264 # hello driver
265 $e mknod hello c 17 0
266 $e chmod 644 hello
269 echo "$0: don't know about $dev" >&2
270 ex=1
271 esac
272 done
274 exit $ex