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