]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - etc/MAKEDEV
Longshire LCS-8634TB
[FreeBSD/FreeBSD.git] / etc / MAKEDEV
1 #!/bin/sh -
2 #
3 # Copyright (c) 1990 The Regents of the University of California.
4 # All rights reserved.
5 #
6 # Written and contributed by W. Jolitz 12/90
7 #
8 # Redistribution and use in source and binary forms are permitted provided
9 # that: (1) source distributions retain this entire copyright notice and
10 # comment, and (2) distributions including binaries display the following
11 # acknowledgement:  ``This product includes software developed by the
12 # University of California, Berkeley and its contributors'' in the
13 # documentation or other materials provided with the distribution and in
14 # all advertising materials mentioning features or use of this software.
15 # Neither the name of the University nor the names of its contributors may
16 # be used to endorse or promote products derived from this software without
17 # specific prior written permission.
18 # THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
19 # WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
20 # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
21 #
22 #       @(#)MAKEDEV     5.2 (Berkeley) 6/22/90
23 # $FreeBSD$
24 #
25 # Device "make" file.  Valid arguments:
26 #       all     makes all known devices, standard number of units (or close)
27 #       std     standard devices
28 #       jail    suitable for a jail(8)
29 #       local   configuration specific devices
30 #       mach-4  mach4&lites+devices for Mach's XFree86 distribution
31 #       (see http://www.cs.hut.fi/lites.html for more info on LITES)
32 #
33 # Tapes:
34 #       wt*     QIC-interfaced (e.g. not SCSI) 3M cartridge tape
35 #       sa*     SCSI Sequential Access Devices
36 #
37 # Disks:
38 #       aac*    Adaptec FSA RAID controllers
39 #       aacd*   Adaptec FSA RAID
40 #       acd*    ATAPI CD-ROM disks
41 #       amrd*   AMI MegaRAID
42 #       cd*     SCSI CD-ROM disks
43 #       da*     SCSI Direct Access Devices
44 #       fd*     floppy disk drives (3 1/2", 5 1/4")
45 #       fla*    M-Systems DiskOnChip
46 #       idad*   Compaq Smart-2 RAID arrays
47 #       matcd*  Matsushita (Panasonic) CD-ROM disks
48 #       mcd*    Mitsumi CD-ROM disks
49 #       md*     Memory (or malloc) disk
50 #       mlx*    Mylex DAC960 RAID controllers
51 #       mlxd*   Mylex DAC960 RAID disk volumes
52 #       mly*    Mylex RAID controllers (newer models)
53 #       scd*    Sony CD-ROM disks
54 #       wd*     "Winchester" disk drives (ST506,IDE,ESDI,RLL,...)
55 #       wfd*    IDE floppy disk drives (LS-120)
56 #
57 # Console ports:
58 #       vty*    virtual console devices for syscons/pcvt/codrv
59 #
60 # Pointing devices:
61 #       mse*    Logitech and ATI Inport bus mouse
62 #       psm*    PS/2 mouse
63 #       jogdial Sony VAIO jog dial
64 #       sysmouse Mousesystems mouse emulator for syscons
65 #
66 # Time devices:
67 #       refclock-*  serial ports used by xntpd parse refclocks
68 #
69 # Terminal ports:
70 #       tty*    general purpose serial ports
71 #       cua*    dialout serial ports
72 #       ttyA*   Specialix SI/XIO dialin ports ('*' = number of devices)
73 #       cuaA*   Specialix SI/XIO dialout ports
74 #       ttyDXX  Digiboard Xi - 16 dialin ports (dgb)
75 #       cuaDXX  Digiboard Xi - 16 dialout ports (dgb)
76 #       ttyDX.X Digiboards (work in progress) - 16 dialin ports (digi)
77 #       cuaDX.X Digiboards (work in progress) - 16 dialout ports (digi)
78 #       ttyM*   Digiboard Xem - 16 dialin ports (dgm)
79 #       cuaM*   Digiboard Xem - 16 dialout ports (dgm)
80 #       ttyR*   Rocketport dialin ports
81 #       cuaR*   Rocketport dialout ports
82 #
83 # Pseudo terminals:
84 #       pty*    set of 32 master and slave pseudo terminals
85 #       vty*    virtual terminals using syscons/pcvt/codrv console
86 #
87 # Parallel port:
88 #       lpt*    Printer
89 #       ppi*    Parallel port i/o
90 #       pps*    Pulse per second timing interface
91 #       pcfclock*  Parallel time sync interface
92 #
93 # I2C and SMBus:
94 #       iic*    I2C devices
95 #       smb*    SMBUS devices
96 #
97 # USB devices:
98 #       usb*    USB bus control device
99 #       ugen*   generic USB device
100 #       uhid*   Human Interface Device (HID)
101 #       ulpt*   printer
102 #       umodem* modems
103 #       ums*    mouse
104 #       urio*   Diamond Rio 500
105 #       uscanner* USB scanners
106 #       usio*   USB serial devices
107 #
108 # SCSI devices (other than CD-ROM, tape and disk):
109 #       ch*     SCSI Media-Changer (juke box) driver
110 #       worm*   WORM driver
111 #       pt*     Processor Type (HP scanner, as one example)
112 #       pass*   CAM Passthrough device
113 #       ses*    SES (SCSI Environmental Services) and
114 #               SAF-TE (Scsi Accessable Fault-Tolerant Enclosures) device
115 #
116 # PC-CARD (previously called PCMCIA) support
117 #       card*   PC-CARD slots
118 #
119 # ISDN devices:
120 #       i4b     isdnd call control device
121 #       i4bctl  debugging control device
122 #       i4btrc* trace data interface(s), one per passive card
123 #       i4btel* telephony interface(s)
124 #       i4bteld* telephony dialout interface(s)
125 #       i4brbch* raw b channel access device(s)
126 #
127 # Special purpose devices:
128 #       acpi    Advanced Configuration and Power Interface
129 #       apm     Advanced Power Management BIOS
130 #       apmctl  APM BIOS control device
131 #       bpf*    packet filter
132 #       speaker pc speaker
133 #       tw*     xten power controller
134 #       snd*    various sound cards
135 #       pcaudio PCM audio driver
136 #       socksys iBCS2 socket system driver
137 #       vat     VAT compatibility audio driver (requires snd*)
138 #       gsc     Genius GS-4500 hand scanner
139 #       joy     pc joystick
140 #       tun*    Tunneling IP device
141 #       tap*    Ethernet Tunneling device
142 #       snp*    tty snoop devices
143 #       spigot  Video Spigot video acquisition card
144 #       ctx*    Cortex-I video acquisition card
145 #       meteor* Matrox Meteor video acquisition card (pci)
146 #       bktr*   Bt848 based video acquisition card (pci)
147 #       labpc*  National Instrument's Lab-PC and LAB-PC+
148 #       perfmon CPU performance-monitoring counters
149 #       pci     PCI configuration-space access from user mode
150 #       ipl     ipfilter control devices (ipl, ipnat, ipstate, ipauth)
151 #       kbd     keyboard devices
152 #       3dfx*   3dfx voodoo device for glide (tdfx) (/dev/3dfx,3dfxN,voodoo)
153 #       agpgart AGP interface
154 #       cfs*    Coda Distributed Filesystem
155 #       nsmb*   SMB/CIFS protocol interface
156 #
157
158 if [ -n "$MAKEDEVPATH" ]; then
159         PATH="$MAKEDEVPATH"
160 else
161         PATH=/sbin:/bin
162 fi
163 umask 77
164
165 # Usage: die exitcode msg
166 die() {
167         echo $2
168         exit $1
169 }
170
171 # Convert integer to partition name
172 dkitop() {
173         local p
174
175         case $1 in
176         0) p=a;; 1) p=b;; 2) p=c;; 3) p=d;; 4) p=e;; 5) p=f;; 6) p=g;; 7) p=h;;
177         *) p="?";;
178         esac
179         echo $p
180 }
181
182 # Convert integer to slice name
183 dkitos() {
184         local s
185
186         case $1 in
187         0) s="";;
188         1) s="";;
189         *) s=s$(($1-1));;
190         esac
191         echo $s
192 }
193
194 # Convert disk (type, unit, slice, partition) to minor number
195 dkminor()
196 {
197         echo $(($1 << 25 | ($2 / 32) << 21 | ($2 % 32) << 3 | $3 << 16 | $4))
198 }
199
200 # Print the hexadecimal representation of a decimal value from 0 to 15.
201 hexdigit() {
202         local d
203
204         if [ $1 -lt 10 ]; then
205                 d=$1
206         else
207                 case $1 in
208                 10) d=a;; 11) d=b;; 12) d=c;; 13) d=d;; 14) d=e;; 15) d=f;;
209                 *) d="?";;
210                 esac
211         fi
212         echo $d
213 }
214
215 # Print the hexadecimal representation of an arbitrary decimal value.
216 hexprint() {
217         local dig
218         local str
219         local val
220
221         val=$1
222         str=''
223         dig=`hexdigit $(($val & 15))`
224         str=$dig$str
225         val=$(($val >> 4))
226         while [ $val -gt 0 ]; do
227                 dig=`hexdigit $(($val & 15))`
228                 str=$dig$str
229                 val=$(($val >> 4))
230         done
231         echo $str
232 }
233
234 # Override mknod(2) to add extra handling to it.
235 mknod=/sbin/mknod
236 for i in `IFS=':'; echo $PATH`; do
237         if [ -x "${i}/mknod" ]; then
238                 mknod="${i}/mknod"
239                 break
240         fi
241 done
242 mknod() {
243         rm -f "$1" || exit 1
244         case $# in
245         4) "$mknod" "$@" root:wheel || die 2 "$mknod $@ failed";;
246         5) "$mknod" "$@"            || die 2 "$mknod $@ failed";;
247         *) die 2 "bad node: mknod $@";;
248         esac
249 }
250
251 # Convert tape (ctrl, unit, mode, access) to minor number
252 saminor()
253 {
254         echo $(($1 << 29 | ($2 / 16) << 16 | ($2 % 16) << 4 | $3 << 2 | $4))
255 }
256
257 # Convert the last character of a tty name to a minor number.
258 ttyminor()
259 {
260         case $unit in
261         [0-9]) m=$unit;;
262         a) m=10;; b) m=11;; c) m=12;; d) m=13;; e) m=14;; f) m=15;; g) m=16;;
263         h) m=17;; i) m=18;; j) m=19;; k) m=20;; l) m=21;; m) m=22;; n) m=23;;
264         o) m=24;; p) m=25;; q) m=26;; r) m=27;; s) m=28;; t) m=29;; u) m=30;;
265         v) m=31;;
266         *) m="?";;
267         esac
268         echo $m
269 }
270
271 # Convert a unit number to a minor number.
272 unit2minor()
273 {
274         echo $(((($1 >> 8) << 16) | ($1 % 256)))
275 }
276
277 # Zero-pad a value to the appropriate minimum length.
278 zeropad() {
279         local min
280         local val
281
282         min=$1
283         val=$2
284         while [ ${#val} -lt $min ]; do
285                 val=0$val
286         done
287         echo $val
288 }
289
290 # Raw partition for disks
291 dkrawpart=2
292
293 # Compatibility slice for disks
294 dkcompatslice=0
295
296 # Raw slice for disks
297 dkrawslice=1
298
299 # Standard umasks
300 disk_umask=037                  # allow group operator to read disks
301 tape_umask=017                  # allow group operator to read/write tapes
302
303 for i in $*; do
304 case $i in
305
306 all)
307         sh $0 std                                       # standard
308         sh $0 fd0 fd1                                   # floppy disk
309         sh $0 da0 da1 da2 da3                           # SCSI disk
310         sh $0 ata                                       # ATA control
311         sh $0 ad0 ad1 ad2 ad3                           # ATA disk
312         sh $0 ar0 ar1                                   # ATA RAID disk
313         sh $0 acd0 acd0t0 afd0 ast0                     # ATAPI devices
314         sh $0 wd0 wd1 wd2 wd3                           # OLD disk
315         sh $0 wcd0 wfd0 wst0                            # OLD ATAPI devs
316         sh $0 cd0 matcd0 mcd0 scd0                      # cdrom
317         sh $0 sa0 wt0                                   # tape
318         sh $0 vty12                                     # virtual tty
319         sh $0 cuaa0 cuaa1 cuaa2 cuaa3                   # serial tty
320         sh $0 pty0                                      # pseudo tty
321         sh $0 ttyd0 ttyd1 ttyd2 ttyd3                   # serial tty
322         sh $0 kbd0 kbd1                                 # keyboard
323         sh $0 mse0 psm0 jogdial sysmouse                # mouse
324         sh $0 pcaudio speaker                           # noise
325         sh $0 lpt0 lpt1 lpt2                            # printer
326         sh $0 ppi0 ppi1 ppi2                            # parallel port
327         sh $0 iic0 iic1                                 # I2C device
328         sh $0 smb0 smb1                                 # SMBus device
329         sh $0 usb usb0 uhid0 ums0 ulpt0 ugen0           # USB devices
330         sh $0 urio0 uscanner0 umodem0                   # USB devices too
331         sh $0 bpf0 bpf1 bpf2 bpf3                       # network
332         sh $0 ipl tun0 tun1 tun2 tun3                   # network
333         sh $0 tap0 tap1 tap2 tap3                       # network
334         sh $0 ch0 perfmon tw0                           # miscellaneous
335         sh $0 acpi                                      # ACPI
336         sh $0 apm apmctl card0 card1 card2 card3        # laptop
337         sh $0 pass4 xpt2                                # CAM
338         sh $0 i4b i4bctl i4btrc0 i4btrc1                # ISDN
339         sh $0 i4btel0 i4btel1 i4bteld0 i4bteld1         # ISDN
340         sh $0 i4brbch0 i4brbch1                         # ISDN
341         sh $0 agpgart                                   # AGP
342         sh $0 nsmb0                                     # SMB/CIFS
343         ;;
344
345 # a much restricted set of the above, to save precious i-nodes on the
346 # fixit floppy
347 fixit)
348         sh $0 std                                       # standard
349         sh $0 fd0                                       # floppy disk
350         sh $0 da0                                       # SCSI disk
351         sh $0 ad0                                       # ATA disk
352         sh $0 acd0 afd0 ast0                            # ATAPI devices
353         sh $0 wd0                                       # OLD disk
354         sh $0 wcd0 wfd0 wst0                            # OLD ATAPI devs
355         sh $0 cd0                                       # cdrom
356         sh $0 sa0                                       # tape
357         sh $0 vty2                                      # virtual tty
358         sh $0 cuaa0                                     # serial tty
359         sh $0 pty0                                      # pseudo tty
360         sh $0 ttyd0                                     # serial tty
361         sh $0 kbd0                                      # keyboard
362         sh $0 mse0 psm0 jogdial sysmouse                # mouse
363         sh $0 lpt0                                      # printer
364         sh $0 ppi0                                      # parallel port
365         sh $0 iic0                                      # I2C device
366         sh $0 smb0                                      # SMBus device
367         sh $0 ums0                                      # USB devices
368         sh $0 tun0                                      # network
369         sh $0 tap0                                      # network
370         sh $0 ch0                                       # miscellaneous
371         sh $0 acpi                                      # ACPI
372         sh $0 apm apmctl card0                          # laptop
373         sh $0 pass1 xpt1                                # CAM
374         sh $0 i4b i4bctl i4btrc0 i4btrc1                # ISDN
375         sh $0 i4btel0 i4bteld0                          # ISDN
376         sh $0 i4brbch0                                  # ISDN
377         rm -f fd/[1-9]?
378         ;;
379
380 std)
381         mknod console   c 0 0;                  chmod 600 console
382         mknod kmem      c 2 1 root:kmem;        chmod 640 kmem
383         mknod mem       c 2 0 root:kmem;        chmod 640 mem
384         mknod null      c 2 2;                  chmod 666 null
385         mknod random    c 2 3;                  chmod 666 random
386         ln -f random urandom
387         mknod zero      c 2 12;                 chmod 666 zero
388         mknod io        c 2 14;                 chmod 600 io
389         mknod tty       c 1 0;                  chmod 666 tty
390         mknod klog      c 7 0;                  chmod 600 klog
391         mknod pci       c 78 0;                 chmod 644 pci
392         mknod mdctl     c 95 0xffff00ff;        chmod 600 mdctl
393         mkdir -p fd
394         (cd fd && i=0 &&
395                 while [ $i -lt 64 ]; do
396                         mknod $i c 22 $i
397                         i=$(($i + 1))
398                 done
399         )
400         chmod 555 fd
401         chmod 666 fd/*
402         ln -sf fd/0 stdin
403         ln -sf fd/1 stdout
404         ln -sf fd/2 stderr
405         ;;
406
407 jail)
408         sh $0 std pty0
409         rm mem kmem pci io klog console         # for security
410         ln -sf null mem                 # for libkvm (ab)users
411         ln -sf null kmem                # --//--
412         ln -sf null console
413         ;;
414
415 mach-4)
416         mknod iopl c 22 0
417         mknod kbd c 23 0
418         mknod mouse c 24 0
419         mknod time c 25 0
420         mknod timezone c 26 0
421         ;;
422
423 # Create device files for new Archive/Wangtek QIC-02 tape driver (vak)
424 wt*)
425         umask $tape_umask
426         u=`expr $i : '..\(.*\)'`
427         if [ -z "${u}" ]; then u=0; fi
428         # default density, 512b blocks
429         mknod rwt${u}   c 10 $(( 0 + $u)) root:operator
430         mknod nrwt${u}  c 10 $(( 4 + $u)) root:operator
431         # default density, 1024b blocks
432 #       mknod rWt${u}   c 10 $((64 + $u)) root:operator
433 #       mknod nrWt${u}  c 10 $((68 + $u)) root:operator
434         mknod rwt${u}b  c 10 $((16 + $u)) root:operator # 60 megabytes
435         mknod nrwt${u}b c 10 $((20 + $u)) root:operator
436         mknod rwt${u}c  c 10 $((24 + $u)) root:operator # 120 megabytes
437         mknod nrwt${u}c c 10 $((28 + $u)) root:operator
438         mknod rwt${u}d  c 10 $((32 + $u)) root:operator # 150 megabytes
439         mknod nrwt${u}d c 10 $((36 + $u)) root:operator
440 #       mknod rwt${u}e  c 10 $((40 + $u)) root:operator # 300 megabytes?
441 #       mknod nrwt${u}e c 10 $((44 + $u)) root:operator
442 #       mknod rwt${u}f  c 10 $((48 + $u)) root:operator # 600 megabytes?
443 #       mknod nrwt${u}f c 10 $((52 + $u)) root:operator
444         umask 77
445         ;;
446
447 # Individual slices.
448 aacd*s*|ad*s*|ar*s*|afd*s*|amrd*s*|da*s*|fla*s*|idad*s*|md*s*|mlxd*s*|twed*s*|wd*s*|wfd*s*)
449         umask $disk_umask
450         case $i in
451         aacd*s*) name=aacd; chr=151;;
452         ad*s*) name=ad; chr=116;;
453         ar*s*) name=ar; chr=157;;
454         afd*s*) name=afd; chr=118;;
455         amrd*s*) name=amrd; chr=133;;
456         da*s*) name=da;  chr=13;;
457         fla*s*) name=fla; chr=102;;
458         idad*s*) name=idad; chr=109;;
459         md*s*) name=md;  chr=95;;
460         mlxd*s*) name=mlxd; chr=131;;
461         twed*s*) name=twed; chr=147;;
462         wd*s*) name=wd;  chr=3;;
463         wfd*s*) name=wfd; chr=87;;
464         esac
465         case $i in
466         aacd*s*|amrd*s*|idad*s*|mlxd*s*|twed*s*)
467                 unit=`expr $i : '....\([0-9]*\)s'`
468                 slice=`expr $i : '....[0-9]*s\([0-9]*\)'`
469                 part=`expr $i : '....[0-9]*s[0-9]*\(.*\)'`
470                 ;;
471         afd*s*|fla*s*|wfd*s*)
472                 unit=`expr $i : '...\([0-9]*\)s'`
473                 slice=`expr $i : '...[0-9]*s\([0-9]*\)'`
474                 part=`expr $i : '...[0-9]*s[0-9]*\(.*\)'`
475                 ;;
476         *)
477                 unit=`expr $i : '..\([0-9]*\)s'`
478                 slice=`expr $i : '..[0-9]*s\([0-9]*\)'`
479                 part=`expr $i : '..[0-9]*s[0-9]*\(.*\)'`
480                 ;;
481         esac
482         case $unit in
483         [0-9]|[0-9][0-9]|[0-4][0-9][0-9]|50[0-9]|51[0-1])
484                 case $slice in
485                 [0-9]|[1-2][0-9]|30)
486                         oldslice=$slice
487                         slice=$(($slice+1))
488                         slicename=`dkitos $slice`
489                         minor=`dkminor 0 $unit $slice $dkrawpart`
490                         mknod  $name$unit$slicename c $chr $minor root:operator
491                         ln -f $name$unit$slicename r$name$unit$slicename
492                         case $part in
493                         [a-h])
494                                 case $oldslice in
495                                 0) slice=$oldslice ;;
496                                 esac
497                                 for part in 0 1 2 3 4 5 6 7
498                                 do
499                                         minor=`dkminor 0 $unit $slice $part`
500                                         partname=`dkitop $part`
501                                         mknod  $name$unit$slicename$partname \
502                                               c $chr $minor root:operator
503                                         ln -f $name$unit$slicename$partname \
504                                              r$name$unit$slicename$partname
505                                 done
506                                 ;;
507                         "")
508                                 ;;
509                         *)
510                                 echo bad partition for disk in: $i
511                                 ;;
512                         esac
513                         ;;
514                 *)
515                         echo bad slice for disk in: $i
516                         ;;
517                 esac
518                 ;;
519         *)
520                 echo bad unit for disk in: $i "(unit=$unit, slice=$slice, part=$part)"
521                 ;;
522         esac
523         umask 77
524         ;;
525
526 fd*)
527         umask $disk_umask
528         unit=`expr $i : '..\(.*\)'`
529         name=fd; chr=9
530         case $unit in
531         0|1|2|3)
532                 mknod ${name}${unit}   c $chr $(($unit * 64)) root:operator
533                 ln -f ${name}${unit} r${name}${unit}
534                 # Fake BSD partitions
535                 for i in a b c d e f g h
536                 do
537                         ln -f ${name}${unit} ${name}${unit}$i
538                         ln -f r${name}${unit} r${name}${unit}$i
539                 done
540                 # User-readable and programmer-readable name sets
541
542                 mknod ${name}${unit}.1720  c $chr $(($unit * 64 + 1)) \
543                     root:operator
544                 ln -f ${name}${unit}.1720 r${name}${unit}.1720
545                 # ln -f ${name}${unit}.1720 ${name}${unit}135hs21
546                 # ln -f r${name}${unit}.1720 r${name}${unit}135hs21
547
548                 mknod ${name}${unit}.1480  c $chr $(($unit * 64 + 2)) \
549                     root:operator
550                 ln -f ${name}${unit}.1480 r${name}${unit}.1480
551                 # ln -f ${name}${unit}.1480 ${name}${unit}135hs18
552                 # ln -f r${name}${unit}.1480 r${name}${unit}135hs18
553                 # ln -f ${name}${unit}.1480 ${name}${unit}96hs18
554                 # ln -f r${name}${unit}.1480 r${name}${unit}96hs18
555
556                 mknod ${name}${unit}.1440  c $chr $(($unit * 64 + 3)) \
557                     root:operator
558                 ln -f ${name}${unit}.1440 r${name}${unit}.1440
559                 # ln -f ${name}${unit}.1440 ${name}${unit}135
560                 # ln -f r${name}${unit}.1440 r${name}${unit}135
561                 # ln -f ${name}${unit}.1440 ${name}${unit}135ds18
562                 # ln -f r${name}${unit}.1440 r${name}${unit}135ds18
563                 # ln -f ${name}${unit}.1440 ${name}${unit}96ds18
564                 # ln -f r${name}${unit}.1440 r${name}${unit}96ds18
565
566                 mknod ${name}${unit}.1200  c $chr $(($unit * 64 + 4)) \
567                     root:operator
568                 ln -f ${name}${unit}.1200 r${name}${unit}.1200
569                 # ln -f ${name}${unit}.1200 ${name}${unit}96
570                 # ln -f r${name}${unit}.1200 r${name}${unit}96
571                 # ln -f ${name}${unit}.1200 ${name}${unit}96ds15
572                 # ln -f r${name}${unit}.1200 r${name}${unit}96ds15
573                 # ln -f ${name}${unit}.1200 ${name}${unit}135ds15
574                 # ln -f r${name}${unit}.1200 r${name}${unit}135ds15
575
576                 mknod ${name}${unit}.820  c $chr $(($unit * 64 + 5)) \
577                     root:operator
578                 ln -f ${name}${unit}.820 r${name}${unit}.820
579                 # ln -f ${name}${unit}.820 ${name}${unit}96hs10
580                 # ln -f r${name}${unit}.820 r${name}${unit}96hs10
581                 # ln -f ${name}${unit}.820 ${name}${unit}135hs10
582                 # ln -f r${name}${unit}.820 r${name}${unit}135hs10
583
584                 mknod ${name}${unit}.800  c $chr $(($unit * 64 + 6)) \
585                     root:operator
586                 ln -f ${name}${unit}.800 r${name}${unit}.800
587                 # ln -f ${name}${unit}.800 ${name}${unit}96ds10
588                 # ln -f r${name}${unit}.800 r${name}${unit}96ds10
589                 # ln -f ${name}${unit}.800 ${name}${unit}135ds10
590                 # ln -f r${name}${unit}.800 r${name}${unit}135ds10
591
592                 mknod ${name}${unit}.720  c $chr $(($unit * 64 + 7)) \
593                     root:operator
594                 ln -f ${name}${unit}.720 r${name}${unit}.720
595                 # ln -f ${name}${unit}.720 ${name}${unit}96ds9
596                 # ln -f r${name}${unit}.720 r${name}${unit}96ds9
597                 # ln -f ${name}${unit}.720 ${name}${unit}135ds9
598                 # ln -f r${name}${unit}.720 r${name}${unit}135ds9
599
600                 mknod ${name}${unit}.360  c $chr $(($unit * 64 + 8)) \
601                     root:operator
602                 ln -f ${name}${unit}.360 r${name}${unit}.360
603                 # ln -f ${name}${unit}.360 ${name}${unit}48
604                 # ln -f r${name}${unit}.360 r${name}${unit}48
605                 # ln -f ${name}${unit}.360 ${name}${unit}48ds9
606                 # ln -f r${name}${unit}.360 r${name}${unit}48ds9
607
608                 mknod ${name}${unit}.640  c $chr $(($unit * 64 + 9)) \
609                     root:operator
610                 ln -f ${name}${unit}.640 r${name}${unit}.640
611                 # ln -f ${name}${unit}.640 ${name}${unit}96ds8
612                 # ln -f r${name}${unit}.640 r${name}${unit}96ds8
613                 # ln -f ${name}${unit}.640 ${name}${unit}135ds8
614                 # ln -f r${name}${unit}.640 r${name}${unit}135ds8
615
616                 mknod ${name}${unit}.1232  c $chr $(($unit * 64 + 10)) \
617                     root:operator
618                 ln -f ${name}${unit}.1232 r${name}${unit}.1232
619                 # ln -f ${name}${unit}.1232 ${name}${unit}96ds8
620                 # ln -f r${name}${unit}.1232 r${name}${unit}96ds8
621                 # ln -f ${name}${unit}.1232 ${name}${unit}135ds8
622                 # ln -f r${name}${unit}.1232 r${name}${unit}135ds8
623                 ;;
624         *)
625                 echo bad unit for disk in: $i
626                 ;;
627         esac
628         umask 77
629         ;;
630
631 ata)
632         umask 177
633         mknod ata c 159 0 root:operator
634         umask 77
635         ;;
636         
637
638 aacd*|ad*|ar*|afd*|amrd*|da*|fla*|idad*|md*|mlxd*|twed*|wd*|wfd*)
639         umask $disk_umask
640         case $i in
641         aacd*) name=aacd; chr=151;;
642         ad*) name=ad; chr=116;;
643         ar*) name=ar; chr=157;;
644         afd*) name=afd; chr=118;;
645         amrd*) name=amrd; chr=133;;
646         da*) name=da;  chr=13;;
647         fla*) name=fla; chr=102;;
648         idad*) name=idad; chr=109;;
649         md*) name=md; chr=95;;
650         mlxd*) name=mlxd; chr=131;;
651         twed*) name=twed; chr=147;;
652         wd*) name=wd;  chr=3;;
653         wfd*) name=wfd; chr=87;;
654         esac
655         case $i in
656         aacd*|amrd*|idad*|mlxd*|twed*)
657                 unit=`expr $i : '....\(.*\)'`
658                 ;;
659         afd*|fla*|wfd*)
660                 unit=`expr $i : '...\(.*\)'`
661                 ;;
662         *)
663                 unit=`expr $i : '..\(.*\)'`
664                 ;;
665         esac
666         case $unit in
667         [0-9]|[0-9][0-9]|[0-4][0-9][0-9]|50[0-9]|51[0-1])
668                 for slicepartname in s0h s1h s2 s3 s4
669                 do
670                         sh $0 $name$unit$slicepartname
671                 done
672                 ;;
673         *)
674                 echo bad unit for disk in: $i
675                 ;;
676         esac
677         umask 77
678         ;;
679
680 ccd*)
681         umask $disk_umask
682         name=ccd
683         chr=74
684         unit=`expr $i : '...\(.*\)'`
685         case $unit in
686         [0-9]|[0-9][0-9]|[0-4][0-9][0-9]|50[0-9]|51[0-1])
687                 for part in 0 1 2 3 4 5 6 7
688                 do
689                         minor=`dkminor 0 $unit 0 $part`
690                         partname=`dkitop $part`
691                         mknod  $name$unit$partname c $chr $minor root:operator
692                         ln -f $name$unit$partname r$name$unit$partname
693                 done
694                 ;;
695         *)
696                 echo bad unit for disk in: $i
697                 ;;
698         esac
699         umask 77
700         ;;
701
702 # SCSI processor type driver
703 pt[0-9]*)
704         chr=61
705         name=pt
706         unit=`expr $i : 'pt\([0-9][0-9]*\)'`
707         if [ -z "${unit}" ]; then
708                 unit=0
709         fi
710         unit=$(($unit + 1 - 1))
711         mknod ${name}${unit} c $chr `unit2minor $unit`
712         ;;
713
714 # SCSI SES/SAF-TE type driver
715 ses[0-9]*)
716         chr=110
717         name=ses
718         unit=`expr $i : 'ses\([0-9][0-9]*\)'`
719         if [ -z "${unit}" ]; then
720                 unit=0
721         fi
722         unit=$(($unit + 1 - 1))
723         mknod ${name}${unit} c $chr `unit2minor $unit`
724         ;;
725 # SCSI target mode sample driver
726 targ[0-9]*)
727         chr=65
728         name=targ
729         unit=`expr $i : 'targ\([0-9][0-9]*\)'`
730         if [ -z "${unit}" ]; then
731                 unit=0
732         fi
733         unit=$(($unit + 1 - 1))
734         mknod ${name}${unit} c $chr `unit2minor $unit`
735         mknod ${name}.ctl c $chr 0xffff00ff
736         ;;
737
738 # CAM transport layer device
739 xpt*)
740         # This major number is temporary
741         chr=104
742         name=xpt
743         units=`expr $i : 'xpt\(.*\)'`
744         if [ -z "${units}" ]; then
745                 units=1
746         fi
747         i=0
748         while [ $i -lt $units ]; do
749                 dname=$name$i
750                 rm -rf $dname r$dname
751                 mknod $dname c $chr `unit2minor $i` root:operator
752                 i=$(($i + 1))
753         done    
754         ;;
755
756 # CAM passthrough device
757 pass*)
758         # This major number is temporary
759         chr=31
760         name=pass
761         units=`expr $i : 'pass\(.*\)'`
762         if [ -z "${units}" ]; then
763                 units=1
764         fi
765         i=0
766         while [ $i -lt $units ]; do
767                 dname=$name$i
768                 rm -rf $dname r$dname
769                 mknod $dname c $chr `unit2minor $i` root:operator
770                 i=$(($i + 1))
771         done    
772         ;;
773 pty*)
774         class=`expr $i : 'pty\(.*\)'`
775         case $class in
776         0) offset=0 name=p;;
777         1) offset=32 name=q;;
778         2) offset=64 name=r;;
779         3) offset=96 name=s;;
780 # Note that xterm (at least) only look at p-s.
781         4) offset=128 name=P;;
782         5) offset=160 name=Q;;
783         6) offset=192 name=R;;
784         7) offset=224 name=S;;
785         # This still leaves [tuTU].
786         *) echo bad unit for pty in: $i;;
787         esac
788         umask 0
789         case $class in
790         0|1|2|3|4|5|6|7)
791                 i=0
792                 while [ $i -lt 32 ]; do
793 #                       This was an awk substr() before.
794                         c=$(echo 0123456789abcdefghijklmnopqrstuv |
795                             dd bs=1 skip=$i count=1 2>/dev/null)
796                         mknod tty$name$c c 5 $(($offset + $i))
797                         mknod pty$name$c c 6 $(($offset + $i))
798                         i=$(($i + 1))
799                 done
800                 ;;
801         esac
802         umask 77
803         ;;
804
805 sa*)
806         umask $tape_umask
807         unit=`expr $i : '..\(.*\)'`
808         chr=14
809
810         case $unit in
811         [0-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9])
812                 mknod sa${unit}.ctl c $chr `saminor 1 ${unit} 0 0`
813                 ln -f sa${unit}.ctl rsa${unit}.ctl
814                 for m in 0 1 2 3
815                 do
816                         mknod sa${unit}.${m} c $chr \
817                             `saminor 0 ${unit} ${m} 0`  root:operator
818                         ln -f sa${unit}.${m} rsa${unit}.${m}
819                         mknod nsa${unit}.${m} c $chr \
820                             `saminor 0 ${unit} ${m} 1` root:operator
821                         ln -f nsa${unit}.${m} nrsa${unit}.${m}
822                         mknod esa${unit}.${m} c $chr \
823                             `saminor 0 ${unit} ${m} 2` root:operator
824                         ln -f esa${unit}.${m} ersa${unit}.${m}
825                 done
826                 ln -f sa${unit}.0 sa${unit}
827                 ln -f sa${unit}.0 rsa${unit}.0
828                 ln -f sa${unit}.0 rsa${unit}
829                 ln -f nsa${unit}.0 nsa${unit}
830                 ln -f nsa${unit}.0 nrsa${unit}.0
831                 ln -f nsa${unit}.0 nrsa${unit}
832                 ln -f esa${unit}.0 esa${unit}
833                 ln -f esa${unit}.0 ersa${unit}.0
834                 ln -f esa${unit}.0 ersa${unit}
835                 ;;
836         *)
837                 echo bad unit for tape in: $i
838                 ;;
839         esac
840         umask 77
841         ;;
842
843 ch*)
844         umask 37
845         unit=`expr $i : '..\(.*\)'`
846         case $i in
847         ch*) name=ch;  chr=17;;
848         esac
849         case $unit in
850         0|1|2|3|4|5|6)
851                 mknod ${name}${unit}    c $chr $unit root:operator
852                 ;;
853         *)
854                 echo bad unit for media changer in: $i
855                 ;;
856         esac
857         umask 77
858         ;;
859
860 ast*)
861         umask 2 ;
862         unit=`expr $i : '...\(.*\)'`
863         chr=119
864         case $unit in
865         0|1|2|3)
866                 mknod ast${unit} c $chr $(($unit * 8 + 0)) root:operator
867                 chmod 640 ast${unit}
868                 mknod nast${unit} c $chr $(($unit * 8 + 1)) root:operator
869                 chmod 640 nast${unit}
870                 ;;
871         *)
872                 echo bad unit for tape in: $i
873                 ;;
874         esac
875         umask 77
876         ;;
877
878 acd*t*)
879         umask $disk_umask
880         units=`expr $i : '...\(.*\)t'`;
881         tracks=`expr $i : '.*t\(.*\)'`;
882         name=acd;
883         chr=117;
884         if [ -z "${units}" -o "${units}" -le 0 ]; then
885                 units=1
886         fi
887         if [ -z "${tracks}" -o "${tracks}" -le 0 ]; then
888                 tracks=100
889         fi
890         if [ "${units}" -le 31 -a "${tracks}" -le 169 ]; then
891                 i=0
892                 while [ $i -le $units ]; do
893                         dname=$name$i
894                         rm -rf ${dname}t*
895                         j=1
896                         while [ $j -le ${tracks} ]; do
897                                 mknod ${dname}t$j c $chr \
898                                         $((($i * 8) + (65536 * $j))) \
899                                         root:operator
900                                 j=$(($j + 1))
901                         done
902                         i=$(($i + 1))
903                 done
904         else
905                 echo "$i is invalid -- can't have more than 32 cd devices or 169 tracks"
906         fi
907         umask 77
908         ;;
909
910 acd*|cd*|mcd*|scd*)
911         umask $disk_umask
912         case $i in
913         acd*) units=`expr $i : '...\(.*\)'`; name=acd; chr=117;;
914         cd*) units=`expr $i : '..\(.*\)'`; name=cd; chr=15;;
915         mcd*) units=`expr $i : '...\(.*\)'`; name=mcd; chr=29;;
916         scd*) units=`expr $i : '...\(.*\)'`; name=scd; chr=45;;
917         esac
918         if [ -z "${units}" -o "${units}" -le 0 ]; then
919                 units=1
920         fi
921         if [ "${units}" -le 31 ]; then
922                 i=0
923                 while [ $i -le $units ]; do
924                         dname=$name$i
925                         rm -rf ${dname}[!t]* r${dname}*
926                         mknod ${dname}a c $chr $(($i * 8)) root:operator
927                         mknod ${dname}c c $chr $(($i * 8 + 2)) root:operator
928                         ln -f ${dname}a r${dname}a
929                         ln -f ${dname}c r${dname}c
930                         i=$(($i + 1))
931                 done
932         else
933                 echo "$i is invalid -- can't have more than 32 cd devices"
934         fi
935         umask 77
936         ;;
937
938 matcd*)
939         umask 2
940         case $i in
941         matcd*) unit=`expr $i : '.....\(.*\)'`; name=matcd; chr=46;;
942         esac
943         case $unit in
944         0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15)
945                 mknod ${name}${unit}a   c $chr $(($unit * 8 + 0)) \
946                     root:operator
947                 mknod ${name}${unit}c   c $chr $(($unit * 8 + 2)) \
948                     root:operator
949                 ln -f ${name}${unit}a r${name}${unit}a
950                 ln -f ${name}${unit}c r${name}${unit}c
951                 chmod 640 ${name}${unit}[a-h] r${name}${unit}[a-h]
952
953                 mknod ${name}${unit}la  c $chr $(($unit * 8 + 128)) \
954                     root:operator
955                 mknod ${name}${unit}lc  c $chr $(($unit * 8 + 130)) \
956                     root:operator
957                 ln -f ${name}${unit}la r${name}${unit}la
958                 ln -f ${name}${unit}lc r${name}${unit}lc
959                 chmod 640 ${name}${unit}l[a-h] r${name}${unit}l[a-h]
960                 ;;
961         *)
962                 echo bad unit for disk in: $i
963                 ;;
964         esac
965         umask 77
966         ;;
967
968 wcd*)
969         umask 2 ;
970         unit=`expr $i : '...\(.*\)'`
971         chr=69
972         case $unit in
973         0|1|2|3|4|5|6|7)
974                 mknod wcd${unit}a  c $chr $(($unit * 8 + 0)) root:operator
975                 mknod wcd${unit}c  c $chr $(($unit * 8 + 2)) root:operator
976                 ln -f wcd${unit}a rwcd${unit}a
977                 ln -f wcd${unit}c rwcd${unit}c
978                 chmod 640 wcd${unit}[a-h] rwcd${unit}[a-h]
979                 ;;
980         *)
981                 echo bad unit for disk in: $i
982                 ;;
983         esac
984         umask 77
985         ;;
986
987 wst*)
988         umask 2 ;
989         unit=`expr $i : '...\(.*\)'`
990         chr=90
991         case $unit in
992         0|1|2|3)
993                 mknod rwst${unit} c $chr $(($unit * 8 + 0)) root:operator
994                 chmod 640 rwst${unit}
995                 ;;
996         esac
997         umask 77
998         ;;
999
1000 iic*)
1001         unit=`expr $i : 'iic\(.*\)'`
1002         mknod iic$unit c 105 `unit2minor $unit`
1003         ;;
1004
1005 smb*)
1006         unit=`expr $i : 'smb\(.*\)'`
1007         mknod smb$unit c 106 `unit2minor $unit`
1008         ;;
1009
1010 pcfclock*)
1011         unit=`expr $i : 'pcfclock\(.*\)'`
1012         mknod pcfclock$unit c 140 `unit2minor $unit`
1013         ;;
1014
1015 ppi*)
1016         unit=`expr $i : 'ppi\(.*\)'`
1017         mknod ppi$unit c 82 `unit2minor $unit`
1018         ;;
1019
1020 pps*)
1021         unit=`expr $i : 'pps\(.*\)'`
1022         mknod pps$unit c 89 `unit2minor $unit`
1023         ;;
1024
1025 usb)
1026         mknod usb$unit c 108 255 root:operator
1027         chmod 0660 usb$unit
1028         ;;
1029
1030 usb*)
1031         umask 7
1032         unit=`expr $i : 'usb\(.*\)'`
1033         mknod usb$unit c 108 `unit2minor $unit` root:operator
1034         umask 77
1035         ;;
1036
1037 uhid*)
1038         umask 7
1039         unit=`expr $i : 'uhid\(.*\)'`
1040         mknod uhid$unit c 122 `unit2minor $unit` root:operator
1041         umask 77
1042         ;;
1043
1044 ums*)
1045         umask 7
1046         unit=`expr $i : 'ums\(.*\)'`
1047         mknod ums$unit c 111 `unit2minor $unit` root:operator
1048         umask 77
1049         ;;
1050
1051 ulpt*)
1052         unit=`expr $i : 'ulpt\(.*\)'`
1053         minor=`unit2minor $unit`
1054         mknod ulpt$unit c 113 $minor
1055         minor=`unit2minor $(($unit + 64))`
1056         mknod unlpt$unit c 113 $minor           # and the 'no prime' version
1057         ;;
1058
1059 ugen*)
1060         umask 7
1061         unit=`expr $i : 'ugen\([0-9][0-9]*\)'`
1062         endpoint=`expr $i : 'ugen.*\.\([0-9][0-9]*\)'`
1063         if [ -z "${unit}" ]; then
1064                 echo $i - Invalid unit number
1065         fi
1066         if [ -z "${endpoint}" ]; then           # ugen0 & ugen0.1 - ugen0.15
1067                 mknod ugen$unit c 114 \
1068                                 `unit2minor $(($unit * 16))` root:operator
1069                 i=1
1070                 while [ $i -lt 16 ]; do
1071                         mknod ugen$unit.$i c 114 \
1072                                 `unit2minor $(($unit * 16 + $i))` root:operator
1073                         i=$(($i + 1))
1074                 done
1075         else
1076                 minor=`unit2minor $(($unit * 16 + $endpoint))`
1077                 mknod ugen$unit.$endpoint c 114 $minor root:operator
1078         fi
1079         umask 77
1080         ;;
1081
1082 urio*)
1083         umask 7
1084         unit=`expr $i : 'urio\(.*\)'`
1085         mknod urio$unit c 143 `unit2minor $unit` root:operator
1086         umask 77
1087         ;;
1088
1089 usio*)
1090         umask 7
1091         unit=`expr $i : 'usio\(.*\)'`
1092         minor=`unit2minor $(($unit + 128))`
1093         mknod usio$unit c 138 $minor uucp:dialer
1094         umask 77
1095         ;;
1096
1097 uscanner*)
1098         umask 7
1099         unit=`expr $i : 'uscanner\(.*\)'`
1100         mknod uscanner$unit c 156 `unit2minor $unit` root:operator
1101         umask 77
1102         ;;
1103
1104 umodem*)
1105         umask 7
1106         unit=`expr $i : 'umodem\(.*\)'`
1107         mknod umodem$unit c 124 `unit2minor $unit` uucp:dialer
1108         umask 77
1109         ;;
1110
1111 lpt*)
1112         unit=`expr $i : 'lpt\(.*\)'`
1113         mknod lpt$unit c 16 `unit2minor $unit`
1114         mknod lpctl$unit c 16 `unit2minor $(($unit + 128))`
1115         ;;
1116
1117 # Use this to create virtual consoles for syscons, pcvt or codrv
1118 # ttyv0-b
1119 # use as MAKEDEV vtyNN to create NN entries
1120 vty*)
1121         chr=12
1122         units=`expr $i : 'vty\(.*\)'`
1123         i=0
1124         while [ $i -lt $units ]; do
1125                 mknod ttyv$(hexprint $i) c $chr `unit2minor $i`
1126                 i=$(($i + 1))
1127         done
1128         ln -fs ttyv0 vga        # XXX X still needs this pccons relic
1129         ;;
1130
1131 nmdm*)
1132         units=`expr $i : 'nmdm\(.*\)'`
1133         chr=18
1134         i=0
1135         while [ $i -lt $units ]; do
1136                 minor=`unit2minor $i`
1137                 minor=$(($minor + $minor))
1138                 mknod nmdm${i}A c $chr $minor
1139                 mknod nmdm${i}B c $chr $(($minor + 1))
1140                 i=$(($i + 1))
1141         done
1142         ;;
1143
1144 bpf*)
1145         units=`expr $i : 'bpf\(.*\)$'`
1146         unit=0
1147         while [ $unit -le $units ]; do
1148                 mknod bpf$unit c 23 `unit2minor $unit`
1149                 unit=$(($unit + 1))
1150         done
1151         ;;
1152
1153 speaker)
1154         mknod speaker c 26 0
1155         ;;
1156
1157 cuaa?|cua?)
1158         umask 7
1159         unit=`expr $i : 'cua.*\(.\)$'`
1160         m=`ttyminor $unit`
1161         mknod cuaa$unit c 28 $(($m + 128)) uucp:dialer
1162         mknod cuaia$unit c 28 $(($m + 32 + 128)) uucp:dialer
1163         mknod cuala$unit c 28 $(($m + 64 + 128)) uucp:dialer
1164         umask 77
1165         ;;
1166
1167 tty0?|ttyd?|tty?)
1168         unit=`expr $i : 'tty.*\(.\)$'`
1169         m=`ttyminor $unit`
1170         mknod ttyd$unit c 28 $m
1171         mknod ttyid$unit c 28 $(($m + 32))
1172         mknod ttyld$unit c 28 $(($m + 64))
1173         ;;
1174
1175 cuac?)
1176         umask 7
1177         portlist="0 1 2 3 4 5 6 7 8 9 a b c d e f
1178                   g h i j k l m n o p q r s t u v"
1179         major=48
1180         card=`expr $i : 'cua.*\(.\)$'`
1181         for unit in $portlist
1182         do
1183                 minor=`ttyminor $unit`
1184                 minor=$(($card * 65536 + $minor))
1185                 name=$card$unit
1186                 mknod cuac$name c $major $(($minor + 128)) uucp:dialer
1187                 mknod cuaic$name c $major $(($minor + 32 + 128)) uucp:dialer
1188                 mknod cualc$name c $major $(($minor + 64 + 128)) uucp:dialer
1189         done
1190         umask 77
1191         ;;
1192
1193 ttyc?)
1194         portlist="0 1 2 3 4 5 6 7 8 9 a b c d e f
1195                   g h i j k l m n o p q r s t u v"
1196         major=48
1197         card=`expr $i : 'tty.*\(.\)$'`
1198         for unit in $portlist
1199         do
1200                 minor=`ttyminor $unit`
1201                 minor=$(($card * 65536 + $minor))
1202                 name=$card$unit
1203                 mknod ttyc$name c $major $minor
1204                 mknod ttyic$name c $major $(($minor + 32))
1205                 mknod ttylc$name c $major $(($minor + 64))
1206         done
1207         ;;
1208
1209 # RISCom8 'rc' driver entries
1210
1211 cuam?)
1212         umask 7
1213         unit=`expr $i : 'cua.*\(.\)$'`
1214         m=`ttyminor $unit`
1215         mknod cuam$unit c 63 $(($m + 128)) uucp:dialer
1216         umask 77
1217         ;;
1218
1219 ttym?)
1220         unit=`expr $i : 'tty.*\(.\)$'`
1221         m=`ttyminor $unit`
1222         mknod ttym$unit c 63 $m
1223         ;;
1224
1225 # Specialix SI/XIO.
1226 # Note: these are 'base 1' to match the numbers on the panels, and to match
1227 #       the manual that comes with the system.
1228 ttyA*)
1229         major=68
1230         units=`expr $i : 'ttyA\(.*\)$'`
1231         port=1
1232         while [ $port -le $units ]; do
1233                 minor=$(($port - 1))
1234                 name=$(zeropad 2 $port)
1235                 mknod ttyA$name c $major $minor
1236                 mknod ttyiA$name c $major $(($minor + 65536))
1237                 mknod ttylA$name c $major $(($minor + 131072))
1238                 port=$(($port + 1))
1239         done
1240         # For the user-mode control program, 'sicontrol'
1241         mknod si_control c 68 262144
1242         ;;
1243
1244 cuaA*)
1245         umask 7
1246         major=68
1247         units=`expr $i : 'cuaA\(.*\)$'`
1248         port=1
1249         while [ $port -le $units ]; do
1250                 minor=$(($port - 1))
1251                 name=$(zeropad 2 $port)
1252                 mknod cuaA$name c $major $(($minor + 128)) uucp:dialer
1253                 mknod cuaiA$name c $major $(($minor + 128 + 65536)) \
1254                     uucp:dialer
1255                 mknod cualA$name c $major $(($minor + 128 + 131072)) \
1256                     uucp:dialer
1257                 port=$(($port + 1))
1258         done
1259         umask 77
1260         ;;
1261
1262 # Alpha AS8[24]00 (TurboLaser) console.
1263 zs?)
1264         unit=`expr $i : 'zs.*\(.\)$'`
1265         m=`ttyminor $unit`
1266         mknod zs$unit c 135 $m
1267         ;;
1268
1269 # Digiboard PC/?? 16 port card.
1270 # The current scheme of minor numbering is:
1271 #
1272 #       unused{14} CARD{2} major{8} CALLOUT{1} LOCK{1} INIT{1} PORT{5}
1273 #
1274 #   CARD bitfield in future versions may be extended to 3 bits.
1275 #
1276 # See dgb(4)
1277 #
1278 ttyD?)
1279         portlist="0 1 2 3 4 5 6 7 8 9 a b c d e f"
1280         major=58
1281         card=`expr $i : 'tty.*\(.\)$'`
1282         for unit in $portlist
1283         do
1284                 minor=`ttyminor $unit`
1285                 minor=$(($card * 65536 + $minor))
1286                 name=$card$unit
1287                 mknod ttyD$name c $major $minor
1288                 mknod ttyiD$name c $major $(($minor + 32))
1289                 mknod ttylD$name c $major $(($minor + 64))
1290         done
1291
1292         # Also create devices for the digi driver
1293         umask 7
1294         major=162
1295         card=`expr $i : 'tty.*\(.\)$'`
1296         rm -f digi$card.ctl
1297         mknod digi$card.ctl c $major $(($card * 65536 + 8388608)) uucp:dialer
1298         unit=0
1299         while [ $unit -lt 16 ]
1300         do
1301                 base=$(($card * 65536 + $unit))
1302                 name=$card.$unit
1303                 rm -f tty*D$name
1304                 mknod ttyD$name c $major $base
1305                 mknod ttyiD$name c $major $(($base + 1048576))
1306                 mknod ttylD$name c $major $(($base + 2097152))
1307                 unit=$(($unit + 1))
1308         done
1309         umask 77
1310         ;;
1311
1312 cuaD?)
1313         umask 7
1314         portlist="0 1 2 3 4 5 6 7 8 9 a b c d e f"
1315         major=58
1316         card=`expr $i : 'cua.*\(.\)$'`
1317         for unit in $portlist
1318         do
1319                 minor=`ttyminor $unit`
1320                 minor=$(($card * 65536 + $minor))
1321                 name=$card$unit
1322                 mknod cuaD$name c $major $(($minor + 128)) uucp:dialer
1323                 mknod cuaiD$name c $major $(($minor + 32 + 128)) uucp:dialer
1324                 mknod cualD$name c $major $(($minor + 64 + 128)) uucp:dialer
1325         done
1326
1327         # Also create devices for the digi driver
1328         major=162
1329         card=`expr $i : 'cua.*\(.\)$'`
1330         rm -f digi$card.ctl
1331         mknod digi$card.ctl c $major $(($card * 65536 + 8388608)) uucp:dialer
1332         unit=0
1333         while [ $unit -lt 16 ]
1334         do
1335                 base=$(($card * 65536 + $unit))
1336                 name=$card.$unit
1337                 rm -f cua*D$name
1338                 mknod cuaD$name c $major $(($base + 4194304)) uucp:dialer
1339                 mknod cuaiD$name c $major $(($base + 5242880)) uucp:dialer
1340                 mknod cualD$name c $major $(($base + 6291456)) uucp:dialer
1341                 unit=$(($unit + 1))
1342         done
1343         umask 77
1344         ;;
1345
1346 # Digiboard Xem - superceeded by the digi device above
1347 #
1348 ttyM*)
1349         portlist="0 1 2 3 4 5 6 7 8 9 a b c d e f"
1350         modulelist="a b c d"
1351         major=101
1352         card=`expr $i : 'tty.*\(.\)$'`
1353         for unit in $modulelist
1354         do
1355                 moduleminor=`ttyminor $unit`
1356                 moduleminor=$(($moduleminor % 10 * 16))
1357                 modulename=$unit
1358
1359                 for unit in $portlist
1360                 do
1361                         minor=`ttyminor $unit`
1362                         minor=$(($card * 65536 + $minor + $moduleminor))
1363                         name=$card$modulename$unit
1364                         rm -f tty*M$name
1365                         mknod ttyM$name c $major $minor
1366                         mknod ttyiM$name c $major $(($minor + 64))
1367                         mknod ttylM$name c $major $(($minor + 128))
1368                 done
1369         done
1370         ;;
1371
1372 cuaM?)
1373         umask 7
1374         portlist="0 1 2 3 4 5 6 7 8 9 a b c d e f"
1375         modulelist="a b c d"
1376         major=101
1377         card=`expr $i : 'cua.*\(.\)$'`
1378         for unit in $modulelist
1379         do
1380                 moduleminor=`ttyminor $unit`
1381                 moduleminor=$(($moduleminor % 10 * 16))
1382                 modulename=$unit
1383
1384                 for unit in $portlist
1385                 do
1386                         minor=`ttyminor $unit`
1387                         minor=$(($card * 65536 + $minor + $moduleminor))
1388                         name=$card$modulename$unit
1389                         rm -f cua*M$name
1390                         mknod cuaM$name c $major $(($minor + 262144)) \
1391                             uucp:dialer
1392                         mknod cuaiM$name c $major $(($minor + 64 + 262144)) \
1393                             uucp:dialer
1394                         mknod cualM$name c $major $(($minor + 128 + 262144)) \
1395                             uucp:dialer
1396                 done
1397         done
1398         umask 77
1399         ;;
1400
1401 ttyR?)
1402         major=81
1403         BOARD=1; Rnum=0
1404         MINOR=$(($BOARD * 65536))
1405         controllers=$(
1406                 dmesg | while read first rest; do
1407                         case "$first" in
1408                         RocketPort[0-4])
1409                                 echo "$first"
1410                                 ;;
1411                         esac
1412                 done
1413         )
1414         rm -f ttyR* ttyiR* ttylR*
1415         for i in $controllers; do
1416            ndevices=$(
1417                 dmesg | while read first bar ports rest; do
1418                         case "$first" in
1419                         $i*)
1420                                 echo "$ports"
1421                                 ;;
1422                         esac
1423                 done
1424            )
1425            echo -n "Creating $ndevices devices for $i: "
1426            dev=0
1427            while [ $dev -lt $ndevices ]; do
1428                    mknod ttyR$Rnum c $major $MINOR
1429                    mknod ttyiR$Rnum c $major $(($MINOR + 32))
1430                    mknod ttylR$Rnum c $major $(($MINOR + 64))
1431                    Rnum=$(($Rnum + 1))
1432                    MINOR=$(($MINOR + 1))
1433                    dev=$(($dev + 1))
1434            done
1435                 BOARD=$(($BOARD + 1))
1436                 MINOR=$(($BOARD * 65536))
1437            echo " "
1438         done
1439         ;;
1440
1441 cuaR?)
1442         major=81
1443         BOARD=1; Rnum=0
1444         MINOR=$(($BOARD * 65536))
1445         controllers=$(
1446                 dmesg | while read first rest; do
1447                         case "$first" in
1448                         RocketPort[0-4])
1449                                 echo "$first"
1450                                 ;;
1451                         esac
1452                 done
1453         )
1454         rm -f cuaR* cuaiR* cualR*
1455         for i in $controllers; do
1456            ndevices=$(
1457                 dmesg | while read first bar ports rest; do
1458                         case "$first" in
1459                         $i*)
1460                                 echo "$ports"
1461                                 ;;
1462                         esac
1463                 done
1464            )
1465            echo -n "Creating $ndevices devices for $i: "
1466            dev=0
1467            while [ $dev -lt $ndevices ]; do
1468                    mknod cuaR$Rnum c  $major $(($MINOR + 128)) uucp:dialer
1469                    mknod cuaiR$Rnum c $major $(($MINOR + 128 + 32)) \
1470                        uucp:dialer
1471                    mknod cualR$Rnum c $major $(($MINOR + 128 + 64)) \
1472                        uucp:dialer
1473                    Rnum=$(($Rnum + 1))
1474                    MINOR=$(($MINOR + 1))
1475                    dev=$(($dev + 1))
1476            done
1477                 BOARD=$(($BOARD + 1))
1478                 MINOR=$(($BOARD * 65536))
1479            echo " "
1480         done
1481         ;;
1482
1483 mse*)
1484         unit=`expr $i : 'mse\(.*\)'`
1485         chr=27
1486         # non-blocking for X11
1487         mknod mse$unit c $chr `unit2minor $(($unit * 2 + 1))`
1488         ;;
1489
1490 psm*)
1491         unit=`expr $i : 'psm\(.*\)'`
1492         chr=21
1493         # non-blocking for X11
1494         mknod psm$unit c $chr `unit2minor $(($unit * 2 + 1))`
1495         ;;
1496
1497 mouse*)
1498         name=`expr $i : 'mouse\(.*\)'`
1499         if [ ! -c $name ]; then
1500                 $0 $name                        # make the appropriate device
1501         fi
1502         ln -fs $name mouse
1503         ;;
1504
1505 pcaudio)
1506         mknod pcaudio c 24 0
1507         mknod pcaudioctl c 24 128
1508         ;;
1509
1510 socksys)
1511         mknod socksys c 41 0
1512         mknod spx c 41 1
1513         ln -fs socksys nfsd
1514         chmod 666 socksys nfsd spx
1515         ;;
1516
1517 snd*)
1518 #
1519 # changes from Linux voxware
1520 # minor         Linux                   FreeBSD
1521 # 8             sequencer2 (aka music0) music0
1522 # 17            patmgr0                 sequencer1
1523 # 33            patmgr1                 sequencer2
1524 #
1525
1526         unit=`expr $i : 'snd\(.*\)'`
1527         chr=30
1528
1529         # XXX write this less verbosely, like std
1530         snd_security_hole=0     # XXX
1531         umask $snd_security_hole
1532
1533         ln -fs mixer$unit mixer
1534         ln -fs sequencer$unit sequencer
1535         ln -fs dsp$unit dsp
1536         ln -fs audio$unit audio
1537         ln -fs dspW$unit dspW
1538         ln -fs music$unit music
1539         ln -fs pss$unit pss
1540
1541         mknod mixer$unit        c $chr `unit2minor $(($unit * 16 + 0))`
1542         mknod sequencer$unit    c $chr `unit2minor $(($unit * 16 + 1))`
1543         mknod midi$unit         c $chr `unit2minor $(($unit * 16 + 2))`
1544         mknod dsp$unit          c $chr `unit2minor $(($unit * 16 + 3))`
1545         mknod audio$unit        c $chr `unit2minor $(($unit * 16 + 4))`
1546         mknod dspW$unit         c $chr `unit2minor $(($unit * 16 + 5))`
1547         mknod sndstat           c $chr 6
1548                                 # minor number 7 is unused
1549         mknod music$unit        c $chr `unit2minor $(($unit * 16 + 8))`
1550         mknod pss$unit          c $chr `unit2minor $(($unit * 16 + 9))`
1551                                 # minor number 10 is unused
1552         mknod midistat          c $chr 11
1553                                 # minor numbers 12-15 are unused
1554         umask 77
1555         ;;
1556
1557 vat)
1558         mknod vatio c 25 128
1559         chmod 660 vatio
1560         ;;
1561
1562 gsc*)
1563         unit=`expr $i : 'gsc\(.*\)'`
1564         mknod gsc${unit} c 47 `unit2minor $unit`
1565         mknod gsc${unit}p c 47 `unit2minor $(($unit + 8))`
1566         mknod gsc${unit}d c 47 `unit2minor $(($unit + 32))`
1567         mknod gsc${unit}pd c 47 `unit2minor $(($unit + 40))`
1568         chmod 666 gsc${unit}*
1569         ;;
1570
1571 acpi)
1572         mknod acpi c 152 0 root:operator
1573         chmod 660 acpi
1574         ;;
1575
1576 apm)
1577         mknod apm c 39 0 root:operator
1578         chmod 664 apm
1579         ;;
1580
1581 apmctl)
1582         mknod apmctl c 39 8 root:operator
1583         chmod 660 apmctl
1584         ;;
1585
1586 card*)
1587         unit=`expr $i : 'card\(.*\)'`
1588         chr=50
1589         mknod card$unit c $chr `unit2minor $unit`
1590         chmod 644 card$unit
1591         ;;
1592
1593 ttyx?|ttyy?|ttyz?)
1594         case $i in
1595         *0) unit=0;;    *1) unit=1;;    *2) unit=2;;    *3) unit=3;;
1596         *4) unit=4;;    *5) unit=5;;    *6) unit=6;;    *7) unit=7;;
1597         *8) unit=8;;    *9) unit=9;;    *a) unit=10;;   *b) unit=11;;
1598         *c) unit=12;;   *d) unit=13;;   *e) unit=14;;   *f) unit=15;;
1599         esac
1600         case $i in
1601         ttyy?)  unit=$(($unit \+ 16));;
1602         ttyz?)  unit=$(($unit \+ 32));;
1603         esac
1604         mknod $i c 42 $unit
1605         ;;
1606
1607 cronyx)
1608         mknod cronyx c 42 63
1609         ;;
1610
1611 joy)
1612         mknod joy0 c 51 0 root:operator
1613         mknod joy1 c 51 1 root:operator
1614         chmod 640  joy0 joy1
1615         ;;
1616
1617 spigot)
1618         mknod spigot c 11 0
1619         chmod 444 spigot
1620         ;;
1621
1622 ctx?)
1623         unit=`expr $i : 'ctx\(.*\)'`
1624         mknod ctx$unit c 40 `unit2minor $unit`
1625         chmod 444 ctx$unit
1626         ;;
1627
1628 meteor?)
1629         unit=`expr $i : 'meteor\(.*\)'`
1630         mknod meteor$unit c 67 `unit2minor $unit`
1631         chmod 444 meteor$unit
1632         ;;
1633
1634 bktr?)
1635         unit=`expr $i : 'bktr\(.*\)'`
1636         mknod bktr$unit c 92 `unit2minor $unit`
1637         mknod tuner$unit c 92 `unit2minor $((16 + $unit))`
1638         mknod vbi$unit c 92 `unit2minor $((32 + $unit))`
1639         chmod 444 bktr$unit tuner$unit vbi$unit
1640         ;;
1641
1642 tun*)
1643         units=`expr $i : 'tun\(.*\)$'`
1644         unit=0
1645         while [ $unit -le $units ]; do
1646                 mknod tun$unit c 52 `unit2minor $unit`
1647                 unit=$(($unit + 1))
1648         done
1649         ;;
1650
1651 tap*)
1652         units=`expr $i : 'tap\(.*\)$'`
1653         unit=0
1654         while [ $unit -le $units ]; do
1655                 mknod tap$unit c 149 `unit2minor $unit` root:network
1656                 unit=$(($unit + 1))
1657         done
1658         ;;
1659
1660 sysmouse)
1661         mknod sysmouse c 12 128
1662         mknod consolectl c 12 255
1663         ;;
1664
1665 jogdial)
1666         mknod jogdial c 160 0
1667         ;;
1668
1669 snp?)
1670         unit=`expr $i : 'snp\(.*\)'`
1671         mknod snp$unit c 53 `unit2minor $unit`
1672         ;;
1673
1674 # dufault@hda.com: If I do much more work on other A-D boards
1675 # then eventually we'll have a "ad" and "dio" interface and some of these
1676 # "labpcaio" ones will be gone.
1677 # labpcaio: D-A and A-D.
1678 # labpcdio: Digital in and Digital out.
1679 #
1680 labpc*)
1681         umask 7
1682         case $i in
1683         labpcaio*)
1684                 name=labpcaio
1685                 unit=`expr $i : 'labpcaio\(.*\)'`
1686                 all="0 1 2 3 4 5 6 7"
1687                 offset=0
1688                 ;;
1689         labpcdio*)
1690                 name=labpcdio
1691                 unit=`expr $i : 'labpcdio\(.*\)'`
1692                 all="0 1 2 3"
1693                 offset=8
1694                 ;;
1695         *)
1696                 die 3 "Don't know LabPC type $i"
1697                 ;;
1698         esac
1699         if [ -z "${unit}" ]; then
1700                 unit=all
1701         fi
1702         case $unit in
1703                 0|1|2|3|4|5|6|7)
1704                                 mknod $name$unit c 66 $(($offset + $unit))
1705                 ;;
1706                 all)
1707                         for i in $all
1708                         do
1709                                 mknod $name$i c 66 $(($offset + $i))
1710                         done
1711                         ;;
1712                 *)
1713                         echo "No such LabPC unit: $unit"
1714                         ;;
1715         esac
1716         umask 77
1717         ;;
1718
1719 perfmon)
1720         mknod perfmon c 2 32 root:kmem
1721         chmod 640 perfmon
1722         ;;
1723
1724 ipl)
1725         mknod ipl c 79 0
1726         mknod ipnat c 79 1
1727         mknod ipstate c 79 2
1728         mknod ipauth c 79 3
1729         ;;
1730
1731 kbd*)
1732         unit=`expr $i : 'kbd\(.*\)'`
1733         chr=112
1734         mknod kbd$unit c $chr `unit2minor $unit`
1735         ;;
1736
1737 i4b)
1738         mknod i4b c 60 0
1739         ;;
1740
1741 i4bctl)
1742         mknod i4bctl c 55 0
1743         ;;
1744
1745 i4brbch*)
1746         unit=`expr $i : 'i4brbch\(.*\)'`
1747         mknod i4brbch$unit c 57 `unit2minor $unit`
1748         ;;
1749
1750 i4bteld*)
1751         offset=64
1752         unit=`expr $i : 'i4bteld\(.*\)'`
1753         mknod i4bteld$unit c 56 `unit2minor $(($offset + $unit))`
1754         ;;
1755
1756 i4btel*)
1757         unit=`expr $i : 'i4btel\(.*\)'`
1758         mknod i4btel$unit c 56 `unit2minor $unit`
1759         ;;
1760
1761 i4btrc*)
1762         unit=`expr $i : 'i4btrc\(.*\)'`
1763         mknod i4btrc$unit c 59 `unit2minor $unit`
1764         ;;
1765
1766 aac*)
1767         unit=`expr $i : 'aac\(.*\)'`
1768         mknod aac$unit c 150 `unit2minor $unit`
1769         ln -fs aac$unit afa$unit
1770         ln -fs aac$unit hpn$unit
1771         ;;
1772
1773 mlx*)
1774         unit=`expr $i : 'mlx\(.*\)'`
1775         mknod mlx$unit c 130 `unit2minor $unit`
1776         ;;
1777
1778 mly*)
1779         unit=`expr $i : 'mlx\(.*\)'`
1780         mknod mlx$unit c 158 `unit2minor $unit`
1781         ;;
1782
1783 amr*)
1784         unit=`expr $i : 'amr\(.*\)'`
1785         mknod amr$unit c 132 `unit2minor $unit`
1786         ;;
1787
1788 ciss*)
1789         unit=`expr $i : 'ciss\(.*\)'`
1790         mknod ciss$unit c 166 `unit2minor $unit`
1791         ;;
1792
1793 3dfx*)
1794         unit=`expr $i : '3dfx\(.*\)'`
1795         mknod 3dfx$unit c 107 `unit2minor $unit`
1796         ln -sf 3dfx$unit 3dfx
1797    ln -sf 3dfx$unit voodoo
1798         ;;
1799
1800 agpgart)
1801         mknod agpgart c 148 0
1802         ;;
1803
1804 twe*)
1805         unit=`expr $i : 'twe\(.*\)'`
1806         mknod twe$unit c 146 `unit2minor $unit`
1807         ;;
1808
1809 tw*)
1810         unit=`expr $i : 'tw\(.*\)'`
1811         mknod tw$unit c 19 `unit2minor $unit` root:operator
1812         ;;
1813
1814 cfs*)
1815         unit=`expr $i : 'cfs\(.*\)'`
1816         mknod cfs$unit c 93 $unit root:operator
1817         ;;
1818
1819 nsmb*)
1820         unit=`expr $i : 'nsmb\(.*\)'`
1821         mknod nsmb$unit c 144 $unit
1822         ;;
1823
1824 local)
1825         umask 0                 # XXX should be elsewhere
1826         sh $0.local
1827         umask 77
1828         ;;
1829
1830 *)
1831         echo $i - no such device name
1832         ;;
1833
1834 esac
1835 done