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