]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - etc/MAKEDEV
This commit was generated by cvs2svn to compensate for changes in r100513,
[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 #       ucom*   USB serial devices
107 #
108 # SCSI devices (other than CD-ROM, tape and disk):
109 #       ch*     SCSI Media-Changer (juke box) driver
110 #       pt*     Processor Type (HP scanner, as one example)
111 #       pass*   CAM Passthrough device
112 #       ses*    SES (SCSI Environmental Services) and
113 #               SAF-TE (Scsi Accessable Fault-Tolerant Enclosures) device
114 #
115 # PC-CARD (previously called PCMCIA) support
116 #       card*   PC-CARD slots
117 #
118 # ISDN devices:
119 #       i4b     isdnd call control device
120 #       i4bctl  debugging control device
121 #       i4btrc* trace data interface(s), one per passive card
122 #       i4btel* telephony interface(s)
123 #       i4bteld* telephony dialout interface(s)
124 #       i4brbch* raw b channel access device(s)
125 #
126 # Special purpose devices:
127 #       acpi    Advanced Configuration and Power Interface
128 #       apm     Advanced Power Management BIOS
129 #       apmctl  APM BIOS control device
130 #       bpf*    packet filter
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 #
156
157 if [ -n "$MAKEDEVPATH" ]; then
158         PATH="$MAKEDEVPATH"
159 else
160         PATH=/sbin:/bin
161 fi
162 umask 77
163
164 # Usage: die exitcode msg
165 die() {
166         echo $2
167         exit $1
168 }
169
170 # Convert integer to partition name
171 dkitop() {
172         local p
173
174         case $1 in
175         0) p=a;; 1) p=b;; 2) p=c;; 3) p=d;; 4) p=e;; 5) p=f;; 6) p=g;; 7) p=h;;
176         *) p="?";;
177         esac
178         echo $p
179 }
180
181 # Convert integer to slice name
182 dkitos() {
183         local s
184
185         case $1 in
186         0) s="";;
187         1) s="";;
188         *) s=s$(($1-1));;
189         esac
190         echo $s
191 }
192
193 # Convert disk (type, unit, slice, partition) to minor number
194 dkminor()
195 {
196         echo $(($1 << 25 | ($2 / 32) << 21 | ($2 % 32) << 3 | $3 << 16 | $4))
197 }
198
199 # Print the hexadecimal representation of a decimal value from 0 to 15.
200 hexdigit() {
201         local d
202
203         if [ $1 -lt 10 ]; then
204                 d=$1
205         else
206                 case $1 in
207                 10) d=a;; 11) d=b;; 12) d=c;; 13) d=d;; 14) d=e;; 15) d=f;;
208                 *) d="?";;
209                 esac
210         fi
211         echo $d
212 }
213
214 # Print the hexadecimal representation of an arbitrary decimal value.
215 hexprint() {
216         local dig
217         local str
218         local val
219
220         val=$1
221         str=''
222         dig=`hexdigit $(($val & 15))`
223         str=$dig$str
224         val=$(($val >> 4))
225         while [ $val -gt 0 ]; do
226                 dig=`hexdigit $(($val & 15))`
227                 str=$dig$str
228                 val=$(($val >> 4))
229         done
230         echo $str
231 }
232
233 # Override mknod(2) to add extra handling to it.
234 mknod=/sbin/mknod
235 for i in `IFS=':'; echo $PATH`; do
236         if [ -x "${i}/mknod" ]; then
237                 mknod="${i}/mknod"
238                 break
239         fi
240 done
241 mknod() {
242         rm -f "$1" || exit 1
243         case $# in
244         4) "$mknod" "$@" root:wheel || die 2 "$mknod $@ failed";;
245         5) "$mknod" "$@"            || die 2 "$mknod $@ failed";;
246         *) die 2 "bad node: mknod $@";;
247         esac
248 }
249
250 # Convert tape (ctrl, unit, mode, access) to minor number
251 saminor()
252 {
253         echo $(($1 << 29 | ($2 / 16) << 16 | ($2 % 16) << 4 | $3 << 2 | $4))
254 }
255
256 # Convert the last character of a tty name to a minor number.
257 ttyminor()
258 {
259         case $1 in
260         [0-9]) m=$1;;
261         a) m=10;; b) m=11;; c) m=12;; d) m=13;; e) m=14;; f) m=15;; g) m=16;;
262         h) m=17;; i) m=18;; j) m=19;; k) m=20;; l) m=21;; m) m=22;; n) m=23;;
263         o) m=24;; p) m=25;; q) m=26;; r) m=27;; s) m=28;; t) m=29;; u) m=30;;
264         v) m=31;;
265         *) m="?";;
266         esac
267         echo $m
268 }
269
270 # Convert a unit number to a minor number.
271 unit2minor()
272 {
273         echo $(((($1 >> 8) << 16) | ($1 % 256)))
274 }
275
276 # Zero-pad a value to the appropriate minimum length.
277 zeropad() {
278         local min
279         local val
280
281         min=$1
282         val=$2
283         while [ ${#val} -lt $min ]; do
284                 val=0$val
285         done
286         echo $val
287 }
288
289 # Raw partition for disks
290 dkrawpart=2
291
292 # Compatibility slice for disks
293 dkcompatslice=0
294
295 # Raw slice for disks
296 dkrawslice=1
297
298 # Standard umasks
299 disk_umask=037                  # allow group operator to read disks
300 tape_umask=017                  # allow group operator to read/write tapes
301
302 for i in $*; do
303 case $i in
304
305 all)
306         sh $0 std                                       # standard
307         sh $0 fd0 fd1                                   # floppy disk
308         sh $0 da0 da1 da2 da3                           # SCSI disk
309         sh $0 ata                                       # ATA control
310         sh $0 ad0 ad1 ad2 ad3                           # ATA disk
311         sh $0 ar0 ar1                                   # ATA RAID disk
312         sh $0 acd0 acd0t0 afd0 ast0                     # ATAPI devices
313         sh $0 wd0 wd1 wd2 wd3                           # OLD disk
314         sh $0 wcd0 wfd0 wst0                            # OLD ATAPI devs
315         sh $0 cd0 matcd0 mcd0 scd0                      # cdrom
316         sh $0 sa0 wt0                                   # tape
317         sh $0 vty12                                     # virtual tty
318         sh $0 cuaa0 cuaa1 cuaa2 cuaa3                   # serial tty
319         sh $0 pty0                                      # pseudo tty
320         sh $0 ttyd0 ttyd1 ttyd2 ttyd3                   # serial tty
321         sh $0 kbd0 kbd1                                 # keyboard
322         sh $0 mse0 psm0 jogdial sysmouse                # mouse
323         sh $0 pcaudio speaker                           # noise
324         sh $0 lpt0 lpt1 lpt2                            # printer
325         sh $0 ppi0 ppi1 ppi2                            # parallel port
326         sh $0 iic0 iic1                                 # I2C device
327         sh $0 smb0 smb1                                 # SMBus device
328         sh $0 usb usb0 uhid0 ums0 ulpt0 ugen0           # USB devices
329         sh $0 urio0 uscanner0 umodem0                   # USB devices too
330         sh $0 bpf0 bpf1 bpf2 bpf3                       # network
331         sh $0 ipl tun0 tun1 tun2 tun3                   # network
332         sh $0 tap0 tap1 tap2 tap3                       # network
333         sh $0 ch0 perfmon tw0                           # miscellaneous
334         sh $0 acpi                                      # ACPI
335         sh $0 apm apmctl card0 card1 card2 card3        # laptop
336         sh $0 pass4 xpt2                                # CAM
337         sh $0 i4b i4bctl i4btrc0 i4btrc1                # ISDN
338         sh $0 i4btel0 i4btel1 i4bteld0 i4bteld1         # ISDN
339         sh $0 i4brbch0 i4brbch1                         # ISDN
340         sh $0 agpgart                                   # AGP
341         sh $0 nsmb0                                     # SMB/CIFS
342         sh $0 ti0 ti1                                   # ti(4)
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                 # Fake BSD partitions
534                 for i in a b c d e f g h
535                 do
536                         ln -f ${name}${unit} ${name}${unit}$i
537                 done
538                 ;;
539         *)
540                 echo bad unit for disk in: $i
541                 ;;
542         esac
543         umask 77
544         ;;
545
546 ata)
547         umask 177
548         mknod ata c 159 0 root:operator
549         umask 77
550         ;;
551         
552
553 aacd*|ad*|ar*|afd*|amrd*|da*|fla*|idad*|md*|mlxd*|twed*|wd*|wfd*)
554         umask $disk_umask
555         case $i in
556         aacd*) name=aacd; chr=151;;
557         ad*) name=ad; chr=116;;
558         ar*) name=ar; chr=157;;
559         afd*) name=afd; chr=118;;
560         amrd*) name=amrd; chr=133;;
561         da*) name=da;  chr=13;;
562         fla*) name=fla; chr=102;;
563         idad*) name=idad; chr=109;;
564         md*) name=md; chr=95;;
565         mlxd*) name=mlxd; chr=131;;
566         twed*) name=twed; chr=147;;
567         wd*) name=wd;  chr=3;;
568         wfd*) name=wfd; chr=87;;
569         esac
570         case $i in
571         aacd*|amrd*|idad*|mlxd*|twed*)
572                 unit=`expr $i : '....\(.*\)'`
573                 ;;
574         afd*|fla*|wfd*)
575                 unit=`expr $i : '...\(.*\)'`
576                 ;;
577         *)
578                 unit=`expr $i : '..\(.*\)'`
579                 ;;
580         esac
581         case $unit in
582         [0-9]|[0-9][0-9]|[0-4][0-9][0-9]|50[0-9]|51[0-1])
583                 for slicepartname in s0h s1h s2 s3 s4
584                 do
585                         sh $0 $name$unit$slicepartname
586                 done
587                 ;;
588         *)
589                 echo bad unit for disk in: $i
590                 ;;
591         esac
592         umask 77
593         ;;
594
595 ccd*)
596         umask $disk_umask
597         name=ccd
598         chr=74
599         unit=`expr $i : '...\(.*\)'`
600         case $unit in
601         [0-9]|[0-9][0-9]|[0-4][0-9][0-9]|50[0-9]|51[0-1])
602                 for part in 0 1 2 3 4 5 6 7
603                 do
604                         minor=`dkminor 0 $unit 0 $part`
605                         partname=`dkitop $part`
606                         mknod  $name$unit$partname c $chr $minor root:operator
607                         ln -f $name$unit$partname r$name$unit$partname
608                 done
609                 ;;
610         *)
611                 echo bad unit for disk in: $i
612                 ;;
613         esac
614         umask 77
615         ;;
616
617 # SCSI processor type driver
618 pt[0-9]*)
619         chr=61
620         name=pt
621         unit=`expr $i : 'pt\([0-9][0-9]*\)'`
622         if [ -z "${unit}" ]; then
623                 unit=0
624         fi
625         unit=$(($unit + 1 - 1))
626         mknod ${name}${unit} c $chr `unit2minor $unit`
627         ;;
628
629 # SCSI SES/SAF-TE type driver
630 ses[0-9]*)
631         chr=110
632         name=ses
633         unit=`expr $i : 'ses\([0-9][0-9]*\)'`
634         if [ -z "${unit}" ]; then
635                 unit=0
636         fi
637         unit=$(($unit + 1 - 1))
638         mknod ${name}${unit} c $chr `unit2minor $unit`
639         ;;
640 # SCSI target mode sample driver
641 targ[0-9]*)
642         chr=65
643         name=targ
644         unit=`expr $i : 'targ\([0-9][0-9]*\)'`
645         if [ -z "${unit}" ]; then
646                 unit=0
647         fi
648         unit=$(($unit + 1 - 1))
649         mknod ${name}${unit} c $chr `unit2minor $unit`
650         mknod ${name}.ctl c $chr 0xffff00ff
651         ;;
652
653 # CAM transport layer device
654 xpt*)
655         # This major number is temporary
656         chr=104
657         name=xpt
658         units=`expr $i : 'xpt\(.*\)'`
659         if [ -z "${units}" ]; then
660                 units=1
661         fi
662         i=0
663         while [ $i -lt $units ]; do
664                 dname=$name$i
665                 rm -rf $dname r$dname
666                 mknod $dname c $chr `unit2minor $i` root:operator
667                 i=$(($i + 1))
668         done    
669         ;;
670
671 # CAM passthrough device
672 pass*)
673         # This major number is temporary
674         chr=31
675         name=pass
676         units=`expr $i : 'pass\(.*\)'`
677         if [ -z "${units}" ]; then
678                 units=1
679         fi
680         i=0
681         while [ $i -lt $units ]; do
682                 dname=$name$i
683                 rm -rf $dname r$dname
684                 mknod $dname c $chr `unit2minor $i` root:operator
685                 i=$(($i + 1))
686         done    
687         ;;
688 pty*)
689         class=`expr $i : 'pty\(.*\)'`
690         case $class in
691         0) offset=0 name=p;;
692         1) offset=32 name=q;;
693         2) offset=64 name=r;;
694         3) offset=96 name=s;;
695 # Note that xterm (at least) only look at p-s.
696         4) offset=128 name=P;;
697         5) offset=160 name=Q;;
698         6) offset=192 name=R;;
699         7) offset=224 name=S;;
700         # This still leaves [tuTU].
701         *) echo bad unit for pty in: $i;;
702         esac
703         umask 0
704         case $class in
705         0|1|2|3|4|5|6|7)
706                 i=0
707                 while [ $i -lt 32 ]; do
708 #                       This was an awk substr() before.
709                         c=$(echo 0123456789abcdefghijklmnopqrstuv |
710                             dd bs=1 skip=$i count=1 2>/dev/null)
711                         mknod tty$name$c c 5 $(($offset + $i))
712                         mknod pty$name$c c 6 $(($offset + $i))
713                         i=$(($i + 1))
714                 done
715                 ;;
716         esac
717         umask 77
718         ;;
719
720 sa*)
721         umask $tape_umask
722         unit=`expr $i : '..\(.*\)'`
723         chr=14
724
725         case $unit in
726         [0-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9])
727                 mknod sa${unit}.ctl c $chr `saminor 1 ${unit} 0 0`
728                 ln -f sa${unit}.ctl rsa${unit}.ctl
729                 for m in 0 1 2 3
730                 do
731                         mknod sa${unit}.${m} c $chr \
732                             `saminor 0 ${unit} ${m} 0`  root:operator
733                         ln -f sa${unit}.${m} rsa${unit}.${m}
734                         mknod nsa${unit}.${m} c $chr \
735                             `saminor 0 ${unit} ${m} 1` root:operator
736                         ln -f nsa${unit}.${m} nrsa${unit}.${m}
737                         mknod esa${unit}.${m} c $chr \
738                             `saminor 0 ${unit} ${m} 2` root:operator
739                         ln -f esa${unit}.${m} ersa${unit}.${m}
740                 done
741                 ln -f sa${unit}.0 sa${unit}
742                 ln -f sa${unit}.0 rsa${unit}.0
743                 ln -f sa${unit}.0 rsa${unit}
744                 ln -f nsa${unit}.0 nsa${unit}
745                 ln -f nsa${unit}.0 nrsa${unit}.0
746                 ln -f nsa${unit}.0 nrsa${unit}
747                 ln -f esa${unit}.0 esa${unit}
748                 ln -f esa${unit}.0 ersa${unit}.0
749                 ln -f esa${unit}.0 ersa${unit}
750                 ;;
751         *)
752                 echo bad unit for tape in: $i
753                 ;;
754         esac
755         umask 77
756         ;;
757
758 ch*)
759         umask 37
760         unit=`expr $i : '..\(.*\)'`
761         case $i in
762         ch*) name=ch;  chr=17;;
763         esac
764         case $unit in
765         0|1|2|3|4|5|6)
766                 mknod ${name}${unit}    c $chr $unit root:operator
767                 ;;
768         *)
769                 echo bad unit for media changer in: $i
770                 ;;
771         esac
772         umask 77
773         ;;
774
775 ast*)
776         umask 2 ;
777         unit=`expr $i : '...\(.*\)'`
778         chr=119
779         case $unit in
780         0|1|2|3)
781                 mknod ast${unit} c $chr $(($unit * 8 + 0)) root:operator
782                 chmod 640 ast${unit}
783                 mknod nast${unit} c $chr $(($unit * 8 + 1)) root:operator
784                 chmod 640 nast${unit}
785                 ;;
786         *)
787                 echo bad unit for tape in: $i
788                 ;;
789         esac
790         umask 77
791         ;;
792
793 acd*t*)
794         umask $disk_umask
795         units=`expr $i : '...\(.*\)t'`;
796         tracks=`expr $i : '.*t\(.*\)'`;
797         name=acd;
798         chr=117;
799         if [ -z "${units}" -o "${units}" -le 0 ]; then
800                 units=1
801         fi
802         if [ -z "${tracks}" -o "${tracks}" -le 0 ]; then
803                 tracks=100
804         fi
805         if [ "${units}" -le 31 -a "${tracks}" -le 169 ]; then
806                 i=0
807                 while [ $i -le $units ]; do
808                         dname=$name$i
809                         rm -rf ${dname}t*
810                         j=1
811                         while [ $j -le ${tracks} ]; do
812                                 mknod ${dname}t$j c $chr \
813                                         $((($i * 8) + (65536 * $j))) \
814                                         root:operator
815                                 j=$(($j + 1))
816                         done
817                         i=$(($i + 1))
818                 done
819         else
820                 echo "$i is invalid -- can't have more than 32 cd devices or 169 tracks"
821         fi
822         umask 77
823         ;;
824
825 acd*|cd*|mcd*|scd*)
826         umask $disk_umask
827         case $i in
828         acd*) units=`expr $i : '...\(.*\)'`; name=acd; chr=117;;
829         cd*) units=`expr $i : '..\(.*\)'`; name=cd; chr=15;;
830         mcd*) units=`expr $i : '...\(.*\)'`; name=mcd; chr=29;;
831         scd*) units=`expr $i : '...\(.*\)'`; name=scd; chr=45;;
832         esac
833         if [ -z "${units}" -o "${units}" -le 0 ]; then
834                 units=1
835         fi
836         if [ "${units}" -le 31 ]; then
837                 i=0
838                 while [ $i -le $units ]; do
839                         dname=$name$i
840                         rm -rf ${dname}[!t]* r${dname}*
841                         mknod ${dname}a c $chr $(($i * 8)) root:operator
842                         mknod ${dname}c c $chr $(($i * 8 + 2)) root:operator
843                         ln -f ${dname}a r${dname}a
844                         ln -f ${dname}c r${dname}c
845                         i=$(($i + 1))
846                 done
847         else
848                 echo "$i is invalid -- can't have more than 32 cd devices"
849         fi
850         umask 77
851         ;;
852
853 matcd*)
854         umask 2
855         case $i in
856         matcd*) unit=`expr $i : '.....\(.*\)'`; name=matcd; chr=46;;
857         esac
858         case $unit in
859         0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15)
860                 mknod ${name}${unit}a   c $chr $(($unit * 8 + 0)) \
861                     root:operator
862                 mknod ${name}${unit}c   c $chr $(($unit * 8 + 2)) \
863                     root:operator
864                 ln -f ${name}${unit}a r${name}${unit}a
865                 ln -f ${name}${unit}c r${name}${unit}c
866                 chmod 640 ${name}${unit}[a-h] r${name}${unit}[a-h]
867
868                 mknod ${name}${unit}la  c $chr $(($unit * 8 + 128)) \
869                     root:operator
870                 mknod ${name}${unit}lc  c $chr $(($unit * 8 + 130)) \
871                     root:operator
872                 ln -f ${name}${unit}la r${name}${unit}la
873                 ln -f ${name}${unit}lc r${name}${unit}lc
874                 chmod 640 ${name}${unit}l[a-h] r${name}${unit}l[a-h]
875                 ;;
876         *)
877                 echo bad unit for disk in: $i
878                 ;;
879         esac
880         umask 77
881         ;;
882
883 wcd*)
884         umask 2 ;
885         unit=`expr $i : '...\(.*\)'`
886         chr=69
887         case $unit in
888         0|1|2|3|4|5|6|7)
889                 mknod wcd${unit}a  c $chr $(($unit * 8 + 0)) root:operator
890                 mknod wcd${unit}c  c $chr $(($unit * 8 + 2)) root:operator
891                 ln -f wcd${unit}a rwcd${unit}a
892                 ln -f wcd${unit}c rwcd${unit}c
893                 chmod 640 wcd${unit}[a-h] rwcd${unit}[a-h]
894                 ;;
895         *)
896                 echo bad unit for disk in: $i
897                 ;;
898         esac
899         umask 77
900         ;;
901
902 wst*)
903         umask 2 ;
904         unit=`expr $i : '...\(.*\)'`
905         chr=90
906         case $unit in
907         0|1|2|3)
908                 mknod rwst${unit} c $chr $(($unit * 8 + 0)) root:operator
909                 chmod 640 rwst${unit}
910                 ;;
911         esac
912         umask 77
913         ;;
914
915 iic*)
916         unit=`expr $i : 'iic\(.*\)'`
917         mknod iic$unit c 105 `unit2minor $unit`
918         ;;
919
920 smb*)
921         unit=`expr $i : 'smb\(.*\)'`
922         mknod smb$unit c 106 `unit2minor $unit`
923         ;;
924
925 pcfclock*)
926         unit=`expr $i : 'pcfclock\(.*\)'`
927         mknod pcfclock$unit c 140 `unit2minor $unit`
928         ;;
929
930 ppi*)
931         unit=`expr $i : 'ppi\(.*\)'`
932         mknod ppi$unit c 82 `unit2minor $unit`
933         ;;
934
935 pps*)
936         unit=`expr $i : 'pps\(.*\)'`
937         mknod pps$unit c 89 `unit2minor $unit`
938         ;;
939
940 usb)
941         mknod usb$unit c 108 255 root:operator
942         chmod 0660 usb$unit
943         ;;
944
945 usb*)
946         umask 7
947         unit=`expr $i : 'usb\(.*\)'`
948         mknod usb$unit c 108 `unit2minor $unit` root:operator
949         umask 77
950         ;;
951
952 uhid*)
953         umask 7
954         unit=`expr $i : 'uhid\(.*\)'`
955         mknod uhid$unit c 122 `unit2minor $unit` root:operator
956         umask 77
957         ;;
958
959 ums*)
960         umask 7
961         unit=`expr $i : 'ums\(.*\)'`
962         mknod ums$unit c 111 `unit2minor $unit` root:operator
963         umask 77
964         ;;
965
966 ulpt*)
967         unit=`expr $i : 'ulpt\(.*\)'`
968         minor=`unit2minor $unit`
969         mknod ulpt$unit c 113 $minor
970         minor=`unit2minor $(($unit + 64))`
971         mknod unlpt$unit c 113 $minor           # and the 'no prime' version
972         ;;
973
974 ugen*)
975         umask 7
976         unit=`expr $i : 'ugen\([0-9][0-9]*\)'`
977         endpoint=`expr $i : 'ugen.*\.\([0-9][0-9]*\)'`
978         if [ -z "${unit}" ]; then
979                 echo $i - Invalid unit number
980         fi
981         if [ -z "${endpoint}" ]; then           # ugen0 & ugen0.1 - ugen0.15
982                 mknod ugen$unit c 114 \
983                                 `unit2minor $(($unit * 16))` root:operator
984                 i=1
985                 while [ $i -lt 16 ]; do
986                         mknod ugen$unit.$i c 114 \
987                                 `unit2minor $(($unit * 16 + $i))` root:operator
988                         i=$(($i + 1))
989                 done
990         else
991                 minor=`unit2minor $(($unit * 16 + $endpoint))`
992                 mknod ugen$unit.$endpoint c 114 $minor root:operator
993         fi
994         umask 77
995         ;;
996
997 urio*)
998         umask 7
999         unit=`expr $i : 'urio\(.*\)'`
1000         mknod urio$unit c 143 `unit2minor $unit` root:operator
1001         umask 77
1002         ;;
1003
1004 ucom*)
1005         umask 7
1006         unit=`expr $i : 'ucom\(.*\)'`
1007         minor=`unit2minor $(($unit + 128))`
1008         mknod ucom$unit c 138 $minor uucp:dialer
1009         umask 77
1010         ;;
1011
1012 uscanner*)
1013         umask 7
1014         unit=`expr $i : 'uscanner\(.*\)'`
1015         mknod uscanner$unit c 156 `unit2minor $unit` root:operator
1016         umask 77
1017         ;;
1018
1019 umodem*)
1020         umask 7
1021         unit=`expr $i : 'umodem\(.*\)'`
1022         mknod umodem$unit c 124 `unit2minor $unit` uucp:dialer
1023         umask 77
1024         ;;
1025
1026 lpt*)
1027         unit=`expr $i : 'lpt\(.*\)'`
1028         mknod lpt$unit c 16 `unit2minor $unit`
1029         mknod lpctl$unit c 16 `unit2minor $(($unit + 128))`
1030         ;;
1031
1032 # Use this to create virtual consoles for syscons, pcvt or codrv
1033 # ttyv0-b
1034 # use as MAKEDEV vtyNN to create NN entries
1035 vty*)
1036         chr=12
1037         units=`expr $i : 'vty\(.*\)'`
1038         i=0
1039         while [ $i -lt $units ]; do
1040                 mknod ttyv$(hexprint $i) c $chr `unit2minor $i`
1041                 i=$(($i + 1))
1042         done
1043         ln -fs ttyv0 vga        # XXX X still needs this pccons relic
1044         ;;
1045
1046 nmdm*)
1047         units=`expr $i : 'nmdm\(.*\)'`
1048         chr=18
1049         i=0
1050         while [ $i -lt $units ]; do
1051                 minor=`unit2minor $i`
1052                 minor=$(($minor + $minor))
1053                 mknod nmdm${i}A c $chr $minor
1054                 mknod nmdm${i}B c $chr $(($minor + 1))
1055                 i=$(($i + 1))
1056         done
1057         ;;
1058
1059 bpf*)
1060         units=`expr $i : 'bpf\(.*\)$'`
1061         unit=0
1062         while [ $unit -le $units ]; do
1063                 mknod bpf$unit c 23 `unit2minor $unit`
1064                 unit=$(($unit + 1))
1065         done
1066         ;;
1067
1068 speaker)
1069         mknod speaker c 26 0
1070         ;;
1071
1072 cua?|cuaa?|cuaa??)
1073         umask 7
1074         unit_low=`expr $i : 'cua.*\(.\)$'`
1075         case $i in
1076         cua?|cuaa?)
1077                 unit_high=""
1078                 m_high=0
1079                 ;;
1080         cuaa??)
1081                 unit_high=`expr $i : 'cuaa\(.\).$'`
1082                 m_high=`ttyminor $unit_high`
1083                 ;;
1084         esac
1085         unit=$unit_high$unit_low
1086         m=$(($m_high << 16 | `ttyminor $unit_low`))
1087         mknod cuaa$unit c 28 $(($m | 128)) uucp:dialer
1088         mknod cuaia$unit c 28 $(($m | 32 | 128)) uucp:dialer
1089         mknod cuala$unit c 28 $(($m | 64 | 128)) uucp:dialer
1090         umask 77
1091         ;;
1092
1093 tty?|tty0?|ttyd?|ttyd??)
1094         unit_low=`expr $i : 'tty.*\(.\)$'`
1095         case $i in
1096         tty?|tty0?|ttyd?)
1097                 unit_high=""
1098                 m_high=0
1099                 ;;
1100         ttyd??)
1101                 unit_high=`expr $i : 'ttyd\(.\).$'`
1102                 m_high=`ttyminor $unit_high`
1103                 ;;
1104         esac
1105         unit=$unit_high$unit_low
1106         m=$(($m_high << 16 | `ttyminor $unit_low`))
1107         mknod ttyd$unit c 28 $m
1108         mknod ttyid$unit c 28 $(($m | 32))
1109         mknod ttyld$unit c 28 $(($m | 64))
1110         ;;
1111
1112 cuac?)
1113         umask 7
1114         portlist="0 1 2 3 4 5 6 7 8 9 a b c d e f
1115                   g h i j k l m n o p q r s t u v"
1116         major=48
1117         card=`expr $i : 'cua.*\(.\)$'`
1118         for unit in $portlist
1119         do
1120                 minor=`ttyminor $unit`
1121                 minor=$(($card * 65536 + $minor))
1122                 name=$card$unit
1123                 mknod cuac$name c $major $(($minor + 128)) uucp:dialer
1124                 mknod cuaic$name c $major $(($minor + 32 + 128)) uucp:dialer
1125                 mknod cualc$name c $major $(($minor + 64 + 128)) uucp:dialer
1126         done
1127         umask 77
1128         ;;
1129
1130 ttyc?)
1131         portlist="0 1 2 3 4 5 6 7 8 9 a b c d e f
1132                   g h i j k l m n o p q r s t u v"
1133         major=48
1134         card=`expr $i : 'tty.*\(.\)$'`
1135         for unit in $portlist
1136         do
1137                 minor=`ttyminor $unit`
1138                 minor=$(($card * 65536 + $minor))
1139                 name=$card$unit
1140                 mknod ttyc$name c $major $minor
1141                 mknod ttyic$name c $major $(($minor + 32))
1142                 mknod ttylc$name c $major $(($minor + 64))
1143         done
1144         ;;
1145
1146 # RISCom8 'rc' driver entries
1147
1148 cuam?)
1149         umask 7
1150         unit=`expr $i : 'cua.*\(.\)$'`
1151         m=`ttyminor $unit`
1152         mknod cuam$unit c 63 $(($m + 128)) uucp:dialer
1153         umask 77
1154         ;;
1155
1156 ttym?)
1157         unit=`expr $i : 'tty.*\(.\)$'`
1158         m=`ttyminor $unit`
1159         mknod ttym$unit c 63 $m
1160         ;;
1161
1162 # Specialix SI/XIO.
1163 # Note: these are 'base 1' to match the numbers on the panels, and to match
1164 #       the manual that comes with the system.
1165 ttyA*)
1166         major=68
1167         units=`expr $i : 'ttyA\(.*\)$'`
1168         port=1
1169         while [ $port -le $units ]; do
1170                 minor=$(($port - 1))
1171                 name=$(zeropad 2 $port)
1172                 mknod ttyA$name c $major $minor
1173                 mknod ttyiA$name c $major $(($minor + 65536))
1174                 mknod ttylA$name c $major $(($minor + 131072))
1175                 port=$(($port + 1))
1176         done
1177         # For the user-mode control program, 'sicontrol'
1178         mknod si_control c 68 262144
1179         ;;
1180
1181 cuaA*)
1182         umask 7
1183         major=68
1184         units=`expr $i : 'cuaA\(.*\)$'`
1185         port=1
1186         while [ $port -le $units ]; do
1187                 minor=$(($port - 1))
1188                 name=$(zeropad 2 $port)
1189                 mknod cuaA$name c $major $(($minor + 128)) uucp:dialer
1190                 mknod cuaiA$name c $major $(($minor + 128 + 65536)) \
1191                     uucp:dialer
1192                 mknod cualA$name c $major $(($minor + 128 + 131072)) \
1193                     uucp:dialer
1194                 port=$(($port + 1))
1195         done
1196         umask 77
1197         ;;
1198
1199 # Alpha AS8[24]00 (TurboLaser) console.
1200 zs?)
1201         unit=`expr $i : 'zs.*\(.\)$'`
1202         m=`ttyminor $unit`
1203         mknod zs$unit c 135 $m
1204         ;;
1205
1206 # Digiboard PC/?? 16 port card.
1207 # The current scheme of minor numbering is:
1208 #
1209 #       unused{14} CARD{2} major{8} CALLOUT{1} LOCK{1} INIT{1} PORT{5}
1210 #
1211 #   CARD bitfield in future versions may be extended to 3 bits.
1212 #
1213 # See dgb(4)
1214 #
1215 ttyD?)
1216         portlist="0 1 2 3 4 5 6 7 8 9 a b c d e f"
1217         major=58
1218         card=`expr $i : 'tty.*\(.\)$'`
1219         for unit in $portlist
1220         do
1221                 minor=`ttyminor $unit`
1222                 minor=$(($card * 65536 + $minor))
1223                 name=$card$unit
1224                 mknod ttyD$name c $major $minor
1225                 mknod ttyiD$name c $major $(($minor + 32))
1226                 mknod ttylD$name c $major $(($minor + 64))
1227         done
1228
1229         # Also create devices for the digi driver
1230         umask 7
1231         major=162
1232         card=`expr $i : 'tty.*\(.\)$'`
1233         rm -f digi$card.ctl
1234         mknod digi$card.ctl c $major $(($card * 65536 + 8388608)) uucp:dialer
1235         unit=0
1236         while [ $unit -lt 16 ]
1237         do
1238                 base=$(($card * 65536 + $unit))
1239                 name=$card.$unit
1240                 rm -f tty*D$name
1241                 mknod ttyD$name c $major $base
1242                 mknod ttyiD$name c $major $(($base + 1048576))
1243                 mknod ttylD$name c $major $(($base + 2097152))
1244                 unit=$(($unit + 1))
1245         done
1246         umask 77
1247         ;;
1248
1249 cuaD?)
1250         umask 7
1251         portlist="0 1 2 3 4 5 6 7 8 9 a b c d e f"
1252         major=58
1253         card=`expr $i : 'cua.*\(.\)$'`
1254         for unit in $portlist
1255         do
1256                 minor=`ttyminor $unit`
1257                 minor=$(($card * 65536 + $minor))
1258                 name=$card$unit
1259                 mknod cuaD$name c $major $(($minor + 128)) uucp:dialer
1260                 mknod cuaiD$name c $major $(($minor + 32 + 128)) uucp:dialer
1261                 mknod cualD$name c $major $(($minor + 64 + 128)) uucp:dialer
1262         done
1263
1264         # Also create devices for the digi driver
1265         major=162
1266         card=`expr $i : 'cua.*\(.\)$'`
1267         rm -f digi$card.ctl
1268         mknod digi$card.ctl c $major $(($card * 65536 + 8388608)) uucp:dialer
1269         unit=0
1270         while [ $unit -lt 16 ]
1271         do
1272                 base=$(($card * 65536 + $unit))
1273                 name=$card.$unit
1274                 rm -f cua*D$name
1275                 mknod cuaD$name c $major $(($base + 4194304)) uucp:dialer
1276                 mknod cuaiD$name c $major $(($base + 5242880)) uucp:dialer
1277                 mknod cualD$name c $major $(($base + 6291456)) uucp:dialer
1278                 unit=$(($unit + 1))
1279         done
1280         umask 77
1281         ;;
1282
1283 # Digiboard Xem - superceeded by the digi device above
1284 #
1285 ttyM*)
1286         portlist="0 1 2 3 4 5 6 7 8 9 a b c d e f"
1287         modulelist="a b c d"
1288         major=101
1289         card=`expr $i : 'tty.*\(.\)$'`
1290         for unit in $modulelist
1291         do
1292                 moduleminor=`ttyminor $unit`
1293                 moduleminor=$(($moduleminor % 10 * 16))
1294                 modulename=$unit
1295
1296                 for unit in $portlist
1297                 do
1298                         minor=`ttyminor $unit`
1299                         minor=$(($card * 65536 + $minor + $moduleminor))
1300                         name=$card$modulename$unit
1301                         rm -f tty*M$name
1302                         mknod ttyM$name c $major $minor
1303                         mknod ttyiM$name c $major $(($minor + 64))
1304                         mknod ttylM$name c $major $(($minor + 128))
1305                 done
1306         done
1307         ;;
1308
1309 cuaM?)
1310         umask 7
1311         portlist="0 1 2 3 4 5 6 7 8 9 a b c d e f"
1312         modulelist="a b c d"
1313         major=101
1314         card=`expr $i : 'cua.*\(.\)$'`
1315         for unit in $modulelist
1316         do
1317                 moduleminor=`ttyminor $unit`
1318                 moduleminor=$(($moduleminor % 10 * 16))
1319                 modulename=$unit
1320
1321                 for unit in $portlist
1322                 do
1323                         minor=`ttyminor $unit`
1324                         minor=$(($card * 65536 + $minor + $moduleminor))
1325                         name=$card$modulename$unit
1326                         rm -f cua*M$name
1327                         mknod cuaM$name c $major $(($minor + 262144)) \
1328                             uucp:dialer
1329                         mknod cuaiM$name c $major $(($minor + 64 + 262144)) \
1330                             uucp:dialer
1331                         mknod cualM$name c $major $(($minor + 128 + 262144)) \
1332                             uucp:dialer
1333                 done
1334         done
1335         umask 77
1336         ;;
1337
1338 ttyR?)
1339         major=81
1340         BOARD=1; Rnum=0
1341         MINOR=$(($BOARD * 65536))
1342         controllers=$(
1343                 dmesg | while read first rest; do
1344                         case "$first" in
1345                         RocketPort[0-4])
1346                                 echo "$first"
1347                                 ;;
1348                         esac
1349                 done
1350         )
1351         rm -f ttyR* ttyiR* ttylR*
1352         for i in $controllers; do
1353            ndevices=$(
1354                 dmesg | while read first foo bar ports rest; do
1355                         case "$first" in
1356                         $i*)
1357                                 echo "$ports"
1358                                 ;;
1359                         esac
1360                 done
1361            )
1362            echo -n "Creating $ndevices devices for $i: "
1363            dev=0
1364            while [ $dev -lt $ndevices ]; do
1365                    mknod ttyR$Rnum c $major $MINOR
1366                    mknod ttyiR$Rnum c $major $(($MINOR + 32))
1367                    mknod ttylR$Rnum c $major $(($MINOR + 64))
1368                    Rnum=$(($Rnum + 1))
1369                    MINOR=$(($MINOR + 1))
1370                    dev=$(($dev + 1))
1371            done
1372                 BOARD=$(($BOARD + 1))
1373                 MINOR=$(($BOARD * 65536))
1374            echo " "
1375         done
1376         ;;
1377
1378 cuaR?)
1379         major=81
1380         BOARD=1; Rnum=0
1381         MINOR=$(($BOARD * 65536))
1382         controllers=$(
1383                 dmesg | while read first rest; do
1384                         case "$first" in
1385                         RocketPort[0-4])
1386                                 echo "$first"
1387                                 ;;
1388                         esac
1389                 done
1390         )
1391         rm -f cuaR* cuaiR* cualR*
1392         for i in $controllers; do
1393            ndevices=$(
1394                 dmesg | while read first foo bar ports rest; do
1395                         case "$first" in
1396                         $i*)
1397                                 echo "$ports"
1398                                 ;;
1399                         esac
1400                 done
1401            )
1402            echo -n "Creating $ndevices devices for $i: "
1403            dev=0
1404            while [ $dev -lt $ndevices ]; do
1405                    mknod cuaR$Rnum c  $major $(($MINOR + 128)) uucp:dialer
1406                    mknod cuaiR$Rnum c $major $(($MINOR + 128 + 32)) \
1407                        uucp:dialer
1408                    mknod cualR$Rnum c $major $(($MINOR + 128 + 64)) \
1409                        uucp:dialer
1410                    Rnum=$(($Rnum + 1))
1411                    MINOR=$(($MINOR + 1))
1412                    dev=$(($dev + 1))
1413            done
1414                 BOARD=$(($BOARD + 1))
1415                 MINOR=$(($BOARD * 65536))
1416            echo " "
1417         done
1418         ;;
1419
1420 mse*)
1421         unit=`expr $i : 'mse\(.*\)'`
1422         chr=27
1423         # non-blocking for X11
1424         mknod mse$unit c $chr `unit2minor $(($unit * 2 + 1))`
1425         ;;
1426
1427 psm*)
1428         unit=`expr $i : 'psm\(.*\)'`
1429         chr=21
1430         # non-blocking for X11
1431         mknod psm$unit c $chr `unit2minor $(($unit * 2 + 1))`
1432         ;;
1433
1434 mouse*)
1435         name=`expr $i : 'mouse\(.*\)'`
1436         if [ ! -c $name ]; then
1437                 $0 $name                        # make the appropriate device
1438         fi
1439         ln -fs $name mouse
1440         ;;
1441
1442 pcaudio)
1443         mknod pcaudio c 24 0
1444         mknod pcaudioctl c 24 128
1445         ;;
1446
1447 socksys)
1448         mknod socksys c 41 0
1449         mknod spx c 41 1
1450         ln -fs socksys nfsd
1451         chmod 666 socksys nfsd spx
1452         ;;
1453
1454 snd*)
1455 #
1456 # changes from Linux voxware
1457 # minor         Linux                   FreeBSD
1458 # 8             sequencer2 (aka music0) music0
1459 # 17            patmgr0                 sequencer1
1460 # 33            patmgr1                 sequencer2
1461 #
1462
1463         unit=`expr $i : 'snd\(.*\)'`
1464         chr=30
1465
1466         # XXX write this less verbosely, like std
1467         snd_security_hole=0     # XXX
1468         umask $snd_security_hole
1469
1470         ln -fs mixer$unit mixer
1471         ln -fs sequencer$unit sequencer
1472         ln -fs dsp$unit dsp
1473         ln -fs audio$unit audio
1474         ln -fs dspW$unit dspW
1475         ln -fs music$unit music
1476         ln -fs pss$unit pss
1477
1478         mknod mixer$unit        c $chr `unit2minor $(($unit * 16 + 0))`
1479         mknod sequencer$unit    c $chr `unit2minor $(($unit * 16 + 1))`
1480         mknod midi$unit         c $chr `unit2minor $(($unit * 16 + 2))`
1481         mknod dsp$unit          c $chr `unit2minor $(($unit * 16 + 3))`
1482         mknod audio$unit        c $chr `unit2minor $(($unit * 16 + 4))`
1483         mknod dspW$unit         c $chr `unit2minor $(($unit * 16 + 5))`
1484         mknod sndstat           c $chr 6
1485                                 # minor number 7 is unused
1486         mknod music$unit        c $chr `unit2minor $(($unit * 16 + 8))`
1487         mknod pss$unit          c $chr `unit2minor $(($unit * 16 + 9))`
1488                                 # minor number 10 is unused
1489         mknod midistat          c $chr 11
1490                                 # minor numbers 12-15 are unused
1491         umask 77
1492         ;;
1493
1494 vat)
1495         mknod vatio c 25 128
1496         chmod 660 vatio
1497         ;;
1498
1499 gsc*)
1500         unit=`expr $i : 'gsc\(.*\)'`
1501         mknod gsc${unit} c 47 `unit2minor $unit`
1502         mknod gsc${unit}p c 47 `unit2minor $(($unit + 8))`
1503         mknod gsc${unit}d c 47 `unit2minor $(($unit + 32))`
1504         mknod gsc${unit}pd c 47 `unit2minor $(($unit + 40))`
1505         chmod 666 gsc${unit}*
1506         ;;
1507
1508 acpi)
1509         mknod acpi c 152 0 root:operator
1510         chmod 660 acpi
1511         ;;
1512
1513 apm)
1514         mknod apm c 39 0 root:operator
1515         chmod 664 apm
1516         ;;
1517
1518 apmctl)
1519         mknod apmctl c 39 8 root:operator
1520         chmod 660 apmctl
1521         ;;
1522
1523 card*)
1524         unit=`expr $i : 'card\(.*\)'`
1525         chr=50
1526         mknod card$unit c $chr `unit2minor $unit`
1527         chmod 644 card$unit
1528         ;;
1529
1530 ti*)    unit=`expr $i : 'ti\(.*\)'`
1531         chr=153
1532         mknod ti$unit c $chr `unit2minor $unit`
1533         chmod 600 ti$unit
1534         ;;
1535
1536 ttyx?|ttyy?|ttyz?)
1537         case $i in
1538         *0) unit=0;;    *1) unit=1;;    *2) unit=2;;    *3) unit=3;;
1539         *4) unit=4;;    *5) unit=5;;    *6) unit=6;;    *7) unit=7;;
1540         *8) unit=8;;    *9) unit=9;;    *a) unit=10;;   *b) unit=11;;
1541         *c) unit=12;;   *d) unit=13;;   *e) unit=14;;   *f) unit=15;;
1542         esac
1543         case $i in
1544         ttyy?)  unit=$(($unit + 16));;
1545         ttyz?)  unit=$(($unit + 32));;
1546         esac
1547         mknod $i c 42 $unit
1548         ;;
1549
1550 cronyx)
1551         mknod cronyx c 42 63
1552         ;;
1553
1554 joy)
1555         mknod joy0 c 51 0 root:operator
1556         mknod joy1 c 51 1 root:operator
1557         chmod 640  joy0 joy1
1558         ;;
1559
1560 spigot)
1561         mknod spigot c 11 0
1562         chmod 444 spigot
1563         ;;
1564
1565 ctx?)
1566         unit=`expr $i : 'ctx\(.*\)'`
1567         mknod ctx$unit c 40 `unit2minor $unit`
1568         chmod 444 ctx$unit
1569         ;;
1570
1571 meteor?)
1572         unit=`expr $i : 'meteor\(.*\)'`
1573         mknod meteor$unit c 67 `unit2minor $unit`
1574         chmod 444 meteor$unit
1575         ;;
1576
1577 bktr?)
1578         unit=`expr $i : 'bktr\(.*\)'`
1579         mknod bktr$unit c 92 `unit2minor $unit`
1580         mknod tuner$unit c 92 `unit2minor $((16 + $unit))`
1581         mknod vbi$unit c 92 `unit2minor $((32 + $unit))`
1582         chmod 444 bktr$unit tuner$unit vbi$unit
1583         ;;
1584
1585 tun*)
1586         units=`expr $i : 'tun\(.*\)$'`
1587         unit=0
1588         while [ $unit -le $units ]; do
1589                 mknod tun$unit c 52 `unit2minor $unit`
1590                 unit=$(($unit + 1))
1591         done
1592         ;;
1593
1594 tap*)
1595         units=`expr $i : 'tap\(.*\)$'`
1596         unit=0
1597         while [ $unit -le $units ]; do
1598                 mknod tap$unit c 149 `unit2minor $unit` root:network
1599                 unit=$(($unit + 1))
1600         done
1601         ;;
1602
1603 sysmouse)
1604         mknod sysmouse c 12 128
1605         mknod consolectl c 12 255
1606         ;;
1607
1608 jogdial)
1609         mknod jogdial c 160 0
1610         ;;
1611
1612 snp?)
1613         unit=`expr $i : 'snp\(.*\)'`
1614         mknod snp$unit c 53 `unit2minor $unit`
1615         ;;
1616
1617 # dufault@hda.com: If I do much more work on other A-D boards
1618 # then eventually we'll have a "ad" and "dio" interface and some of these
1619 # "labpcaio" ones will be gone.
1620 # labpcaio: D-A and A-D.
1621 # labpcdio: Digital in and Digital out.
1622 #
1623 labpc*)
1624         umask 7
1625         case $i in
1626         labpcaio*)
1627                 name=labpcaio
1628                 unit=`expr $i : 'labpcaio\(.*\)'`
1629                 all="0 1 2 3 4 5 6 7"
1630                 offset=0
1631                 ;;
1632         labpcdio*)
1633                 name=labpcdio
1634                 unit=`expr $i : 'labpcdio\(.*\)'`
1635                 all="0 1 2 3"
1636                 offset=8
1637                 ;;
1638         *)
1639                 die 3 "Don't know LabPC type $i"
1640                 ;;
1641         esac
1642         if [ -z "${unit}" ]; then
1643                 unit=all
1644         fi
1645         case $unit in
1646                 0|1|2|3|4|5|6|7)
1647                                 mknod $name$unit c 66 $(($offset + $unit))
1648                 ;;
1649                 all)
1650                         for i in $all
1651                         do
1652                                 mknod $name$i c 66 $(($offset + $i))
1653                         done
1654                         ;;
1655                 *)
1656                         echo "No such LabPC unit: $unit"
1657                         ;;
1658         esac
1659         umask 77
1660         ;;
1661
1662 perfmon)
1663         mknod perfmon c 2 32 root:kmem
1664         chmod 640 perfmon
1665         ;;
1666
1667 ipl)
1668         mknod ipl c 79 0
1669         mknod ipnat c 79 1
1670         mknod ipstate c 79 2
1671         mknod ipauth c 79 3
1672         ;;
1673
1674 kbd*)
1675         unit=`expr $i : 'kbd\(.*\)'`
1676         chr=112
1677         mknod kbd$unit c $chr `unit2minor $unit`
1678         ;;
1679
1680 i4b)
1681         mknod i4b c 60 0
1682         ;;
1683
1684 i4bctl)
1685         mknod i4bctl c 55 0
1686         ;;
1687
1688 i4brbch*)
1689         unit=`expr $i : 'i4brbch\(.*\)'`
1690         mknod i4brbch$unit c 57 `unit2minor $unit`
1691         ;;
1692
1693 i4bteld*)
1694         offset=64
1695         unit=`expr $i : 'i4bteld\(.*\)'`
1696         mknod i4bteld$unit c 56 `unit2minor $(($offset + $unit))`
1697         ;;
1698
1699 i4btel*)
1700         unit=`expr $i : 'i4btel\(.*\)'`
1701         mknod i4btel$unit c 56 `unit2minor $unit`
1702         ;;
1703
1704 i4btrc*)
1705         unit=`expr $i : 'i4btrc\(.*\)'`
1706         mknod i4btrc$unit c 59 `unit2minor $unit`
1707         ;;
1708
1709 aac*)
1710         unit=`expr $i : 'aac\(.*\)'`
1711         mknod aac$unit c 150 `unit2minor $unit`
1712         ln -fs aac$unit afa$unit
1713         ln -fs aac$unit hpn$unit
1714         ;;
1715
1716 mlx*)
1717         unit=`expr $i : 'mlx\(.*\)'`
1718         mknod mlx$unit c 130 `unit2minor $unit`
1719         ;;
1720
1721 mly*)
1722         unit=`expr $i : 'mlx\(.*\)'`
1723         mknod mlx$unit c 158 `unit2minor $unit`
1724         ;;
1725
1726 amr*)
1727         unit=`expr $i : 'amr\(.*\)'`
1728         mknod amr$unit c 132 `unit2minor $unit`
1729         ;;
1730
1731 ciss*)
1732         unit=`expr $i : 'ciss\(.*\)'`
1733         mknod ciss$unit c 166 `unit2minor $unit`
1734         ;;
1735
1736 3dfx*)
1737         unit=`expr $i : '3dfx\(.*\)'`
1738         mknod 3dfx$unit c 107 `unit2minor $unit`
1739         ln -sf 3dfx$unit 3dfx
1740    ln -sf 3dfx$unit voodoo
1741         ;;
1742
1743 agpgart)
1744         mknod agpgart c 148 0
1745         ;;
1746
1747 twe*)
1748         unit=`expr $i : 'twe\(.*\)'`
1749         mknod twe$unit c 146 `unit2minor $unit`
1750         ;;
1751
1752 tw*)
1753         unit=`expr $i : 'tw\(.*\)'`
1754         mknod tw$unit c 19 `unit2minor $unit` root:operator
1755         ;;
1756
1757 cfs*)
1758         unit=`expr $i : 'cfs\(.*\)'`
1759         mknod cfs$unit c 93 $unit root:operator
1760         ;;
1761
1762 nsmb*)
1763         unit=`expr $i : 'nsmb\(.*\)'`
1764         mknod nsmb$unit c 144 $unit
1765         ;;
1766
1767 local)
1768         umask 0                 # XXX should be elsewhere
1769         sh $0.local
1770         umask 77
1771         ;;
1772
1773 *)
1774         echo $i - no such device name
1775         ;;
1776
1777 esac
1778 done