3 # MAKEDEV 3.3 - Make special devices. Author: Kees J. Bot
6 -n) e
=echo; shift ;; # Just echo when -n is given.
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 uds filter fbd hello
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
47 random # Make /dev/random, /dev/urandom
50 kbdaux # Make /dev/kbdaux
51 filter # Make /dev/filter
53 hello # Make /dev/hello
54 video # Make /dev/video
55 std # All standard devices
65 case $dev in # One of the controllers? Precompute major device nr.
73 ram|mem|kmem|null|boot|zero|imgrd
)
76 $e mknod ram b
1 0; $e chmod 600 ram
77 $e mknod mem c
1 1; $e chmod 640 mem
78 $e mknod kmem c
1 2; $e chmod 640 kmem
79 $e mknod null c
1 3; $e chmod 666 null
80 $e mknod boot b
1 4; $e chmod 600 ram
81 $e mknod zero c
1 5; $e chmod 644 zero
82 $e mknod imgrd b
1 6; $e chmod 644 zero
84 do $e mknod ram
$n b
1 $
((7+$n)); $e chmod 600 ram
$n
86 $e chgrp kmem ram
* mem kmem null boot zero imgrd
89 # Floppy disk drive n.
91 d
=`expr $dev : '.*\\(.\\)'` # Drive number.
95 pc
[0-3]|
at[0-3]|qd
[0-3]|ps
[0-3]|pat
[0-3]|qh
[0-3]|PS
[0-3])
96 # Obsolete density locked floppy disk drive n.
98 d
=`expr $dev : '.*\\(.\\)'` # Drive number.
99 m
=$d # Minor device number.
101 $e mknod pc
$d b
2 $m; m
=`expr $m + 4`
102 $e mknod
at$d b
2 $m; m
=`expr $m + 4`
103 $e mknod qd
$d b
2 $m; m
=`expr $m + 4`
104 $e mknod ps
$d b
2 $m; m
=`expr $m + 4`
105 $e mknod pat
$d b
2 $m; m
=`expr $m + 4`
106 $e mknod qh
$d b
2 $m; m
=`expr $m + 4`
107 $e mknod PS
$d b
2 $m; m
=`expr $m + 4`
109 $e chmod 666 pc
$d at$d qd
$d ps
$d pat
$d qh
$d PS
$d
112 # Floppy disk partitions.
114 n
=`expr $dev : '\\(.*\\)..'` # Name prefix.
115 d
=`expr $dev : '..\\(.\\)'` # Drive number.
116 m
=`expr 112 + $d` # Minor of partition 0.
121 m
=`expr 112 + $d + $p '*' 4` # Minor of partition $p.
122 $e mknod
${n}p
${p} b
2 $m # Make e.g. fd0p0 - fd0p3
123 alldev
="$alldev ${n}p${p}"
128 # Whole disk devices.
129 d
=`expr $dev : '...\\(.\\)'` # Disk number.
130 m
=`expr $d '*' 5` # Minor device number.
131 $e mknod
$dev b
$maj $m
135 # Disk primary partitions.
136 n
=`expr $dev : '\\(.*\\).'` # Name prefix.
137 d
=`expr $dev : '...\\(.\\)'` # Disk number.
142 m
=`expr $d '*' 5 + 1 + $p` # Minor device number.
143 $e mknod
$n$p b
$maj $m
144 alldev
="$alldev $n$p"
146 echo $alldev |
xargs $e chmod 600
148 c
[0-3]d
[0-7]p
[0-3]s
[0-3])
150 n
=`expr $dev : '\\(.*\\)...'` # Name prefix.
151 d
=`expr $dev : '...\\(.\\)'` # Disk number.
158 m
=`expr 128 + $d '*' 16 + $p '*' 4 + $s` # Minor device nr.
159 $e mknod
${n}${p}s${s} b
$maj $m
160 alldev
="$alldev ${n}${p}s${s}"
163 echo $alldev |
xargs $e chmod 600
165 c
[0-3]t
[0-7]|c
[0-3]t
[0-7]n
)
167 n
=`expr $dev : '\\(....\\)'` # Name prefix.
168 t
=`expr $dev : '...\\(.\\)'` # Tape number.
169 m
=`expr 64 + $t '*' 2` # Minor device number.
170 $e mknod
${n}n c
$maj $m
171 $e mknod
${n} c
$maj `expr $m + 1`
172 $e chmod 660 ${n}n
${n}
174 console|
lp|tty|log|kbd|kbdaux|video
)
175 # Console, line printer, anonymous tty, diagnostics device,
176 # raw keyboard, ps/2 mouse, video.
177 $e mknod console c
4 0
189 $e mknod kbdaux c
4 126
190 $e chmod 660 kbd kbdaux
191 $e chgrp operator kbd kbdaux
192 $e mknod video c
4 125
194 $e chgrp operator video
199 m
=`expr $dev : '....\\(.*\\)'` # Minor device number.
207 n
=`expr $dev : '.*\\(.\\)'`
208 $e mknod
$dev c
4 `expr $n + 16`
212 tty
[p-s
][0-9a-f]|pty
[p-s
][0-9a-f])
215 dev
=`expr $dev : '...\\(..\\)'`
216 g
=`expr $dev : '\\(.\\)'` # Which group.
217 g
=`echo $g | tr 'pqrs' '0123'`
218 n
=`expr $dev : '.\\(.\\)'` # Which pty in the group.
220 [a-f
]) n
=1`/bin/echo $n | tr 'abcdef' '012345'`
223 $e mknod tty
$dev c
4 `expr $g '*' 16 + $n + 128`
224 $e mknod pty
$dev c
4 `expr $g '*' 16 + $n + 192`
225 $e chgrp tty tty
$dev pty
$dev
226 $e chmod 666 tty
$dev pty
$dev
228 eth|ip|tcp|udp|eth0|ip0|tcp0|udp0
)
231 $e mknod eth0 c
7 0 # Network 0 (Ethernet)
235 $e chmod 600 eth0 ip0
236 $e chmod 666 tcp0 udp0
237 $e ln -f eth0 eth
# Default interface
245 $e mknod audio c
13 0
246 $e mknod mixer c
13 1
247 $e chmod 666 audio mixer
250 # random data generator.
251 $e mknod random c
16 0; $e chmod 644 random
252 $e mknod urandom c
16 0; $e chmod 644 urandom
253 $e chgrp operator random urandom
256 # unix domain sockets device
257 $e mknod uds c
18 0; $e chmod 644 random
258 $e chgrp operator uds
268 $e mknod filter b
11 0
272 # faulty block device driver
278 $e mknod hello c
17 0
282 echo "$0: don't know about $dev" >&2