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