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