Merge from vendor branch NCURSES:
[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.17 2005/02/26 12:00:54 swildner Exp $
25 #
26 # Device "make" file.  Valid arguments:
27 #       all     makes all known devices, standard number of units (or close)
28 #       std     standard devices
29 #       jail    suitable for a jail(8)
30 #       local   configuration specific devices
31 #       mach-4  mach4&lites+devices for Mach's XFree86 distribution
32 #       (see http://www.cs.hut.fi/lites.html for more info on LITES)
33 #
34 # Tapes:
35 #       ast*    ATAPI tape drives
36 #       wt*     QIC-interfaced (e.g. not SCSI) 3M cartridge tape
37 #       sa*     SCSI Sequential Access Devices
38 #
39 # Disks:
40 #       aac*    Adaptec FSA RAID controllers
41 #       aacd*   Adaptec FSA RAID
42 #       acd*    ATAPI CD-ROM disks
43 #       ad*     ATA disks
44 #       afd*    ATAPI floppy disks
45 #       amrd*   AMI MegaRAID
46 #       cd*     SCSI CD-ROM disks
47 #       da*     SCSI Direct Access Devices
48 #       fd*     floppy disk drives (3 1/2", 5 1/4")
49 #       fla*    M-Systems DiskOnChip
50 #       idad*   Compaq Smart-2 RAID arrays
51 #       ips*    IBM ServeRAID controller
52 #       ipsd*   IBM ServeRAID
53 #       mcd*    Mitsumi CD-ROM disks
54 #       md*     Memory (or malloc) disk
55 #       mlx*    Mylex DAC960 RAID controllers
56 #       mlxd*   Mylex DAC960 RAID disk volumes
57 #       pst*    Promise SuperTrak RAID disks
58 #       scd*    Sony CD-ROM disks
59 #       vn*     vnode disks
60 #
61 # Console ports:
62 #       vty*    virtual console devices for syscons/pcvt/codrv
63 #
64 # Pointing devices:
65 #       mse*    Logitech and ATI Inport bus mouse
66 #       psm*    PS/2 mouse
67 #       jogdial Sony VAIO Jogdial
68 #       sysmouse Mousesystems mouse emulator for syscons
69 #
70 # Time devices:
71 #       refclock-* serial ports used by xntpd parse refclocks
72 #
73 # Terminal ports:
74 #       tty*    general purpose serial ports
75 #       cua*    dialout serial ports
76 #       ttyA*   Specialix SI/XIO dialin ports ('*' = number of devices)
77 #       cuaA*   Specialix SI/XIO dialout ports
78 #       ttyD*   Digiboard - 16 dialin ports
79 #       cuaD*   Digiboard - 16 dialout ports
80 #       ttyE*   Stallion EasyIO (stl) dialin ports
81 #       cuaE*   Stallion EasyIO (stl) dialout ports
82 #       ttyF*   Stallion Brumby (stli) dialin ports
83 #       cuaF*   Stallion Brumby (stli) dialout ports
84 #       ttyR*   Rocketport dialin ports
85 #       cuaR*   Rocketport dialout ports
86 #
87 #       stlN    Stallion EasyIO board N dialin and dialout
88 #       stliN   Stallion Brumby board N dialin and dialout
89 #
90 # Pseudo terminals:
91 #       pty*    set of 32 master and slave pseudo terminals
92 #       vty*    virtual terminals using syscons/pcvt/codrv console
93 #
94 # Parallel port:
95 #       lpt*    Printer
96 #       ppi*    Parallel port i/o
97 #       pps*    Pulse per second timing interface
98 #       pcfclock* Parallel time sync interface
99 #
100 # I2C and SMBus:
101 #       iic*    I2C devices
102 #       smb*    SMBUS devices
103 #
104 # USB devices:
105 #       usb*    USB bus control device
106 #       ucom*   USB serial devices
107 #       ugen*   generic USB device
108 #       uhid*   Human Interface Device (HID)
109 #       ulpt*   printer
110 #       umodem* modems
111 #       ums*    mouse
112 #       urio*   Diamond Rio 500
113 #       uscanner* USB scanners
114 #
115 # SCSI devices (other than CD-ROM, tape and disk):
116 #       ch*     SCSI Media-Changer (juke box) driver
117 #       pt*     Processor Type (HP scanner, as one example)
118 #       pass*   CAM Passthrough device
119 #       ses*    SES (SCSI Environmental Services) and
120 #               SAF-TE (Scsi Accessable Fault-Tolerant Enclosures) device
121 #
122 # PC-CARD (previously called PCMCIA) support
123 #       card*   PC-CARD slots
124 #
125 # ISDN devices:
126 #       i4b     isdnd call control device
127 #       i4bctl  debugging control device
128 #       i4btrc* trace data interface(s), one per passive card
129 #       i4btel* telephony interface(s)
130 #       i4bteld* telephony dialout interface(s)
131 #       i4brbch* raw b channel access device(s)
132 #
133 # Special purpose devices:
134 #       acpi    ACPI control device
135 #       apm     Advanced Power Management BIOS
136 #       apmctl  APM BIOS control device
137 #       bpf*    packet filter
138 #       crypto  crypto interface
139 #       speaker pc speaker
140 #       tw*     xten power controller
141 #       snd*    various sound cards
142 #       pcaudio PCM audio driver
143 #       socksys iBCS2 socket system driver
144 #       vat     VAT compatibility audio driver (requires snd*)
145 #       gsc     Genius GS-4500 hand scanner
146 #       joy     pc joystick
147 #       tun*    Tunneling IP device
148 #       tap*    Ethernet Tunneling device
149 #       snp*    tty snoop devices
150 #       spigot  Video Spigot video acquisition card
151 #       ctx*    Cortex-I video acquisition card
152 #       meteor* Matrox Meteor video acquisition card (pci)
153 #       bktr*   Bt848 based video acquisition card (pci)
154 #       labpc*  National Instrument's Lab-PC and LAB-PC+
155 #       perfmon CPU performance-monitoring counters
156 #       pci     PCI configuration-space access from user mode
157 #       ipl     ipfilter control devices (ipl, ipnat, ipstate, ipauth)
158 #       kbd     keyboard devices
159 #       elan-mmcr       AMD Elan support (e.g. mmap MMCR)
160 #       agpgart AGP interface
161 #       cfs*    Coda Distributed Filesystem
162 #       nsmb*   SMB/CIFS protocol interface
163 #       pf      PF packet filter
164 #
165
166 if [ -n "$MAKEDEVPATH" ]; then
167         PATH="$MAKEDEVPATH"
168 else
169         PATH=/sbin:/bin
170 fi
171 umask 77
172
173 # Usage: die exitcode msg
174 die() {
175         echo $2
176         exit $1
177 }
178
179 # Convert integer to partition name
180 dkitop() {
181         local p
182
183         case $1 in
184         0) p=a;; 1) p=b;; 2) p=c;; 3) p=d;; 4) p=e;; 5) p=f;; 6) p=g;; 7) p=h;;
185         8) p=i;; 9) p=j;; 10) p=k;; 11) p=l;; 12) p=m;; 13) p=n;; 14) p=o;; 15) p=p;;
186         *) p="?";;
187         esac
188         echo $p
189 }
190
191 # Convert integer to slice name
192 dkitos() {
193         local s
194
195         case $1 in
196         0) s="";;
197         1) s="";;
198         *) s=s$(($1-1));;
199         esac
200         echo $s
201 }
202
203 # Convert disk (type, unit, slice, partition) to minor number
204 dkminor()
205 {
206         echo $(($1 << 25 | ($2 / 32) << 21 | ($2 % 32) << 3 | $3 << 16 | ($4 & 7) | ($4 & 8) << 17))
207 }
208
209 # Override mknod(2) to add extra handling to it.
210 mknod=/sbin/mknod
211 for i in `IFS=':'; echo $PATH`; do
212         if [ -x "${i}/mknod" ]; then
213                 mknod="${i}/mknod"
214                 break
215         fi
216 done
217 mknod() {
218         rm -f "$1" || exit 1
219         case $# in
220         4) "$mknod" "$@" root:wheel || die 2 "$mknod $@ failed";;
221         5) "$mknod" "$@"            || die 2 "$mknod $@ failed";;
222         *) die 2 "bad node: mknod $@";;
223         esac
224 }
225
226 # Convert tape (ctrl, unit, mode, access) to minor number
227 saminor()
228 {
229         echo $(($1 << 29 | ($2 / 16) << 16 | ($2 % 16) << 4 | $3 << 2 | $4))
230 }
231
232 # Convert the last character of a tty name to a minor number.
233 ttyminor()
234 {
235         case $1 in
236         [0-9]) m=$1;;
237         a) m=10;; b) m=11;; c) m=12;; d) m=13;; e) m=14;; f) m=15;; g) m=16;;
238         h) m=17;; i) m=18;; j) m=19;; k) m=20;; l) m=21;; m) m=22;; n) m=23;;
239         o) m=24;; p) m=25;; q) m=26;; r) m=27;; s) m=28;; t) m=29;; u) m=30;;
240         v) m=31;;
241         *) m="?";;
242         esac
243         echo $m
244 }
245
246 # Convert a unit number to a minor number.
247 unit2minor()
248 {
249   echo $(((($1 >> 8) << 16) | ($1 % 256)))
250 }
251
252 # For the stallion devices tty[EF]
253 # stallion major letter card iscallout
254 stallion () {
255         major=$1
256         letter=$2
257         card=$3
258         iscallout=$4
259
260         port=0
261         maxport=8
262         pref=tty
263         owner=
264         minorbase=0
265
266         if [ $iscallout -gt 0 ]; then
267             pref=cua
268             owner=uucp:dialer
269             minorbase=128
270         fi
271
272         case "$card" in 
273         [0-7]);;
274         *) die 1 "Invalid stl card number $card";;
275         esac
276
277         # make the mem interface for extracting stats & loading microcode.
278         # 0x1000000 + card number
279         mknod staliomem$card c $major 0x0100000$card
280
281         while [ $port -lt $maxport ]; do
282             minor=$(($minorbase + $card * 1048576 + $port))
283             if [ $port -ge 32 ]; then
284                 minor=$(($minor + 65504))
285             fi
286             unit=$(($card * 64 + $port))
287
288             mknod ${pref}${letter}$unit c $major $minor $owner
289             mknod ${pref}i${letter}$unit c $major $(($minor + 32)) $owner
290             mknod ${pref}l${letter}$unit c $major $(($minor + 64)) $owner
291             port=$(($port + 1))
292         done
293 }
294
295 # Raw partition for disks
296 dkrawpart=2
297
298 # Compatibility slice for disks
299 dkcompatslice=0
300
301 # Raw slice for disks
302 dkrawslice=1
303
304 # Standard umasks
305 disk_umask=037                  # allow group operator to read disks
306 tape_umask=017                  # allow group operator to read/write tapes
307
308 for i in $*; do
309 case $i in
310
311 all)
312         sh MAKEDEV std                                  # standard
313         sh MAKEDEV fd0 fd1                              # bdev, floppy disk
314         sh MAKEDEV da0 da1 da2 da3 da4 da5 da6 da7      # bdev, SCSI disk
315         sh MAKEDEV da8 da9 da10 da11 da12 da13 da14     # bdev, SCSI disk
316         sh MAKEDEV da15                                 # bdev, SCSI disk
317         sh MAKEDEV ata                                  # cdev, ATA control
318         sh MAKEDEV ad0 ad1 ad2 ad3 ad4 ad5 ad6 ad7      # bdev, ATA disk
319         sh MAKEDEV ar0 ar1                              # bdev, ATA RAID disk
320         sh MAKEDEV acd0 afd0 ast0                       # bdev, ATAPI devices
321         sh MAKEDEV vn0                                  # bdev, virtual disk
322         sh MAKEDEV cd0 mcd0 scd0                        # bdev, cdrom
323         sh MAKEDEV sa0 wt0                              # bdev, tape
324         sh MAKEDEV vty12                                # cdev, virtual tty
325         sh MAKEDEV cuaa0 cuaa1 cuaa2 cuaa3              # cdev, serial tty
326         sh MAKEDEV pty0                                 # cdev, pseudo tty
327         sh MAKEDEV ttyd0 ttyd1 ttyd2 ttyd3              # cdev, serial tty
328         sh MAKEDEV zs0                                  # big-Alpha serial tty
329         sh MAKEDEV kbd0 kbd1                            # cdev, keyboard
330         sh MAKEDEV mse0 psm0 jogdial sysmouse           # cdev, mouse
331         sh MAKEDEV pcaudio speaker snd0                 # cdev, noise
332         sh MAKEDEV ipsd0                                # cdev, ServeRAID disk
333         sh MAKEDEV lpt0 lpt1 lpt2                       # cdev, printer
334         sh MAKEDEV ppi0 ppi1 ppi2                       # cdev, parallel port
335         sh MAKEDEV iic0 iic1                            # cdev, I2C device
336         sh MAKEDEV smb0 smb1                            # cdev, SMBus device
337         sh MAKEDEV usb usb0 uhid0 ums0 ulpt0 ugen0      # cdev, USB devices
338         sh MAKEDEV usb1 uhid1 ums1 ulpt1 ugen1          # cdev, USB devices
339         sh MAKEDEV usb2 usb3 usb4 usb5                  # cdev, USB devices
340         sh MAKEDEV urio0 uscanner0 umodem0              # cdev, USB devices too
341         sh MAKEDEV bpf0 bpf1 bpf2 bpf3                  # cdev, network
342         sh MAKEDEV ipl tun0 tun1 tun2 tun3              # cdev, network
343         sh MAKEDEV tap0 tap1 tap2 tap3                  # cdev, network
344         sh MAKEDEV ch0 perfmon tw0                      # cdev, miscellaneous
345         sh MAKEDEV acpi                                 # cdev, laptop
346         sh MAKEDEV apm apmctl card0 card1 card2 card3   # cdev, laptop
347         sh MAKEDEV pass4 xpt2                           # cdev, CAM
348         sh MAKEDEV i4b i4bctl i4btrc0 i4btrc1           # cdev, ISDN
349         sh MAKEDEV i4btel0 i4btel1 i4bteld0 i4bteld1    # cdev, ISDN
350         sh MAKEDEV i4brbch0 i4brbch1                    # cdev, ISDN
351         sh MAKEDEV agpgart                              # cdev, AGP
352         sh MAKEDEV nsmb0                                # cdev, SMB/CIFS
353         sh MAKEDEV twed0                                # 3ware
354         sh MAKEDEV crypto                               # cdev, crypto
355         sh MAKEDEV fw0                                  # cdev, firewire
356         sh MAKEDEV dcons                                # cdev, dcons
357         sh MAKEDEV pf                                   # pf
358         ;;
359
360 # a much restricted set of the above, to save precious i-nodes on the
361 # fixit floppy
362 fixit)
363         sh MAKEDEV std                                  # standard
364         sh MAKEDEV fd0                                  # bdev, floppy disk
365         sh MAKEDEV da0                                  # bdev, SCSI disk
366         sh MAKEDEV ad0                                  # bdev, ATA disk
367         sh MAKEDEV acd0 afd0 ast0                       # bdev, ATAPI devices
368         sh MAKEDEV vn0                                  # bdev, virtual disk
369         sh MAKEDEV cd0                                  # bdev, cdrom
370         sh MAKEDEV sa0                                  # bdev, tape
371         sh MAKEDEV vty2                                 # cdev, virtual tty
372         sh MAKEDEV cuaa0                                # cdev, serial tty
373         sh MAKEDEV pty0                                 # cdev, pseudo tty
374         sh MAKEDEV ttyd0                                # cdev, serial tty
375         sh MAKEDEV zs0                                  # big-Alpha serial tty
376         sh MAKEDEV kbd0                                 # cdev, keyboard
377         sh MAKEDEV mse0 psm0 sysmouse                   # cdev, mouse
378         sh MAKEDEV lpt0                                 # cdev, printer
379         sh MAKEDEV ppi0                                 # cdev, parallel port
380         sh MAKEDEV iic0                                 # cdev, I2C device
381         sh MAKEDEV smb0                                 # cdev, SMBus device
382         sh MAKEDEV ums0                                 # cdev, USB devices
383         sh MAKEDEV tun0                                 # cdev, network
384         sh MAKEDEV tap0                                 # cdev, network
385         sh MAKEDEV ch0                                  # cdev, miscellaneous
386         sh MAKEDEV apm apmctl card0                     # cdev, laptop
387         sh MAKEDEV pass1 xpt1                           # cdev, CAM
388         sh MAKEDEV i4b i4bctl i4btrc0 i4btrc1           # cdev, ISDN
389         sh MAKEDEV i4btel0 i4bteld0                     # cdev, ISDN
390         sh MAKEDEV i4brbch0                             # cdev, ISDN
391         rm -f fd/[1-9]?
392         ;;
393
394 std)
395         mknod console   c 0 0;                  chmod 600 console
396         mknod kmem      c 2 1 root:kmem;        chmod 640 kmem
397         mknod mem       c 2 0 root:kmem;        chmod 640 mem
398         mknod null      c 2 2;                  chmod 666 null
399         mknod random    c 2 3;                  chmod 644 random
400         mknod urandom   c 2 4;                  chmod 644 urandom
401         mknod zero      c 2 12;                 chmod 666 zero
402         mknod io        c 2 14;                 chmod 600 io
403         mknod tty       c 1 0;                  chmod 666 tty
404         mknod klog      c 7 0;                  chmod 600 klog
405         mknod stdin     c 22 0;                 chmod 666 stdin
406         mknod stdout    c 22 1;                 chmod 666 stdout
407         mknod stderr    c 22 2;                 chmod 666 stderr
408         mknod pci       c 78 0;                 chmod 644 pci
409         mkdir -p fd
410         (cd fd && i=0 &&
411                 while [ $i -lt 64 ]; do
412                         mknod $i c 22 $i
413                         i=$(($i + 1))
414                 done
415         )
416         chmod 555 fd
417         chmod 666 fd/*
418         ;;
419
420 jail)
421         sh MAKEDEV std pty0
422         rm mem kmem pci io klog console         # for security
423         ln -sf null mem                 # for libkvm (ab)users
424         ln -sf null kmem                # --//--
425         ln -sf null console
426         ;;
427
428 mach-4)
429         mknod iopl c 22 0
430         mknod kbd c 23 0
431         mknod mouse c 24 0
432         mknod time c 25 0
433         mknod timezone c 26 0
434         ;;
435
436 # Create device files for new Archive/Wangtek QIC-02 tape driver (vak)
437 wt*)
438         umask $tape_umask
439         u=`expr $i : '..\(.*\)'`
440         if [ -z "${u}" ]; then u=0; fi
441         # default density, 512b blocks
442         mknod rwt${u}   c 10 $(( 0 + $u)) root:operator
443         mknod nrwt${u}  c 10 $(( 4 + $u)) root:operator
444         # default density, 1024b blocks
445 #       mknod rWt${u}   c 10 $((64 + $u)) root:operator
446 #       mknod nrWt${u}  c 10 $((68 + $u)) root:operator
447         mknod rwt${u}b  c 10 $((16 + $u)) root:operator # 60 megabytes
448         mknod nrwt${u}b c 10 $((20 + $u)) root:operator
449         mknod rwt${u}c  c 10 $((24 + $u)) root:operator # 120 megabytes
450         mknod nrwt${u}c c 10 $((28 + $u)) root:operator
451         mknod rwt${u}d  c 10 $((32 + $u)) root:operator # 150 megabytes
452         mknod nrwt${u}d c 10 $((36 + $u)) root:operator
453 #       mknod rwt${u}e  c 10 $((40 + $u)) root:operator # 300 megabytes?
454 #       mknod nrwt${u}e c 10 $((44 + $u)) root:operator
455 #       mknod rwt${u}f  c 10 $((48 + $u)) root:operator # 600 megabytes?
456 #       mknod nrwt${u}f c 10 $((52 + $u)) root:operator
457         umask 77
458         ;;
459
460 # Individual slices.
461 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*)
462         umask $disk_umask
463         case $i in
464         aacd*s*) name=aacd; chr=151;;
465         ad*s*) name=ad; chr=116;;
466         ar*s*) name=ar; chr=157;;
467         afd*s*) name=afd; chr=118;;
468         amrd*s*) name=amrd; chr=133;;
469         da*s*) name=da;  chr=13;;
470         fla*s*) name=fla; chr=102;;
471         idad*s*) name=idad; chr=109;;
472         ipsd*s*) name=ipsd; chr=176;;
473         md*s*) name=md;  chr=95;;
474         mlxd*s*) name=mlxd; chr=131;;
475         pst*s*) name=pst; chr=168;;
476         twed*s*) name=twed; chr=147;;
477         vn*s*) name=vn; chr=43;;
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*)
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         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 iic*)
954         unit=`expr $i : 'iic\(.*\)'`
955         mknod iic$unit c 105 `unit2minor $unit`
956         ;;
957
958 smb*)
959         unit=`expr $i : 'smb\(.*\)'`
960         mknod smb$unit c 106 `unit2minor $unit`
961         ;;
962
963 pcfclock*)
964         unit=`expr $i : 'pcfclock\(.*\)'`
965         mknod pcfclock$unit c 140 `unit2minor $unit`
966         ;;
967
968 ppi*)
969         unit=`expr $i : 'ppi\(.*\)'`
970         mknod ppi$unit c 82 `unit2minor $unit`
971         ;;
972
973 pps*)
974         unit=`expr $i : 'pps\(.*\)'`
975         mknod pps$unit c 89 `unit2minor $unit`
976         ;;
977
978 usb)
979         mknod usb c 108 255 root:operator
980         chmod 0660 usb
981         ;;
982
983 usb*)
984         umask 7
985         unit=`expr $i : 'usb\(.*\)'`
986         mknod usb$unit c 108 `unit2minor $unit` root:operator
987         umask 77
988         ;;
989
990 ucom*)
991         umask 7
992         unit=`expr $i : 'ucom\(.*\)'`
993         minor=$(($unit + 128))
994         minor=`unit2minor $(($unit + 128))`
995         mknod ucom$unit c 138 $minor uucp:dialer
996         umask 77
997         ;;
998
999 uhid*)
1000         umask 7
1001         unit=`expr $i : 'uhid\(.*\)'`
1002         mknod uhid$unit c 122 `unit2minor $unit` root:operator
1003         umask 77
1004         ;;
1005
1006 ums*)
1007         umask 7
1008         unit=`expr $i : 'ums\(.*\)'`
1009         mknod ums$unit c 111 `unit2minor $unit` root:operator
1010         umask 77
1011         ;;
1012
1013 ulpt*)
1014         unit=`expr $i : 'ulpt\(.*\)'`
1015         minor=`unit2minor $unit`
1016         mknod ulpt$unit c 113 $minor
1017         minor=`unit2minor $(($unit + 64))`
1018         mknod unlpt$unit c 113 $minor           # and the 'no prime' version
1019         ;;
1020
1021 ugen*)
1022         umask 7
1023         unit=`expr $i : 'ugen\([0-9][0-9]*\)'`
1024         endpoint=`expr $i : 'ugen.*\.\([0-9][0-9]*\)'`
1025         if [ -z "${unit}" ]; then
1026                 echo $i - Invalid unit number
1027         fi
1028         if [ -z "${endpoint}" ]; then           # ugen0 & ugen0.1 - ugen0.15
1029                 mknod ugen$unit c 114 \
1030                                 `unit2minor $(($unit * 16))` root:operator
1031                 i=1
1032                 while [ $i -lt 16 ]; do
1033                         mknod ugen$unit.$i c 114 \
1034                                 `unit2minor $(($unit * 16 + $i))` root:operator
1035                         i=$(($i + 1))
1036                 done
1037         else
1038                 minor=`unit2minor $(($unit * 16 + $endpoint))`
1039                 mknod ugen$unit.$endpoint c 114 $minor root:operator
1040         fi
1041         umask 77
1042         ;;
1043
1044 urio*)
1045         umask 7
1046         unit=`expr $i : 'urio\(.*\)'`
1047         mknod urio$unit c 143 `unit2minor $unit` root:operator
1048         umask 77
1049         ;;
1050
1051 uscanner*)
1052         umask 7
1053         unit=`expr $i : 'uscanner\(.*\)'`
1054         mknod uscanner$unit c 156 `unit2minor $unit` root:operator
1055         umask 77
1056         ;;
1057
1058 umodem*)
1059         umask 7
1060         unit=`expr $i : 'umodem\(.*\)'`
1061         mknod umodem$unit c 124 `unit2minor $unit` uucp:dialer
1062         umask 77
1063         ;;
1064
1065 lpt*)
1066         unit=`expr $i : 'lpt\(.*\)'`
1067         mknod lpt$unit c 16 `unit2minor $unit`
1068         mknod lpctl$unit c 16 `unit2minor $(($unit + 128))`
1069         ;;
1070
1071 # Use this to create virtual consoles for syscons, pcvt or codrv
1072 # ttyv0-b
1073 # use as MAKEDEV vtyNN to create NN entries
1074 vty*)
1075         chr=12
1076         units=`expr $i : 'vty\(.*\)'`
1077         i=0
1078         while [ $i -lt $units ]; do
1079                 mknod ttyv$(printf %01x $i) c $chr `unit2minor $i`
1080                 i=$(($i + 1))
1081         done
1082         ln -fs ttyv0 vga        # XXX X still needs this pccons relic
1083         ;;
1084
1085 nmdm*)
1086         units=`expr $i : 'nmdm\(.*\)'`
1087         chr=18
1088         i=0
1089         while [ $i -lt $units ]; do
1090                 minor=`unit2minor $i`
1091                 minor=$(($minor + $minor))
1092                 mknod nmdm${i}A c $chr $minor
1093                 mknod nmdm${i}B c $chr $(($minor + 1))
1094                 i=$(($i + 1))
1095         done
1096         ;;
1097
1098 bpf*)
1099         nbpf=`expr $i : 'bpf\(.*\)$'`
1100         unit=0
1101         while [ $unit -le $nbpf ]; do
1102                 mknod bpf$unit c 23 `unit2minor $unit`
1103                 unit=$(($unit + 1))
1104         done
1105         ;;
1106
1107 speaker)
1108         mknod speaker c 26 0
1109         ;;
1110
1111 cua?|cuaa?|cuaa??)
1112         umask 7
1113         unit_low=`expr $i : 'cua.*\(.\)$'`
1114         case $i in
1115         cua?|cuaa?)
1116                 unit_high=""
1117                 m_high=0
1118                 ;;
1119         cuaa??)
1120                 unit_high=`expr $i : 'cuaa\(.\).$'`
1121                 m_high=`ttyminor $unit_high`
1122                 ;;
1123         esac
1124         unit=$unit_high$unit_low
1125         m=$(($m_high << 16 | `ttyminor $unit_low`))
1126         mknod cuaa$unit c 28 $(($m | 128)) uucp:dialer
1127         mknod cuaia$unit c 28 $(($m | 32 | 128)) uucp:dialer
1128         mknod cuala$unit c 28 $(($m | 64 | 128)) uucp:dialer
1129         umask 77
1130         ;;
1131
1132 crypto)
1133         mknod crypto c 70 0 root:operator
1134         chmod 666 crypto
1135         ;;
1136 pf)
1137         mknod pf c 73 0 root:operator
1138         chmod 600 pf
1139         ;;
1140 fw?)
1141         unit=`expr $i : 'fw\(.\)$'`
1142         for sub in 0 1 2 3
1143         do
1144                 minor=$(($unit << 16 | $sub))
1145                 mknod fw$unit.$sub c 127 $minor root:operator
1146                 chmod 660 fw$unit.$sub
1147                 mknod fwmem$unit.$sub c 127 $((1<<24 | $minor)) root:operator
1148                 chmod 660 fwmem$unit.$sub
1149         done
1150         ln -sf fw$unit.0 fw$unit
1151         ln -sf fwmem$unit.0 fwmem$unit
1152         ;;
1153
1154 dcons)
1155         mknod dcons c 184 0 root:wheel
1156         chmod 600 dcons
1157         ;;
1158
1159 tty?|tty0?|ttyd?|ttyd??)
1160         unit_low=`expr $i : 'tty.*\(.\)$'`
1161         case $i in
1162         tty?|tty0?|ttyd?)
1163                 unit_high=""
1164                 m_high=0
1165                 ;;
1166         ttyd??)
1167                 unit_high=`expr $i : 'ttyd\(.\).$'`
1168                 m_high=`ttyminor $unit_high`
1169                 ;;
1170         esac
1171         unit=$unit_high$unit_low
1172         m=$(($m_high << 16 | `ttyminor $unit_low`))
1173         mknod ttyd$unit c 28 $m
1174         mknod ttyid$unit c 28 $(($m | 32))
1175         mknod ttyld$unit c 28 $(($m | 64))
1176         ;;
1177
1178 cuac?)
1179         umask 7
1180         portlist="0 1 2 3 4 5 6 7 8 9 a b c d e f
1181                   g h i j k l m n o p q r s t u v"
1182         major=48
1183         card=`expr $i : 'cua.*\(.\)$'`
1184         for unit in $portlist
1185         do
1186                 minor=`ttyminor $unit`
1187                 minor=$(($card * 65536 + $minor))
1188                 name=$card$unit
1189                 mknod cuac$name c $major $(($minor + 128)) uucp:dialer
1190                 mknod cuaic$name c $major $(($minor + 32 + 128)) uucp:dialer
1191                 mknod cualc$name c $major $(($minor + 64 + 128)) uucp:dialer
1192         done
1193         umask 77
1194         ;;
1195
1196 ttyc?)
1197         portlist="0 1 2 3 4 5 6 7 8 9 a b c d e f
1198                   g h i j k l m n o p q r s t u v"
1199         major=48
1200         card=`expr $i : 'tty.*\(.\)$'`
1201         for unit in $portlist
1202         do
1203                 minor=`ttyminor $unit`
1204                 minor=$(($card * 65536 + $minor))
1205                 name=$card$unit
1206                 mknod ttyc$name c $major $minor
1207                 mknod ttyic$name c $major $(($minor + 32))
1208                 mknod ttylc$name c $major $(($minor + 64))
1209         done
1210         ;;
1211
1212 # RISCom8 'rc' driver entries
1213
1214 cuam?)
1215         umask 7
1216         unit=`expr $i : 'cua.*\(.\)$'`
1217         m=`ttyminor $unit`
1218         mknod cuam$unit c 63 $(($m + 128)) uucp:dialer
1219         umask 77
1220         ;;
1221
1222 ttym?)
1223         unit=`expr $i : 'tty.*\(.\)$'`
1224         m=`ttyminor $unit`
1225         mknod ttym$unit c 63 $m
1226         ;;
1227
1228 # Specialix SI/XIO.
1229 # Note: these are 'base 1' to match the numbers on the panels, and to match
1230 #       the manual that comes with the system.
1231 ttyA*)
1232         major=68
1233         nports=`expr $i : 'ttyA\(.*\)$'`
1234         port=1
1235         while [ $port -le $nports ]; do
1236                 minor=$(($port - 1))
1237                 name=$(printf %02d $port)
1238                 mknod ttyA$name c $major $minor
1239                 mknod ttyiA$name c $major $(($minor + 65536))
1240                 mknod ttylA$name c $major $(($minor + 131072))
1241                 port=$(($port + 1))
1242         done
1243         # For the user-mode control program, 'sicontrol'
1244         mknod si_control c 68 262144
1245         ;;
1246
1247 cuaA*)
1248         umask 7
1249         major=68
1250         nports=`expr $i : 'cuaA\(.*\)$'`
1251         port=1
1252         while [ $port -le $nports ]; do
1253                 minor=$(($port - 1))
1254                 name=$(printf %02d $port)
1255                 mknod cuaA$name c $major $(($minor + 128)) uucp:dialer
1256                 mknod cuaiA$name c $major $(($minor + 128 + 65536)) \
1257                     uucp:dialer
1258                 mknod cualA$name c $major $(($minor + 128 + 131072)) \
1259                     uucp:dialer
1260                 port=$(($port + 1))
1261         done
1262         umask 77
1263         ;;
1264
1265 # Alpha AS8[24]00 (TurboLaser) console.
1266 zs?)
1267         unit=`expr $i : 'zs.*\(.\)$'`
1268         m=`ttyminor $unit`
1269         mknod zs$unit c 135 $m
1270         ;;
1271
1272 # Digiboard PC/?? 16 port card.
1273 # The current scheme of minor numbering is:
1274 #
1275 #       unused{14} CARD{2} major{8} CALLOUT{1} LOCK{1} INIT{1} PORT{5}
1276 #
1277 #   CARD bitfield in future versions may be extended to 3 bits.
1278 #
1279 # See dgb(4)
1280 #
1281 ttyD?)
1282         portlist="0 1 2 3 4 5 6 7 8 9 a b c d e f"
1283         major=58
1284         card=`expr $i : 'tty.*\(.\)$'`
1285         for unit in $portlist
1286         do
1287                 minor=`ttyminor $unit`
1288                 minor=$(($card * 65536 + $minor))
1289                 name=$card$unit
1290                 mknod ttyD$name c $major $minor
1291                 mknod ttyiD$name c $major $(($minor + 32))
1292                 mknod ttylD$name c $major $(($minor + 64))
1293         done
1294         ;;
1295
1296 cuaD?)
1297         umask 7
1298         portlist="0 1 2 3 4 5 6 7 8 9 a b c d e f"
1299         major=58
1300         card=`expr $i : 'cua.*\(.\)$'`
1301         for unit in $portlist
1302         do
1303                 minor=`ttyminor $unit`
1304                 minor=$(($card * 65536 + $minor))
1305                 name=$card$unit
1306                 mknod cuaD$name c $major $(($minor + 128)) uucp:dialer
1307                 mknod cuaiD$name c $major $(($minor + 32 + 128)) uucp:dialer
1308                 mknod cualD$name c $major $(($minor + 64 + 128)) uucp:dialer
1309         done
1310         umask 77
1311         ;;
1312
1313 # Stallion multi serial cards (stl and stli drivers)
1314
1315 # These drivers reserve 64 minor devices per board, even if the board
1316 # supports only 4 devices.  We default to creating only 8 of the 64 devices
1317 # to keep /dev from getting too large (which => slow).  The last part of the
1318 # arg is the board number to create ports for.  So:
1319 #       ttyE0 will create 8 dialin ports ttyE0-ttyE7, plus ttyiE* and ttylE*
1320 #       cuaE0 will create 8 dialout ports cuaE0-cuaE7, plus cuaiE* and cualE*
1321 #       ttyE1 will create 8 dialin ports ttyE64-ttyE71, plus ttyiE* and ttylE*
1322 #       etc
1323 # If you have EasyConnect 8/32 or 8/64 cards, you will need to change the 
1324 # definition of "maxport" below to get nodes for the full 32 or 64 
1325 # ports per card.
1326 #
1327 # Note that the mapping of minor device numbers (with the hole between
1328 # 32-64k) is a bit odd to keep compatibility with ttyd? for
1329 # lock/initial devices.  
1330 # Minor device field for the ports is
1331 #       card{3} unused{4} unit-msb{1} unused{8} callout{1} lock{1} init{1} unit-lsbs{5}
1332 # for the mem device is
1333 #       0x1000000 + card
1334 # (For stl, there is only 1 mem device per system; for stli, one per board)
1335
1336 ttyE*)
1337         stallion 72 E `expr $i : 'tty.*\(.\)$'` 0
1338         ;;
1339 cuaE*)
1340         stallion 72 E `expr $i : 'cua.*\(.\)$'` 1
1341         ;;
1342 stl*)
1343         card=`expr $i : 'stl\(.\)$'`
1344         stallion 72 E $card 0
1345         stallion 72 E $card 1
1346         ;;
1347
1348 ttyF*)
1349         stallion 75 F `expr $i : 'tty.*\(.\)$'` 0
1350         ;;
1351 cuaF*)
1352         stallion 75 F `expr $i : 'cua.*\(.\)$'` 1
1353         ;;
1354 stli*)
1355         card=`expr $i : 'stl\(.\)$'`
1356         stallion 75 F $card 0
1357         stallion 75 F $card 1
1358         ;;
1359
1360 ttyM*)
1361         portlist="0 1 2 3 4 5 6 7 8 9 a b c d e f"
1362         modulelist="a b c d"
1363         major=101
1364         card=`expr $i : 'tty.*\(.\)$'`
1365         for unit in $modulelist
1366         do
1367                 moduleminor=`ttyminor $unit`
1368                 moduleminor=$(($moduleminor % 10 * 16))
1369                 modulename=$unit
1370
1371                 for unit in $portlist
1372                 do
1373                         minor=`ttyminor $unit`
1374                         minor=$(($card * 65536 + $minor + $moduleminor))
1375                         name=$card$modulename$unit
1376                         rm -f tty*M$name
1377                         mknod ttyM$name c $major $minor
1378                         mknod ttyiM$name c $major $(($minor + 64))
1379                         mknod ttylM$name c $major $(($minor + 128))
1380                 done
1381         done
1382         ;;
1383
1384 cuaM?)
1385         umask 7
1386         portlist="0 1 2 3 4 5 6 7 8 9 a b c d e f"
1387         modulelist="a b c d"
1388         major=101
1389         card=`expr $i : 'cua.*\(.\)$'`
1390         for unit in $modulelist
1391         do
1392                 moduleminor=`ttyminor $unit`
1393                 moduleminor=$(($moduleminor % 10 * 16))
1394                 modulename=$unit
1395
1396                 for unit in $portlist
1397                 do
1398                         minor=`ttyminor $unit`
1399                         minor=$(($card * 65536 + $minor + $moduleminor))
1400                         name=$card$modulename$unit
1401                         rm -f cua*M$name
1402                         mknod cuaM$name c $major $(($minor + 262144)) \
1403                             uucp:dialer
1404                         mknod cuaiM$name c $major $(($minor + 64 + 262144)) \
1405                             uucp:dialer
1406                         mknod cualM$name c $major $(($minor + 128 + 262144)) \
1407                             uucp:dialer
1408                 done
1409         done
1410         umask 77
1411         ;;
1412
1413 ttyR?)
1414         major=81
1415         BOARD=1; Rnum=0
1416         MINOR=$(($BOARD * 65536))
1417         controllers=$(
1418                 dmesg | while read first rest; do
1419                         case "$first" in
1420                         RocketPort[0-4])
1421                                 echo "$first"
1422                                 ;;
1423                         esac
1424                 done
1425         )
1426         rm -f ttyR* ttyiR* ttylR*
1427         for i in $controllers; do
1428            ndevices=$(
1429                 dmesg | while read first bar ports rest; do
1430                         case "$first" in
1431                         $i*)
1432                                 echo "$ports"
1433                                 ;;
1434                         esac
1435                 done
1436            )
1437            echo -n "Creating $ndevices devices for $i: "
1438            dev=0
1439            while [ $dev -lt $ndevices ]; do
1440                    mknod ttyR$Rnum c $major $MINOR
1441                    mknod ttyiR$Rnum c $major $(($MINOR + 32))
1442                    mknod ttylR$Rnum c $major $(($MINOR + 64))
1443                    Rnum=$(($Rnum + 1))
1444                    MINOR=$(($MINOR + 1))
1445                    dev=$(($dev + 1))
1446            done
1447                 BOARD=$(($BOARD + 1))
1448                 MINOR=$(($BOARD * 65536))
1449            echo " "
1450         done
1451         ;;
1452
1453 cuaR?)
1454         major=81
1455         BOARD=1; Rnum=0
1456         MINOR=$(($BOARD * 65536))
1457         controllers=$(
1458                 dmesg | while read first rest; do
1459                         case "$first" in
1460                         RocketPort[0-4])
1461                                 echo "$first"
1462                                 ;;
1463                         esac
1464                 done
1465         )
1466         rm -f cuaR* cuaiR* cualR*
1467         for i in $controllers; do
1468            ndevices=$(
1469                 dmesg | while read first bar ports rest; do
1470                         case "$first" in
1471                         $i*)
1472                                 echo "$ports"
1473                                 ;;
1474                         esac
1475                 done
1476            )
1477            echo -n "Creating $ndevices devices for $i: "
1478            dev=0
1479            while [ $dev -lt $ndevices ]; do
1480                    mknod cuaR$Rnum c  $major $(($MINOR + 128)) uucp:dialer
1481                    mknod cuaiR$Rnum c $major $(($MINOR + 128 + 32)) \
1482                        uucp:dialer
1483                    mknod cualR$Rnum c $major $(($MINOR + 128 + 64)) \
1484                        uucp:dialer
1485                    Rnum=$(($Rnum + 1))
1486                    MINOR=$(($MINOR + 1))
1487                    dev=$(($dev + 1))
1488            done
1489                 BOARD=$(($BOARD + 1))
1490                 MINOR=$(($BOARD * 65536))
1491            echo " "
1492         done
1493         ;;
1494
1495 mse*)
1496         unit=`expr $i : 'mse\(.*\)'`
1497         chr=27
1498         # non-blocking for X11
1499         mknod mse$unit c $chr `unit2minor $(($unit * 2 + 1))`
1500         ;;
1501
1502 psm*)
1503         unit=`expr $i : 'psm\(.*\)'`
1504         chr=21
1505         # non-blocking for X11
1506         mknod psm$unit c $chr `unit2minor $(($unit * 2 + 1))`
1507         ;;
1508
1509 mouse*)
1510         name=`expr $i : 'mouse\(.*\)'`
1511         if [ ! -c $name ]; then
1512                 $0 $name                        # make the appropriate device
1513         fi
1514         ln -fs $name mouse
1515         ;;
1516
1517 pcaudio)
1518         mknod pcaudio c 24 0
1519         mknod pcaudioctl c 24 128
1520         ;;
1521
1522 socksys)
1523         mknod socksys c 41 0
1524         mknod spx c 41 1
1525         ln -fs socksys nfsd
1526         chmod 666 socksys nfsd spx
1527         ;;
1528
1529 snd*)
1530 #
1531 # changes from Linux voxware
1532 # minor         Linux                   FreeBSD
1533 # 8             sequencer2 (aka music0) music0
1534 # 17            patmgr0                 sequencer1
1535 # 33            patmgr1                 sequencer2
1536 #
1537
1538         unit=`expr $i : 'snd\(.*\)'`
1539         chr=30
1540
1541         # XXX write this less verbosely, like std
1542         snd_security_hole=0     # XXX
1543         umask $snd_security_hole
1544
1545         ln -fs mixer$unit mixer
1546         ln -fs sequencer$unit sequencer
1547         ln -fs dsp$unit dsp
1548         ln -fs audio$unit audio
1549         ln -fs dspW$unit dspW
1550         ln -fs music$unit music
1551         ln -fs pss$unit pss
1552         ln -fs dsp$unit.0 dsp$unit
1553         ln -fs audio$unit.0 audio$unit
1554         ln -fs dspW$unit.0 dspW$unit
1555
1556         mknod mixer$unit        c $chr `unit2minor $(($unit * 16 + 0))`
1557         mknod sequencer$unit    c $chr `unit2minor $(($unit * 16 + 1))`
1558         mknod midi$unit         c $chr `unit2minor $(($unit * 16 + 2))`
1559
1560         for chn in 0 1 2 3
1561         do
1562                 minor=$(($chn * 65536 + $unit * 16))
1563                 mknod dsp$unit.$chn     c $chr $(($minor + 3))
1564                 mknod audio$unit.$chn   c $chr $(($minor + 4))
1565                 mknod dspW$unit.$chn    c $chr $(($minor + 5))
1566         done
1567
1568         mknod sndstat           c $chr 6
1569                                 # minor number 7 is unused
1570         mknod music$unit        c $chr `unit2minor $(($unit * 16 + 8))`
1571         mknod pss$unit          c $chr `unit2minor $(($unit * 16 + 9))`
1572                                 # minor numbers 10-15 are unused
1573         umask 77
1574         ;;
1575
1576 vat)
1577         mknod vatio c 25 128
1578         chmod 660 vatio
1579         ;;
1580
1581 gsc*)
1582         unit=`expr $i : 'gsc\(.*\)'`
1583         mknod gsc${unit} c 47 `unit2minor $unit`
1584         mknod gsc${unit}p c 47 `unit2minor $(($unit + 8))`
1585         mknod gsc${unit}d c 47 `unit2minor $(($unit + 32))`
1586         mknod gsc${unit}pd c 47 `unit2minor $(($unit + 40))`
1587         chmod 666 gsc${unit}*
1588         ;;
1589
1590 acpi)
1591         mknod acpi c 152 0 root:operator
1592         chmod 664 acpi
1593         ;;
1594 apm)
1595         mknod apm c 39 0 root:operator
1596         chmod 664 apm
1597         ;;
1598
1599 apmctl)
1600         mknod apmctl c 39 8 root:operator
1601         chmod 660 apmctl
1602         ;;
1603
1604 card*)
1605         unit=`expr $i : 'card\(.*\)'`
1606         chr=50
1607         mknod card$unit c $chr `unit2minor $unit`
1608         chmod 644 card$unit
1609         ;;
1610
1611 ttyx?|ttyy?|ttyz?)
1612         case $i in
1613         *0) unit=0;;    *1) unit=1;;    *2) unit=2;;    *3) unit=3;;
1614         *4) unit=4;;    *5) unit=5;;    *6) unit=6;;    *7) unit=7;;
1615         *8) unit=8;;    *9) unit=9;;    *a) unit=10;;   *b) unit=11;;
1616         *c) unit=12;;   *d) unit=13;;   *e) unit=14;;   *f) unit=15;;
1617         esac
1618         case $i in
1619         ttyy?)  unit=$(($unit + 16));;
1620         ttyz?)  unit=$(($unit + 32));;
1621         esac
1622         mknod $i c 42 $unit
1623         ;;
1624
1625 cronyx)
1626         mknod cronyx c 42 63
1627         ;;
1628
1629 joy)
1630         mknod joy0 c 51 0 root:operator
1631         mknod joy1 c 51 1 root:operator
1632         chmod 640  joy0 joy1
1633         ;;
1634
1635 spigot)
1636         mknod spigot c 11 0
1637         chmod 444 spigot
1638         ;;
1639
1640 ctx?)
1641         unit=`expr $i : 'ctx\(.*\)'`
1642         mknod ctx$unit c 40 `unit2minor $unit`
1643         chmod 444 ctx$unit
1644         ;;
1645
1646 meteor?)
1647         unit=`expr $i : 'meteor\(.*\)'`
1648         mknod meteor$unit c 67 `unit2minor $unit`
1649         chmod 444 meteor$unit
1650         ;;
1651
1652 bktr?)
1653         unit=`expr $i : 'bktr\(.*\)'`
1654         mknod bktr$unit c 92 `unit2minor $unit`
1655         mknod tuner$unit c 92 `unit2minor $((16 + $unit))`
1656         mknod vbi$unit c 92 `unit2minor $((32 + $unit))`
1657         chmod 444 bktr$unit tuner$unit vbi$unit
1658         ;;
1659
1660 tun*)
1661         ntun=`expr $i : 'tun\(.*\)$'`
1662         unit=0
1663         while [ $unit -le $ntun ]; do
1664                 mknod tun$unit c 52 `unit2minor $unit`
1665                 unit=$(($unit + 1))
1666         done
1667         ;;
1668
1669 tap*)
1670         ntap=`expr $i : 'tap\(.*\)$'`
1671         unit=0
1672         while [ $unit -le $ntap ]; do
1673                 mknod tap$unit c 149 `unit2minor $unit` root:network
1674                 unit=$(($unit + 1))
1675         done
1676         ;;
1677
1678 sysmouse)
1679         mknod sysmouse c 12 128
1680         mknod consolectl c 12 255
1681         ;;
1682
1683 jogdial)
1684         mknod jogdial c 160 0
1685         ;;
1686
1687 snp?)
1688         unit=`expr $i : 'snp\(.*\)'`
1689         mknod snp$unit c 53 `unit2minor $unit`
1690         ;;
1691
1692 # dufault@hda.com: If I do much more work on other A-D boards
1693 # then eventually we'll have a "ad" and "dio" interface and some of these
1694 # "labpcaio" ones will be gone.
1695 # labpcaio: D-A and A-D.
1696 # labpcdio: Digital in and Digital out.
1697 #
1698 labpc*)
1699         umask 7
1700         case $i in
1701         labpcaio*)
1702                 name=labpcaio
1703                 unit=`expr $i : 'labpcaio\(.*\)'`
1704                 all="0 1 2 3 4 5 6 7"
1705                 offset=0
1706                 ;;
1707         labpcdio*)
1708                 name=labpcdio
1709                 unit=`expr $i : 'labpcdio\(.*\)'`
1710                 all="0 1 2 3"
1711                 offset=8
1712                 ;;
1713         *)
1714                 die 3 "Don't know LabPC type $i"
1715                 ;;
1716         esac
1717         if [ -z "${unit}" ]; then
1718                 unit=all
1719         fi
1720         case $unit in
1721                 0|1|2|3|4|5|6|7)
1722                                 mknod $name$unit c 66 $(($offset + $unit))
1723                 ;;
1724                 all)
1725                         for i in $all
1726                         do
1727                                 mknod $name$i c 66 $(($offset + $i))
1728                         done
1729                         ;;
1730                 *)
1731                         echo "No such LabPC unit: $unit"
1732                         ;;
1733         esac
1734         umask 77
1735         ;;
1736
1737 perfmon)
1738         mknod perfmon c 2 32 root:kmem
1739         chmod 640 perfmon
1740         ;;
1741
1742 ipl)
1743         mknod ipl c 79 0
1744         mknod ipnat c 79 1
1745         mknod ipstate c 79 2
1746         mknod ipauth c 79 3
1747         ;;
1748
1749 elan*)
1750         mknod elan-mmcr c 100 0 # XXX local major
1751         chmod 600 elan-mmcr
1752         ;;
1753
1754 kbd*)
1755         unit=`expr $i : 'kbd\(.*\)'`
1756         chr=112
1757         mknod kbd$unit c $chr `unit2minor $unit`
1758         ;;
1759
1760 i4b)
1761         mknod i4b c 60 0
1762         ;;
1763
1764 i4bctl)
1765         mknod i4bctl c 55 0
1766         ;;
1767
1768 i4brbch*)
1769         unit=`expr $i : 'i4brbch\(.*\)'`
1770         mknod i4brbch$unit c 57 `unit2minor $unit`
1771         ;;
1772
1773 i4bteld*)
1774         offset=64
1775         unit=`expr $i : 'i4bteld\(.*\)'`
1776         mknod i4bteld$unit c 56 `unit2minor $(($offset + $unit))`
1777         ;;
1778
1779 i4btel*)
1780         unit=`expr $i : 'i4btel\(.*\)'`
1781         mknod i4btel$unit c 56 `unit2minor $unit`
1782         ;;
1783
1784 i4btrc*)
1785         unit=`expr $i : 'i4btrc\(.*\)'`
1786         mknod i4btrc$unit c 59 `unit2minor $unit`
1787         ;;
1788
1789 aac*)
1790         unit=`expr $i : 'aac\(.*\)'`
1791         mknod aac$unit c 150 `unit2minor $unit`
1792         ln -fs aac$unit afa$unit
1793         ln -fs aac$unit hpn$unit
1794         ;;
1795
1796 mlx*)
1797         unit=`expr $i : 'mlx\(.*\)'`
1798         mknod mlx$unit c 130 `unit2minor $unit`
1799         ;;
1800
1801 amr*)
1802         unit=`expr $i : 'amr\(.*\)'`
1803         mknod amr$unit c 132 `unit2minor $unit`
1804         ;;
1805
1806 ips*)
1807         unit=`expr $i : 'ips\(.*\)'`
1808         mknod mlx$unit c 175 `unit2minor $unit`
1809         ;;
1810
1811 ciss*)
1812         unit=`expr $i : 'ciss\(.*\)'`
1813         mknod ciss$unit c 166 `unit2minor $unit`
1814         ;;
1815
1816 agpgart)
1817         mknod agpgart c 148 0
1818         ;;
1819
1820 twe*)
1821         unit=`expr $i : 'twe\(.*\)'`
1822         mknod twe$unit c 146 `unit2minor $unit`
1823         ;;
1824
1825 tw*)
1826         unit=`expr $i : 'tw\(.*\)'`
1827         mknod tw$unit c 19 `unit2minor $unit` root:operator
1828         ;;
1829
1830 cfs*)
1831         unit=`expr $i : 'cfs\(.*\)'`
1832         mknod cfs$unit c 93 $unit root:operator
1833         ;;
1834
1835 nsmb*)
1836         unit=`expr $i : 'nsmb\(.*\)'`
1837         mknod nsmb$unit c 144 $unit
1838         ;;
1839
1840 local)
1841         umask 0                 # XXX should be elsewhere
1842         sh MAKEDEV.local
1843         umask 77
1844         ;;
1845
1846 *)
1847         echo $i - no such device name
1848         ;;
1849
1850 esac
1851 done