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