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 filter 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
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
63 case $dev in # One of the controllers? Precompute major device nr.
71 ram|mem|kmem|null|boot|zero|imgrd
)
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
82 do $e mknod ram
$n b
1 $
((7+$n)); $e chmod 600 ram
$n
84 $e chgrp kmem ram
* mem kmem null boot zero imgrd
87 # Floppy disk drive n.
89 d
=`expr $dev : '.*\\(.\\)'` # Drive number.
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
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.
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}"
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
133 # Disk primary partitions.
134 n
=`expr $dev : '\\(.*\\).'` # Name prefix.
135 d
=`expr $dev : '...\\(.\\)'` # Disk number.
140 m
=`expr $d '*' 5 + 1 + $p` # Minor device number.
141 $e mknod
$n$p b
$maj $m
142 alldev
="$alldev $n$p"
144 echo $alldev |
xargs $e chmod 600
146 c
[0-3]d
[0-7]p
[0-3]s
[0-3])
148 n
=`expr $dev : '\\(.*\\)...'` # Name prefix.
149 d
=`expr $dev : '...\\(.\\)'` # Disk number.
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}"
161 echo $alldev |
xargs $e chmod 600
163 c
[0-3]t
[0-7]|c
[0-3]t
[0-7]n
)
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
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
192 $e chgrp operator video
197 m
=`expr $dev : '....\\(.*\\)'` # Minor device number.
205 n
=`expr $dev : '.*\\(.\\)'`
206 $e mknod
$dev c
4 `expr $n + 16`
210 tty
[p-s
][0-9a-f]|pty
[p-s
][0-9a-f])
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.
218 [a-f
]) n
=1`/bin/echo $n | tr 'abcdef' '012345'`
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
)
229 $e mknod eth0 c
7 0 # Network 0 (Ethernet)
233 $e chmod 600 eth0 ip0
234 $e chmod 666 tcp0 udp0
235 $e ln -f eth0 eth
# Default interface
243 $e mknod audio c
13 0
244 $e mknod mixer c
13 1
245 $e chmod 666 audio mixer
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
260 $e mknod filter b
11 0
265 $e mknod hello c
17 0
269 echo "$0: don't know about $dev" >&2