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