1 #!/bin/sh - 2 # $NetBSD: MAKEDEV.tmpl,v 1.239 2026/06/27 19:58:26 riastradh Exp $ 3 # 4 # Copyright (c) 2003,2007,2008 The NetBSD Foundation, Inc. 5 # All rights reserved. 6 # 7 # Redistribution and use in source and binary forms, with or without 8 # modification, are permitted provided that the following conditions 9 # are met: 10 # 1. Redistributions of source code must retain the above copyright 11 # notice, this list of conditions and the following disclaimer. 12 # 2. Redistributions in binary form must reproduce the above copyright 13 # notice, this list of conditions and the following disclaimer in the 14 # documentation and/or other materials provided with the distribution. 15 # 16 # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 17 # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 18 # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 19 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 20 # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 # POSSIBILITY OF SUCH DAMAGE. 27 # 28 # 29 ########################################################################### 30 # 31 # PLEASE RUN "cd ../share/man/man8 ; make makedevs" 32 # AFTER CHANGING THIS FILE, AND COMMIT THE UPDATED MANPAGE! 33 # 34 ########################################################################### 35 # 36 # Device "make" file. Valid special arguments: 37 # all makes all known devices, including local devices. 38 # Tries to make the 'standard' number of each type. 39 # init A set of devices that is used for MFS /dev by init. 40 # May be equal to "all". 41 # floppy devices to be put on install floppies 42 # ramdisk devices to be put into INSTALL kernel ramdisks. 43 # std standard devices 44 # local configuration specific devices 45 # lua Lua device 46 # wscons make wscons devices 47 # usbs make USB devices 48 # virtio virtio(4)-related devices 49 # 50 # Tapes: 51 # st* SCSI tapes 52 # wt* QIC-interfaced (e.g. not SCSI) 3M cartridge tape 53 # ht* MASSBUS TM03 and TU?? 54 # mt* MSCP tapes (e.g. TU81, TK50) 55 # tm* UNIBUS TM11 and TE10 emulations (e.g. Emulex TC-11) 56 # ts* UNIBUS TS11 57 # ut* UNIBUS TU45 emulations (e.g. si 9700) 58 # uu* TU58 cassettes on DL11 controller 59 # 60 # Disks: 61 # dk* wedge disk slices 62 # ccd* concatenated disk devices 63 # cd* SCSI or ATAPI CD-ROM 64 # cgd* cryptographic disk devices 65 # raid* RAIDframe disk devices 66 # sd* SCSI disks 67 # wd* "winchester" disk drives (ST506,IDE,ESDI,RLL,...) 68 # bmd* Nereid bank memory disks 69 # ed* IBM PS/2 ESDI disk devices 70 # fd* "floppy" disk drives (3 1/2", 5 1/4") 71 # fss* Files system snapshot devices 72 # gdrom* Dreamcast "gigadisc" CD-ROM drive 73 # hk* UNIBUS RK06 and RK07 74 # hp* MASSBUS RM?? 75 # ld* Logical disk devices (e.g., hardware RAID) 76 # mcd* Mitsumi CD-ROM 77 # md* memory pseudo-disk devices 78 # ofdisk* OpenFirmware disk devices 79 # ra* MSCP disks (RA??, RD??) 80 # rb* 730 IDC w/ RB80 and/or RB02 81 # rd* HDC9224 RD disks on VS2000 82 # rl* UNIBUS RL02 83 # rx* MSCP floppy disk (RX33/50/...) 84 # up* other UNIBUS devices (e.g. on Emulex SC-21V controller) 85 # vnd* "file" pseudo-disks 86 # xbd* Xen virtual disks 87 # xd* Xylogic 753/7053 disks 88 # xy* Xylogic 450/451 disks 89 # 90 # Pointing devices: 91 # wsmouse* wscons mouse events 92 # lms* Logitech bus mouse 93 # mms* Microsoft bus mouse 94 # qms* "quadrature mouse" 95 # pms* PS/2 mouse 96 # mouse mouse (provides events, for X11) 97 # 98 # Keyboard devices: 99 # wskbd* wscons keyboard events 100 # kbd raw keyboard (provides events, for X11) 101 # kbdctl keyboard control 102 # 103 # Terminals/Console ports: 104 # tty[01]* standard serial ports 105 # tty0* SB1250 ("sbscn") serial ports (sbmips) 106 # ttyE* wscons - Workstation console ("wscons") glass-tty emulators 107 # ttyCZ? Cyclades-Z multiport serial boards. Each "unit" 108 # makes 64 ports. 109 # ttyCY? Cyclom-Y multiport serial boards. Each "unit" makes 110 # 32 ports. 111 # ttye* ITE bitmapped consoles 112 # ttyv0 pccons 113 # ttyC? NS16550 ("com") serial ports 114 # ttyS* SA1110 serial port (hpcarm) 115 # ttyTX? TX39 internal serial ports (hpcmips) 116 # ttyB? DEC 3000 ZS8530 ("scc") serial ports (alpha) 117 # ttyA* mfc serial ports (amiga) 118 # ttyB* msc serial ports (amiga) 119 # ttyC* com style serial ports (DraCo, HyperCom) (amiga) 120 # On the DraCo, units 0 and 1 are the built-in "modem" and 121 # "mouse" ports, if configured. 122 # ttyA0 8530 Channel A (formerly ser02) (atari) 123 # ttyA1 8530 Channel B (formerly mdm02) (atari) 124 # ttyB0 UART on first 68901 (formerly mdm01) (atari) 125 # ixpcom IXP12x0 COM ports 126 # epcom EP93xx COM ports 127 # plcom ARM PL01[01] serial ports 128 # wmcom EPOC Windermere COM ports 129 # ttyM? HP200/300 4 port serial mux interface (hp300) 130 # ttya "ttya" system console (luna68k) 131 # ttyb second system serial port (luna68k) 132 # tty* Onboard serial ports (mvme68k) 133 # On the mvme147 these are: ttyZ1, ttyZ2 and ttyZ3. 134 # On the mvme167, and '177: ttyC1, ttyC2 and ttyC3. 135 # Note that tty[CZ]0 is grabbed by the console device 136 # so is not created by default 137 # dc* PMAX 4 channel serial interface (kbd, mouse, modem, printer) 138 # scc* 82530 serial interface (pmax) 139 # ttyZ* Zilog 8530 ("zstty") serial ports 140 # tty[abcd] Built-in serial ports (sparc) 141 # tty* Z88530 serial controllers (sparc64) 142 # ttyh* SAB82532 serial controllers (sparc64) 143 # tty[a-j] Built-in serial ports (sun2, sun3) 144 # ttyC? pccons (arc) 145 # dz* UNIBUS DZ11 and DZ32 (vax) 146 # dh* UNIBUS DH11 and emulations (e.g. Able DMAX, Emulex CS-11) (vax) 147 # dmf* UNIBUS DMF32 (vax) 148 # dhu* UNIBUS DHU11 (vax) 149 # dmz* UNIBUS DMZ32 (vax) 150 # dl* UNIBUS DL11 (vax) 151 # xencons Xen virtual console 152 # ttyVI?? viocon(4) 153 # 154 # Terminal multiplexors: 155 # dc* 4 channel serial interface (keyboard, mouse, modem, printer) 156 # dh* UNIBUS DH11 and emulations (e.g. Able DMAX, Emulex CS-11) 157 # dhu* UNIBUS DHU11 158 # dl* UNIBUS DL11 159 # dmf* UNIBUS DMF32 160 # dmz* UNIBUS DMZ32 161 # dz* UNIBUS DZ11 and DZ32 162 # scc* 82530 serial interface 163 # 164 # Call units: 165 # dn* UNIBUS DN11 and emulations (e.g. Able Quadracall) 166 # 167 # Pseudo terminals: 168 # ptm pty multiplexor device, and pts directory 169 # pty* set of 16 master and slave pseudo terminals 170 # opty first 16 ptys, to save inodes on install media 171 # ipty first 2 ptys, for install media use only 172 # 173 # Printers: 174 # arcpp* Archimedes parallel port 175 # lpt* stock lp 176 # lpa* interruptless lp 177 # par* Amiga motherboard parallel port 178 # cpi* Macintosh Nubus CSI parallel printer card 179 # 180 # USB devices: 181 # usb* USB control devices 182 # uhid* USB generic HID devices 183 # ulpt* USB printer devices 184 # ugen* USB generic devices 185 # ttyHS* USB Option N.V. modems 186 # ttyU* USB modems 187 # ttyY* USB serial adapters 188 # 189 # Video devices: 190 # bwtwo* monochromatic frame buffer 191 # cgtwo* 8-bit color frame buffer 192 # cgthree* 8-bit color frame buffer 193 # cgfour* 8-bit color frame buffer 194 # cgsix* accelerated 8-bit color frame buffer 195 # cgeight* 24-bit color frame buffer 196 # etvme Tseng et-compatible cards on VME (atari) 197 # ik* UNIBUS interface to Ikonas frame buffer 198 # leo Circad Leonardo VME-bus true color (atari) 199 # ps* UNIBUS interface to Picture System 2 200 # qv* QVSS (MicroVAX) display 201 # tcx* accelerated 8/24-bit color frame buffer 202 # 203 # Maple bus devices: 204 # maple Maple bus control devices 205 # mlcd* Maple bus LCD devices 206 # mmem* Maple bus storage devices 207 # 208 # IEEE1394 bus devices: 209 # fw* IEEE1394 bus generic node access devices 210 # fwmem* IEEE1394 bus physical memory of the remote node access devices 211 # 212 # Special purpose devices: 213 # ad* UNIBUS interface to Data Translation A/D converter 214 # agp* AGP GART devices 215 # altq ALTQ control interface 216 # amr* AMI MegaRaid control device 217 # apm power management device 218 # audio* audio devices 219 # bell* OPM bell device (x68k) 220 # bktr Brooktree 848/849/878/879 based TV cards 221 # bpf packet filter 222 # bthub Bluetooth Device Hub control interface 223 # cfs* Coda file system device 224 # ch* SCSI media changer 225 # cir* Consumer IR 226 # clockctl clock control for non root users 227 # cpuctl CPU control 228 # crypto hardware crypto access driver 229 # dmoverio hardware-assisted data movers 230 # dpt* DPT/Adaptec EATA RAID management interface 231 # dpti* DPT/Adaptec I2O RAID management interface 232 # drm* Direct Rendering Manager interface 233 # dtv* Digital TV interface 234 # fb* PMAX generic framebuffer pseudo-device 235 # fd file descriptors 236 # gpioirq* Interrupts on GPIO pins 237 # gpiopps* 1PPS signals on GPIO pins 238 # grf* graphics frame buffer device 239 # hdaudio* High Definition audio control device 240 # hdmicec* HDMI CEC devices 241 # hil HP300 HIL input devices 242 # icp ICP-Vortex/Intel RAID control interface 243 # iic* IIC bus device 244 # io x86 IOPL access for COMPAT_10, COMPAT_FREEBSD 245 # iop* I2O IOP control interface 246 # ipmi* OpenIPMI compatible interface 247 # ipl IP Filter 248 # irframe* IrDA physical frame 249 # ite* terminal emulator interface to HP300 graphics devices 250 # joy* joystick device 251 # kttcp kernel ttcp helper device 252 # lockstat kernel locking statistics 253 # magma* Magma multiport serial/parallel cards 254 # midi* MIDI 255 # mfi* LSI MegaRAID/MegaSAS control interface 256 # mlx* Mylex DAC960 control interface 257 # mly* Mylex AcceleRAID/eXtremeRAID control interface 258 # np* UNIBUS Ethernet co-processor interface, for downloading. 259 # npf NPF packet filter 260 # nvme* Non-Volatile Memory Host Controller Interface device driver 261 # nvme*ns* Non-Volatile Memory namespace 262 # nvmm NetBSD Virtual Machine Monitor 263 # openfirm OpenFirmware accessor 264 # pad* Pseudo-audio device driver 265 # pci* PCI bus access devices 266 # pf PF packet filter 267 # putter Pass-to-Userspace Transporter 268 # px* PixelStamp Xserver access 269 # qemufwcfg* QEMU Firmware Configuration 270 # radio* radio devices 271 # random Random number generator 272 # rtc* RealTimeClock 273 # scmd* Sparkfun Serial Controlled Motor Driver 274 # scsibus* SCSI busses 275 # se* SCSI Ethernet 276 # ses* SES/SAF-TE SCSI Devices 277 # sht3xtemp* Sensirion SHT3X temperature and humidity device driver 278 # speaker PC speaker (XXX - installed) 279 # spi* SPI bus device 280 # sram battery backuped memory (x68k) 281 # srt* source-address based routing 282 # ss* SCSI scanner 283 # stic* PixelStamp interface chip 284 # sysmon System Monitoring hardware 285 # tap* virtual Ethernet device 286 # tprof task profiler 287 # tun* network tunnel driver 288 # twa 3ware Apache control interface 289 # twe 3ware Escalade control interface 290 # uk* unknown SCSI device 291 # veriexec Veriexec fingerprint loader 292 # vhci virtual host controller interface 293 # video* video capture devices 294 # view* generic interface to graphic displays (Amiga) 295 # wsfont* console font control 296 # wsmux* wscons event multiplexor 297 # xenevt Xen event interface 298 # 299 # iSCSI communication devices 300 # iscsi* iSCSI driver and /sbin/iscsid communication 301 # 302 # Trusted Computing devices 303 # tpm Trusted Platform Module 304 # 305 # Debugging and tracing 306 # dtrace Dynamic tracing framework 307 308 309 # 310 # NOTE: 311 # 312 # * MAKEDEV is used both as a standalone script (via "sh ./MAKEDEV 313 # all" or similar), and as a function library for MAKEDEV.local (via 314 # "MAKEDEV_AS_LIBRARY=1 . MAKEDEV"). Because of this, the script 315 # should consist almost entirely of function definitions, apart from a 316 # few lines right at the end. 317 # 318 # * MAKEDEV may be executed in an environment that is missing some 319 # common commands. For example, it may be executed from a minimal 320 # system used during installation, or it may be executed early in the 321 # boot sequence before most file systems have been mounted. It may 322 # also be executed in a cross-build environment on a non-NetBSD host. 323 # 324 325 usage() 326 { 327 cat 1>&2 << _USAGE_ 328 Usage: ${0##*/} [-fMsu] [-m mknod] [-p pax] [-t mtree] special [...] 329 Create listed special devices. Options: 330 -f Force permissions to be updated on existing devices. 331 -M Create memory file system. 332 -m mknod Name of mknod(8) program. [\$TOOL_MKNOD or mknod] 333 -p pax Name of pax(1) program. [\$TOOL_PAX or pax] 334 -s Generate mtree(8) specfile instead of creating devices. 335 -t mtree Name of mtree(8) program. [\$TOOL_MTREE or mtree] 336 -u Don't re-create devices that already exist. 337 338 _USAGE_ 339 exit 1 340 } 341 342 # zeropad width number 343 # display number with a zero (`0') padding of width digits. 344 # 345 zeropad() 346 { 347 case $(($1 - ${#2})) in 348 5) echo 00000$2;; 349 4) echo 0000$2;; 350 3) echo 000$2;; 351 2) echo 00$2;; 352 1) echo 0$2;; 353 0) echo $2;; 354 *) die "bad padding" ;; 355 esac 356 } 357 358 # hexprint number 359 # display (base10) number as hexadecimal 360 # 361 hexprint() 362 { 363 val="$(($1 + 0))" 364 hex= 365 set -- 0 1 2 3 4 5 6 7 8 9 a b c d e f 366 while [ "$val" -gt 0 ]; do 367 eval hex=\${$(($val % 16 + 1))}\$hex 368 val="$(($val / 16))" 369 done 370 echo "${hex:-0}" 371 } 372 373 # linecount multiline_string 374 # count the number of lines in the string 375 # 376 linecount() 377 { 378 local IFS=' 379 ' # just a newline, no other white space between the quotes 380 set -- $1 381 echo $# 382 } 383 384 # nooutput -12 cmd [args...] 385 # run a command with stdout and/or stderr ignored. 386 # "nooutput -1 cmd" is like "cmd >/dev/null"; 387 # "nooutput -2 cmd" is like "{ cmd ; } 2>/dev/null"; 388 # "nooutput -12 cmd" is like "{ cmd ; } >/dev/null 2>&1"; 389 # except they should work even if /dev/null doesn't [yet] exist. 390 # 391 # The "{...}" wrapper used in cases where stderr is redirected 392 # serves to capture shell error messages such as "cmd: not found". 393 # 394 nooutput() 395 { 396 local flags="$1" ; shift 397 local junk 398 case "$flags" in 399 "-1") junk="$( "$@" )" ;; 400 "-2") ( exec 4>&1 ; junk="$( { "$@" ; } 2>&1 1>&4 )" ) ;; 401 "-12") junk="$( { "$@" ; } 2>&1 )" ;; 402 *) warn "Incorrect use of nooutput" ;; 403 esac 404 } 405 406 # check_pax path_to_pax 407 # Check whether pax exists and supports the command line options 408 # and input format that we will want to use. 409 # 410 check_pax() 411 { 412 local pax="$1" 413 echo ". type=dir optional" | nooutput -12 "${pax}" -r -w -M -pe . 414 } 415 416 # check_mtree path_to_mtree 417 # Check whether mtree exists and supports the command line options 418 # and input format that we will want to use. 419 # 420 check_mtree() 421 { 422 local mtree="$1" 423 echo ". type=dir optional" | nooutput -12 "${mtree}" -e -U 424 } 425 426 # setup args... 427 # Parse command line arguments, exit on error. 428 # Callers should shift $((OPTIND - 1)) afterwards. 429 # 430 setup() 431 { 432 PATH=/sbin:/usr/sbin:/bin:/usr/bin:/rescue 433 434 : ${HOST_SH:=sh} 435 : ${TOOL_MKNOD:=mknod} 436 : ${TOOL_MTREE:=mtree} 437 : ${TOOL_PAX:=pax} 438 status=0 439 do_create_mfs=false 440 do_force=false 441 do_mknod=false 442 do_pax=false 443 do_mtree=false 444 do_redirect=false 445 do_specfile=false 446 do_update=false 447 opts= 448 while getopts Mfm:p:st:u ch; do 449 # Note that $opts is only for options passed through to 450 # MAKEDEV.local, not for all options. 451 case ${ch} in 452 M) 453 # "-M" sets do_create_mfs; 454 # "-M -M" is for use from init(8), and sets do_redirect 455 do_redirect=$do_create_mfs 456 do_create_mfs=true 457 ;; 458 f) do_force=true 459 opts="${opts} -f" 460 ;; 461 m) TOOL_MKNOD=${OPTARG} 462 do_mknod=true 463 opts="${opts} -m ${OPTARG}" 464 ;; 465 p) TOOL_PAX="${OPTARG}" 466 if check_pax "${TOOL_PAX}"; then 467 do_pax=true 468 # do not add this to $opts; we will later 469 # add "-s" instead. 470 else 471 warn "Ignored -p option:" \ 472 "${TOOL_PAX} is missing or broken" 473 do_mknod=true 474 fi 475 ;; 476 s) do_specfile=true 477 opts="${opts} -s" 478 ;; 479 t) TOOL_MTREE="${OPTARG}" 480 if check_mtree "${TOOL_MTREE}"; then 481 do_mtree=true 482 # do not add this to $opts; we will later 483 # add "-s" instead. 484 else 485 warn "Ignored -t option:" \ 486 "${TOOL_MTREE} is missing or broken" 487 do_mknod=true 488 fi 489 ;; 490 u) 491 do_update=true 492 opts="${opts} -u" 493 ;; 494 *) usage ;; 495 esac 496 done 497 498 shift $((${OPTIND} - 1)) 499 [ $# -gt 0 ] || usage 500 501 u_root="%uid_root%" 502 u_uucp="%uid_uucp%" 503 g_gpio="%gid__gpio%" 504 g_kmem="%gid_kmem%" 505 g_ntpd="%gid_ntpd%" 506 g_nvmm="%gid_nvmm%" 507 g_operator="%gid_operator%" 508 g_wheel="%gid_wheel%" 509 dialin=0 510 dialout=524288 511 callunit=262144 512 513 # only allow read&write for owner by default 514 umask 077 515 516 # Set fdesc_mounted=true if the fdesc file system is mounted 517 # on the current directory (typically "/dev"). 518 # Later, this will be used to suppress creation of device nodes 519 # that are supplied by the fdesc file system. 520 # 521 fdesc_mounted=false 522 if [ -d fd ]; then 523 # Parse the output from "mount -u -o nosuchoption .". 524 # We don't parse the output from df(1) because that's 525 # less likely to be available on install media. 526 # 527 # If the current directory is a mount point for the 528 # fdesc file system, then the expected output (whether 529 # or not the current user is root) is: 530 # mount_fdesc: -o suchoption: option not supported. 531 # 532 # If the current directory is not a mount point, then 533 # the expected output is: 534 # mount: .: unknown special file or file system. 535 # 536 # If we are not running on NetBSD, or mount(8) is not 537 # found, then we should get some other error message. 538 # 539 case "$({ LC_ALL=C mount -u -o nosuchoption . ; } 2>&1)" in 540 *mount_fdesc*) fdesc_mounted=true ;; 541 esac 542 fi 543 544 # do_force requires mknod 545 if $do_force; then 546 if $do_mtree || $do_pax || $do_specfile; then 547 die "-f option works only with mknod" 548 fi 549 do_mknod=true 550 fi 551 552 # do_force and do_update do not work together 553 if $do_force && $do_update; then 554 die "-f and -u options do not work together" 555 fi 556 557 # If no explicit method was specified on the command line or 558 # forced above, then use one of mtree, pax, or mknod, in that 559 # order of preference. 560 # 561 # mtree is preferred because it's fast and designed for the 562 # purpose. However, it's unlikely to be available early in the 563 # boot sequence, when init(8) may invoke MAKEDEV(8). 564 # 565 # pax is usually acceptable, and it's likely to be available 566 # early in the boot sequence. However, it's much slower than mtree. 567 # 568 # mknod is just very slow, because the shell has to fork for 569 # each device node. 570 # 571 572 case ",${do_mtree},,${do_pax},,${do_mknod},,${do_specfile}," in 573 ( ,false,,false,,false,,false, ) 574 if check_mtree "${TOOL_MTREE}"; then 575 do_mtree=true 576 elif check_pax "${TOOL_PAX}"; then 577 do_pax=true 578 else 579 do_mknod=true 580 fi 581 ;; 582 ( *,true,*,true,* ) 583 die "-m, -p, -s, and -t options are mutually exclusive" 584 ;; 585 esac 586 587 # If we are using mknod, then decide what options to pass it. 588 MKNOD="${TOOL_MKNOD:-mknod} -F netbsd" 589 if $do_mknod; then 590 if $do_force; then 591 MKNOD="${MKNOD} -R" 592 else 593 MKNOD="${MKNOD} -r" 594 fi 595 fi 596 597 # do_mtree or do_pax internally implies do_specfile. 598 # This happens after checking for mutually-exclusive options. 599 if $do_mtree || $do_pax && ! $do_specfile; then 600 do_specfile=true 601 opts="${opts} -s" 602 fi 603 } 604 605 # specfile_before 606 # This is called before the bulk of the makedev processing, 607 # if do_specfile is set. 608 # 609 # It simply prints ". type=dir optional", which must be the 610 # first line of the specfile. 611 # 612 specfile_before() 613 { 614 echo ". type=dir optional" 615 } 616 617 # mtree_after 618 # Output in specfile format is piped into this function. 619 # 620 # It uses mtree to create the devices defined in the specfile. 621 # 622 mtree_after() 623 { 624 nooutput -1 "${TOOL_MTREE}" -e -U 625 } 626 627 # pax_after 628 # Output in specfile format is piped into this function. 629 # 630 # It uses pax to create the devices defined in the specfile. 631 # 632 pax_after() 633 { 634 # Run pax in an empty directory, so it pays 635 # attention only to the specfile, without being 636 # confused by the existing contents of the target 637 # directory. Without this, pax would complain "file 638 # would overwrite itself" for already-existing 639 # device nodes. 640 tmpdir=./tmp.$$ 641 mkdir "${tmpdir}" || die "can't create temporary directory" 642 cd "${tmpdir}" || die "can't cd to temporary directory" 643 "${TOOL_PAX}" -r -w -M -pe .. 644 pax_status=$? 645 cd .. # back to where we started 646 rmdir "${tmpdir}" 647 return $pax_status 648 } 649 650 # makedev_main makedev_name args... 651 # Perform most of the work of the main program. makedev_name 652 # is typically "makedev", but may be the name of some other 653 # makedev-like function (if we are invoked from MAKEDEV.local or 654 # some other script). The other args to this function are the 655 # command line args with which the MAKEDEV (or MAKEDEV.local) 656 # script was invoked. 657 # 658 makedev_main() 659 { 660 local makedev="$1" ; shift 661 662 # Parse command line args 663 setup ${1+"$@"} 664 shift $((${OPTIND}-1)) 665 666 if $do_create_mfs; then 667 # Count inodes and create mfs file system. 668 # The makedev call merely updates $count_nodes. 669 count_nodes=0 670 $makedev ${1+"$@"} 671 create_mfs_dev $count_nodes 672 unset count_nodes 673 fi 674 675 # Set before, middle, and after variables, so we can do 676 # something like "( $before && $middle ) | $after", 677 # except it will have to be more complex so we can capture 678 # the exit status from both sides of the pipe. 679 # 680 if $do_specfile; then 681 before=specfile_before 682 else 683 before=: 684 fi 685 middle='$makedev ${1+"$@"} && (exit $status)' 686 if $do_mtree; then 687 after=mtree_after 688 elif $do_pax ; then 689 after=pax_after 690 else 691 after=cat 692 fi 693 694 # Actually perform the "{ $before && $middle } | $after" commands. 695 # 696 # We go to some trouble to ensure that, if any of 697 # $before, $middle, or $after fails, then we also 698 # exit with a non-zero status. 699 # 700 # In the block below, fd 3 is a copy of the original stdout, 701 # and fd 4 goes to a subshell that analyses the exit status 702 # status from the other commands. 703 # 704 { 705 exec 3>&1; 706 { 707 { eval "$before" && eval "$middle"; echo $? >&4; } \ 708 | { eval "$after"; echo $? >&4; } \ 709 } 4>&1 1>&3 \ 710 | ( 711 read status1; 712 read status2; 713 case "$status1,$status2" in 714 0,0) exit 0;; 715 0,*) exit $status2;; 716 *,*) exit $status1;; 717 esac 718 ) 719 } 720 } 721 722 # 723 # functions available to create nodes: 724 # 725 # mkdev name [b|c] major minor [mode{=600} [gid{=0} [uid{=0}]]] 726 # create device node `name' with the appropriate permissions 727 # 728 # lndev src target 729 # create a symlink from src to target 730 # 731 # makedir dir mode 732 # create directory with appropriate mode 733 # 734 735 mkdev() 736 { 737 if [ -n "$count_nodes" ]; then 738 count_nodes=$((count_nodes + 1)) 739 return 740 fi 741 if $do_update && test -e $1; then 742 return 743 fi 744 if $do_specfile; then 745 case $2 in 746 b) type=block ;; 747 c) type=char ;; 748 esac 749 echo "./$1 type=${type} device=netbsd,$3,$4 mode=${5:-600} gid=${6:-$g_wheel} uid=${7:-$u_root}" 750 else 751 ${MKNOD} -m ${5:-600} -g \#${6:-$g_wheel} -u \#${7:-$u_root} $1 $2 $3 $4 752 fi 753 } 754 755 lndev() 756 { 757 if [ -n "$count_nodes" ]; then 758 count_nodes=$((count_nodes + 1)) 759 return 760 fi 761 if $do_update && test -e $2; then 762 return 763 fi 764 if $do_specfile; then 765 echo "./$2 type=link link=$1 mode=0700 gid=$g_wheel uid=$u_root" 766 else 767 ln -f -s $1 $2 768 fi 769 } 770 771 makedir() 772 { 773 if [ -n "$count_nodes" ]; then 774 count_nodes=$((count_nodes + 1)) 775 return 776 fi 777 if $do_update && test -e $1; then 778 return 779 fi 780 if $do_specfile; then 781 echo "./$1 type=dir mode=$2 gid=$g_wheel uid=$u_root" 782 else 783 nooutput -2 mkdir $1 784 chmod $2 $1 785 fi 786 } 787 788 warn() 789 { 790 echo 1>&2 "$0: $*" 791 status=1 792 } 793 794 die() 795 { 796 echo 1>&2 "$0: $*" 797 exit 1 798 } 799 800 # makedev special [...] 801 # the main loop 802 # 803 makedev() 804 { 805 806 for i 807 do 808 809 case $i in 810 811 %MD_DEVICES% 812 813 all) 814 makedev all_md 815 makedev std fd ptm 816 makedev dk0 dk1 dk2 dk3 dk4 dk5 dk6 dk7 817 makedev dk8 dk9 dk10 dk11 dk12 dk13 dk14 dk15 818 makedev dk16 dk17 dk18 dk19 dk20 dk21 dk22 dk23 819 makedev dk24 dk25 dk26 dk27 dk28 dk29 dk30 dk31 820 makedev ccd0 ccd1 ccd2 ccd3 821 makedev cgd0 cgd1 cgd2 cgd3 cgd4 cgd5 cgd6 cgd7 822 makedev fss0 fss1 fss2 fss3 823 makedev md0 md1 824 makedev raid0 raid1 raid2 raid3 raid4 raid5 raid6 raid7 825 makedev vnd0 vnd1 vnd2 vnd3 826 makedev iscsi0 827 makedev bpf npf 828 makedev tun0 tun1 tun2 tun3 829 makedev ipl pf crypto random 830 makedev lockstat clockctl cpuctl 831 makedev atabus0 atabus1 atabus2 atabus3 atabus4 atabus5 atabus6 atabus7 832 makedev srt0 srt1 srt2 srt3 833 makedev tap tap0 tap1 tap2 tap3 834 makedev gpio gpio0 gpio1 gpio2 gpio3 gpio4 gpio5 gpio6 gpio7 835 makedev gpioirq0 gpiopps0 836 makedev pad pad0 pad1 pad2 pad3 837 makedev bthub 838 makedev putter 839 makedev drvctl 840 makedev video 841 makedev dtv 842 makedev drm0 drm1 drm2 drm3 843 makedev altmem 844 makedev zfs 845 makedev lua 846 makedev hdmicec0 847 makedev dtrace 848 makedev veriexec 849 makedev autofs 850 makedev fw0 fw1 fw2 fw3 851 makedev ipmi0 852 makedev qemufwcfg 853 makedev sht3xtemp0 854 makedev scmd0 855 makedev local # do this last 856 ;; 857 858 init) 859 # unless overridden by MD entry, this is equal to 'all' 860 makedev all opty 861 ;; 862 863 %MI_DEVICES_BEGIN% 864 audio) 865 makedev audio0 audio1 audio2 audio3 866 makedev hdaudio0 hdaudio1 hdaudio2 hdaudio3 867 lndev sound0 sound 868 lndev audio0 audio 869 lndev mixer0 mixer 870 lndev audioctl0 audioctl 871 ;; 872 873 emcfan[0-9]*) 874 unit=${i#emcfan} 875 mkdev emcfan$unit c %emcfan_chr% $unit 660 876 ;; 877 878 gpio) 879 makedev gpio0 gpio1 gpio2 gpio3 gpio4 gpio5 gpio6 gpio7 880 lndev gpio0 gpio 881 ;; 882 883 gpioirq) 884 makedev gpioirq0 885 ;; 886 887 gpiopps) 888 makedev gpiopps0 889 lndev gpiopps0 gpiopps 890 ;; 891 892 lua) 893 makedev lua0 894 lndev lua0 lua 895 ;; 896 897 pad) 898 makedev pad0 pad1 pad2 pad3 899 lndev pad0 pad 900 ;; 901 902 qemufwcfg) 903 makedev qemufwcfg0 904 lndev qemufwcfg0 qemufwcfg 905 ;; 906 907 radio) 908 makedev radio0 radio1 909 lndev radio0 radio 910 ;; 911 912 video) 913 makedev video0 video1 video2 video3 914 ;; 915 916 dtv) 917 makedev dtv0 dtv1 dtv2 dtv3 918 ;; 919 920 iic) 921 makedev iic0 iic1 iic2 iic3 922 ;; 923 924 altmem) 925 makedev altmem0 altmem1 926 ;; 927 928 ramdisk) 929 makedev floppy md0 930 ;; 931 932 sht3xtemp) 933 makedev sht3xtemp0 934 ;; 935 936 scmd) 937 makedev scmd0 938 ;; 939 940 usbs) 941 makedev usb usb0 usb1 usb2 usb3 usb4 usb5 usb6 usb7 942 makedev usb8 usb9 usb10 usb11 usb12 usb13 usb14 usb15 943 makedev uhid0 uhid1 uhid2 uhid3 uhid4 uhid5 944 makedev uhid6 uhid7 uhid8 uhid9 uhid10 uhid11 945 makedev uhid12 uhid13 uhid14 uhid15 946 makedev ulpt0 ulpt1 947 makedev ttyU0 ttyU1 ttyU2 ttyU3 ttyU4 ttyU5 ttyU6 ttyU7 948 makedev ttyY0 ttyY1 949 makedev ttyHS0 950 makedev utoppy0 utoppy1 951 makedev ugen0 ugen1 ugen2 ugen3 952 ;; 953 954 virtio) 955 makedev ttyVI 956 makedev vio9p0 vio9p1 vio9p2 vio9p3 957 makedev vio9p4 vio9p5 vio9p6 vio9p7 958 ;; 959 960 std) 961 mkdev console c %cons_chr% 0 600 962 mkdev constty c %cons_chr% 1 600 963 mkdev drum c %swap_chr% 0 640 $g_kmem 964 mkdev kmem c %mem_chr% 1 640 $g_kmem 965 mkdev mem c %mem_chr% 0 640 $g_kmem 966 mkdev null c %mem_chr% 2 666 967 mkdev full c %mem_chr% 11 666 968 mkdev zero c %mem_chr% 12 666 969 mkdev klog c %log_chr% 0 600 970 mkdev ksyms c %ksyms_chr% 0 440 $g_kmem 971 mkdev random c %rnd_chr% 0 444 972 mkdev urandom c %rnd_chr% 1 644 973 if ! $fdesc_mounted; then 974 mkdev tty c %ctty_chr% 0 666 975 mkdev stdin c %filedesc_chr% 0 666 976 mkdev stdout c %filedesc_chr% 1 666 977 mkdev stderr c %filedesc_chr% 2 666 978 fi 979 ;; 980 981 usb) 982 mkdev usb c %usb_chr% 255 444 983 ;; 984 985 usb[0-9]*) 986 unit=${i#usb} 987 usb=usb$unit 988 mkdev usb$unit c %usb_chr% $unit 989 ;; 990 991 uhid[0-9]*) 992 unit=${i#uhid} 993 mkdev uhid$unit c %uhid_chr% $unit 666 994 ;; 995 996 ulpt[0-9]*) 997 unit=${i#ulpt} 998 mkdev ulpt$unit c %ulpt_chr% $unit 999 mkdev ulpn$unit c %ulpt_chr% $(($unit + 64)) 1000 ;; 1001 1002 utoppy[0-9]*) 1003 unit=${i#utoppy} 1004 mkdev utoppy$unit c %utoppy_chr% $unit 1005 ;; 1006 1007 ttyHS[0-9]*) 1008 unit=${i#ttyHS} 1009 for j in 00 01 02 03 04 05 06 07 08 09 10 1010 do 1011 base=$(($unit * 16 + ${j#0})) 1012 mkdev ttyHS$unit.$j c %uhso_chr% $(($base + $dialin )) "" "" $u_uucp 1013 mkdev dtyHS$unit.$j c %uhso_chr% $(($base + $dialout )) "" "" $u_uucp 1014 mkdev ctyHS$unit.$j c %uhso_chr% $(($base + $callunit)) "" "" $u_uucp 1015 done 1016 ;; 1017 1018 ttyY[0-9]*) 1019 unit=${i#ttyY} 1020 mkdev ttyY$unit c %ucycom_chr% $(($unit + $dialin )) "" "" $u_uucp 1021 mkdev dtyY$unit c %ucycom_chr% $(($unit + $dialout )) "" "" $u_uucp 1022 mkdev ctyY$unit c %ucycom_chr% $(($unit + $callunit)) "" "" $u_uucp 1023 ;; 1024 1025 ucom[0-9]*) 1026 makedev ttyU${i#ucom} 1027 ;; 1028 1029 ttyU[0-9]*) 1030 unit=${i#ttyU} 1031 mkdev ttyU$unit c %ucom_chr% $(($unit + $dialin )) "" "" $u_uucp 1032 mkdev dtyU$unit c %ucom_chr% $(($unit + $dialout )) "" "" $u_uucp 1033 mkdev ctyU$unit c %ucom_chr% $(($unit + $callunit)) "" "" $u_uucp 1034 ;; 1035 1036 ugen[0-9]*) 1037 unit=${i#ugen} 1038 for j in 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 1039 do 1040 mkdev ugen$unit.$j c %ugen_chr% $(($unit * 16 + ${j#0})) 1041 done 1042 ;; 1043 1044 umcpmio[0-9]*) 1045 unit=${i#umcpmio} 1046 mkdev umcpmio${unit}ctl c %umcpmio_chr% $unit 660 1047 for j in 0 1 2 1048 do 1049 mkdev umcpmio${unit}GP$(($j + 1)) c %umcpmio_chr% $(($unit * 3 + 128 + ${j#})) 666 1050 done 1051 mkdev umcpmio${unit}EEP c %umcpmio_chr% $(($unit + 256)) 660 1052 ;; 1053 1054 wscons) 1055 makedev ttyE0 ttyE1 ttyE2 ttyE3 ttyE4 ttyE5 ttyE6 ttyE7 1056 makedev ttyF0 ttyF1 ttyF2 ttyF3 ttyF4 ttyF5 ttyF6 ttyF7 1057 makedev ttyG0 ttyG1 ttyG2 ttyG3 ttyG4 ttyG5 ttyG6 ttyG7 1058 makedev ttyH0 ttyH1 ttyH2 ttyH3 ttyH4 ttyH5 ttyH6 ttyH7 1059 makedev wsmouse0 wsmouse1 wsmouse2 wsmouse3 1060 makedev wskbd0 wskbd1 wskbd2 wskbd3 1061 makedev wsmux0 wsmux1 wsmux2 wsmux3 1062 makedev wsmouse wskbd 1063 makedev ttyEcfg ttyEstat 1064 makedev ttyFcfg ttyFstat 1065 makedev ttyGcfg ttyGstat 1066 makedev ttyHcfg ttyHstat 1067 makedev wsfont 1068 ;; 1069 1070 wsmouse) 1071 mkdev wsmouse c %wsmux_chr% 0 1072 ;; 1073 1074 wskbd) 1075 mkdev wskbd c %wsmux_chr% 1 1076 ;; 1077 1078 wsmux[0-9]*) 1079 unit=${i#wsmux} 1080 mkdev wsmux$unit c %wsmux_chr% $unit 1081 mkdev wsmuxctl$unit c %wsmux_chr% $(($unit + 128)) 200 1082 ;; 1083 1084 xenevt) 1085 mkdev xenevt c %xenevt_chr% 0 1086 ;; 1087 1088 xsd_kva) 1089 mkdev xsd_kva c %xenevt_chr% 1 1090 ;; 1091 1092 xencons) 1093 mkdev xencons c %xencons_chr% 0 1094 ;; 1095 1096 ttyEstat) 1097 mkdev ttyEstat c %wsdisplay_chr% 254 1098 ;; 1099 1100 ttyEcfg) 1101 mkdev ttyEcfg c %wsdisplay_chr% 255 1102 ;; 1103 1104 ttyE[0-9]*) 1105 unit=${i#ttyE} 1106 mkdev ttyE$unit c %wsdisplay_chr% $unit 1107 ;; 1108 1109 ttyFstat) 1110 mkdev ttyFstat c %wsdisplay_chr% 510 1111 ;; 1112 1113 ttyFcfg) 1114 mkdev ttyFcfg c %wsdisplay_chr% 511 1115 ;; 1116 1117 ttyF[0-9]*) 1118 unit=${i#ttyF} 1119 mkdev ttyF$unit c %wsdisplay_chr% $(($unit + 256)) 1120 ;; 1121 1122 ttyGstat) 1123 mkdev ttyGstat c %wsdisplay_chr% 766 1124 ;; 1125 1126 ttyGcfg) 1127 mkdev ttyGcfg c %wsdisplay_chr% 767 1128 ;; 1129 1130 ttyG[0-9]*) 1131 unit=${i#ttyG} 1132 mkdev ttyG$unit c %wsdisplay_chr% $(($unit + 512)) 1133 ;; 1134 1135 ttyHstat) 1136 mkdev ttyHstat c %wsdisplay_chr% 1022 1137 ;; 1138 1139 ttyHcfg) 1140 mkdev ttyHcfg c %wsdisplay_chr% 1023 1141 ;; 1142 1143 ttyH[0-9]*) 1144 unit=${i#ttyH} 1145 mkdev ttyH$unit c %wsdisplay_chr% $(($unit + 768)) 1146 ;; 1147 1148 wsmouse[0-9]*) 1149 unit=${i#wsmouse} 1150 mkdev wsmouse$unit c %wsmouse_chr% $unit 1151 ;; 1152 1153 wskbd[0-9]*) 1154 unit=${i#wskbd} 1155 mkdev wskbd$unit c %wskbd_chr% $unit 1156 ;; 1157 1158 fd) 1159 if ! $fdesc_mounted; then 1160 # Create the "fd" subdirectory, and devices "fd/0" to "fd/63" 1161 makedir fd 755 1162 n=0 1163 while [ $n -lt 64 ] 1164 do 1165 mkdev fd/$n c %filedesc_chr% $n 666 1166 n=$(($n + 1)) 1167 done 1168 fi 1169 ;; 1170 1171 wt[0-9]*) 1172 name=wt; unit=${i#wt}; chr=%wt_chr%; blk=%wt_blk% 1173 for sub in $unit $(($unit+8)) $(($unit+16)) 1174 do 1175 mkdev $name$sub b $blk $(($sub + 0)) 660 $g_operator 1176 mkdev n$name$sub b $blk $(($sub + 4)) 660 $g_operator 1177 mkdev r$name$sub c $chr $(($sub + 0)) 660 $g_operator 1178 mkdev nr$name$sub c $chr $(($sub + 4)) 660 $g_operator 1179 done 1180 ;; 1181 1182 md[0-9]*) 1183 makedisk_minimal md ${i#md} %md_blk% %md_chr% 1184 ;; 1185 1186 fss[0-9]*) 1187 name=fss; unit=${i#fss}; blk=%fss_blk%; chr=%fss_chr% 1188 mkdev $name$unit b $blk $unit 660 $g_operator 1189 mkdev r$name$unit c $chr $unit 660 $g_operator 1190 ;; 1191 1192 ss[0-9]*) 1193 name=ss; unit=${i#ss}; chr=%ss_chr% 1194 mkdev $name$unit c $chr $(($unit * 16 + 0)) 640 $g_operator 1195 mkdev n$name$unit c $chr $(($unit * 16 + 1)) 640 $g_operator 1196 mkdev en$name$unit c $chr $(($unit * 16 + 3)) 640 $g_operator 1197 ;; 1198 1199 ccd[0-9]*|cgd[0-9]*|raid[0-9]*|vnd[0-9]*) 1200 case $i in 1201 ccd*) name=ccd; unit=${i#ccd}; blk=%ccd_blk%; chr=%ccd_chr%;; 1202 cgd*) name=cgd; unit=${i#cgd}; blk=%cgd_blk%; chr=%cgd_chr%;; 1203 raid*) name=raid; unit=${i#raid}; blk=%raid_blk%; chr=%raid_chr%;; 1204 vnd*) name=vnd; unit=${i#vnd}; blk=%vnd_blk%; chr=%vnd_chr%;; 1205 esac 1206 %MKDISK% $name $unit $blk $chr 1207 ;; 1208 1209 sd[0-9]*) 1210 name=sd; unit=${i#sd}; blk=%sd_blk%; chr=%sd_chr% 1211 %MKDISK% $name $unit $blk $chr 1212 ;; 1213 1214 ace[0-9]*) 1215 name=ace; unit=${i#ace}; blk=%ace_blk%; chr=%ace_chr% 1216 %MKDISK% $name $unit $blk $chr 1217 ;; 1218 1219 eflash[0-9]*) 1220 name=eflash; unit=${i#eflash}; blk=%eflash_blk%; chr=%eflash_chr% 1221 %MKDISK% $name $unit $blk $chr 1222 ;; 1223 1224 wd[0-9]*) 1225 name=wd; unit=${i#wd}; blk=%wd_blk%; chr=%wd_chr% 1226 %MKDISK% $name $unit $blk $chr 1227 ;; 1228 1229 fd[0-9]*) 1230 name=fd; unit=${i#fd}; blk=%fd_blk%; chr=%fd_chr% 1231 %MKDISK% $name $unit $blk $chr 1232 ;; 1233 1234 ld[0-9]*) 1235 name=ld; unit=${i#ld}; blk=%ld_blk%; chr=%ld_chr% 1236 %MKDISK% $name $unit $blk $chr 1237 ;; 1238 1239 flash[0-9]*) 1240 unit=${i#flash} 1241 flash=flash$unit 1242 mkdev flash$unit b %flash_blk% $unit 1243 mkdev rflash$unit c %flash_chr% $unit 1244 ;; 1245 1246 spiflash[0-9]*) 1247 unit=${i#spiflash} 1248 spiflash=spiflash$unit 1249 mkdev spiflash$unit b %spiflash_blk% $unit 1250 mkdev rspiflash$unit c %spiflash_chr% $unit 1251 ;; 1252 1253 altmem[0-9]*) 1254 name=altmem; unit=${i#altmem}; blk=%altmem_blk%; chr=%altmem_chr% 1255 %MKDISK% $name $unit $blk $chr 1256 ;; 1257 1258 bio) 1259 mkdev bio c %bio_chr% 0 1260 ;; 1261 1262 ed[0-9]*) 1263 name=ed; unit=${i#ed}; blk=%ed_blk%; chr=%ed_chr% 1264 %MKDISK% $name $unit $blk $chr 1265 ;; 1266 1267 ofdisk[0-9]*) 1268 name=ofdisk; unit=${i#ofdisk}; blk=%ofdisk_blk%; chr=%ofdisk_chr% 1269 %MKDISK% $name $unit $blk $chr 1270 ;; 1271 1272 xbd[0-9]*) 1273 name=xbd; unit=${i#xbd}; blk=%xbd_blk%; chr=%xbd_chr% 1274 %MKDISK% $name $unit $blk $chr 1275 ;; 1276 1277 dk[0-9]*) 1278 name=dk; unit=${i#dk}; blk=%dk_blk%; chr=%dk_chr% 1279 mkdev r$name$unit c $chr $unit 0640 $g_operator 1280 mkdev $name$unit b $blk $unit 0640 $g_operator 1281 ;; 1282 1283 tprof) 1284 mkdev tprof c %tprof_chr% 0 1285 ;; 1286 1287 ttyCY[0-9]*) 1288 # Each unit number creates 32 pairs of {tty,dty} device nodes: 1289 # ttyCY0 => device nodes [td]tyCY000 to [td]tyCY031; 1290 # ttyCY1 => device nodes [td]tyCY032 to [td]tyCY063; 1291 name=tyCY; chr=%cy_chr%; off=32 1292 unit=${i#t${name}} 1293 minor=$(($unit * $off)) 1294 eminor=$(($minor + $off)) 1295 while [ $minor -lt $eminor ] 1296 do 1297 nminor=000$minor 1298 nminor=${nminor#${nminor%???}} 1299 mkdev t$name$nminor c $chr $(($minor + $dialin )) "" "" $u_uucp 1300 mkdev d$name$nminor c $chr $(($minor + $dialout)) "" "" $u_uucp 1301 minor=$(($minor + 1)) 1302 done 1303 ;; 1304 1305 ttyCZ[0-9]*) 1306 # Each unit number creates 64 pairs of {tty,dty} device nodes: 1307 # ttyCZ0 => device nodes [td]tyCZ0000 to [td]tyCZ0063; 1308 # ttyCZ1 => device nodes [td]tyCZ0064 to [td]tyCZ0127; 1309 name=tyCZ; chr=%cz_chr%; off=64 1310 unit=${i#t${name}} 1311 minor=$(($unit * $off)) 1312 eminor=$(($minor + $off)) 1313 while [ $minor -lt $eminor ] 1314 do 1315 nminor=0000$minor 1316 nminor=${nminor#${nminor%????}} 1317 mkdev t$name$nminor c $chr $(($minor + $dialin )) "" "" $u_uucp 1318 mkdev d$name$nminor c $chr $(($minor + $dialout)) "" "" $u_uucp 1319 minor=$(($minor + 1)) 1320 done 1321 ;; 1322 1323 1324 tty[0-9]|tty0[0-9]) 1325 # some archs have built-in zstty (major %zstty_chr%) instead 1326 # of NS16550; create ttyZ* and hardlink as [dt]ty0*; this 1327 # needs to be before com entry, for archs which have both 1328 unit=${i#tty} 1329 unit=$(($unit + 0)) 1330 makedev ttyZ${unit} 1331 lndev ttyZ$unit tty0${unit} 1332 lndev dtyZ$unit dty0${unit} 1333 ;; 1334 1335 tty[0-9]*) 1336 unit=${i#tty} 1337 ounit=00$unit 1338 ounit=${ounit#${ounit%??}} 1339 mkdev tty$ounit c %com_chr% $(($unit + $dialin )) "" "" $u_uucp 1340 mkdev dty$ounit c %com_chr% $(($unit + $dialout)) "" "" $u_uucp 1341 ;; 1342 1343 ttyC[0-9]*) 1344 # some archs call com_chr ttyC traditionally 1345 unit=${i#ttyC}; name=ttyC; dname=dtyC; chr=%com_chr% 1346 mkdev $name$unit c $chr $(($unit + $dialin )) "" "" $u_uucp 1347 mkdev $dname$unit c $chr $(($unit + $dialout)) "" "" $u_uucp 1348 ;; 1349 1350 ttyh[0-9]*) 1351 unit=${i#ttyh}; name=ttyh; dname=dtyh; chr=%sabtty_chr% 1352 mkdev $name$unit c $chr $(($unit + $dialin )) "" "" $u_uucp 1353 mkdev $dname$unit c $chr $(($unit + $dialout)) "" "" $u_uucp 1354 ;; 1355 1356 ttyTX[0-9]*) 1357 unit=${i#ttyTX}; name=ttyTX0; dname=dtyTX0; chr=%txcom_chr% 1358 mkdev $name$unit c $chr $(($unit + $dialin )) "" "" $u_uucp 1359 mkdev $dname$unit c $chr $(($unit + $dialout)) "" "" $u_uucp 1360 ;; 1361 1362 ttyZ[0-9]*) 1363 unit=${i#ttyZ}; name=ttyZ; dname=dtyZ; chr=%zstty_chr% 1364 mkdev $name$unit c $chr $(($unit + $dialin )) "" "" $u_uucp 1365 mkdev $dname$unit c $chr $(($unit + $dialout)) "" "" $u_uucp 1366 ;; 1367 1368 opty) 1369 # Create 16 device nodes, [pt]typ0 to [pt]typf, 1370 # same as "MAKEDEV pty0". 1371 for j in 0 1 2 3 4 5 6 7 8 9 a b c d e f 1372 do 1373 case $j in 1374 [0-9]) jn=$j ;; 1375 a) jn=10 ;; 1376 b) jn=11 ;; 1377 c) jn=12 ;; 1378 d) jn=13 ;; 1379 e) jn=14 ;; 1380 f) jn=15 ;; 1381 esac 1382 mkdev ttyp$j c %pts_chr% $jn 666 1383 mkdev ptyp$j c %ptc_chr% $jn 666 1384 done 1385 ;; 1386 1387 pty[0-9]*) 1388 # Each unit number creates up to 16 pairs of {tty,pty} device nodes: 1389 # pty0 => 16 pairs, [tp]typ0 to [tp]typf 1390 # pty1 => 16 pairs, [tp]tyq0 to [tp]tyqf 1391 # pty16 => 16 pairs, [tp]typg to [tp]typv 1392 # pty17 => 16 pairs, [tp]typw to [tp]typL 1393 # pty18 => 14 pairs, [tp]typM to [tp]typZ 1394 warn "$i: creating BSD style tty nodes with ptyfs is a security issue" 1395 class=${i#pty} 1396 d1="p q r s t u v w x y z P Q R S T" 1397 if [ "$class" -ge 64 ] 1398 then 1399 warn "$i: pty unit must be between 0 and 63" 1400 continue 1401 elif [ "$class" -lt 16 ] 1402 then 1403 # pty[p-zP-T][0-9a-f] 1404 offset=0 1405 mult=0 1406 d2="0 1 2 3 4 5 6 7 8 9 a b c d e f" 1407 else 1408 # pty[p-zP-T][g-zA-Z] 1409 class=$(($class - 16)) 1410 offset=256 1411 mult=2 1412 d2="g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z" 1413 fi 1414 start=$(($class * 16)) 1415 set -- $d2 1416 nt=$# 1417 s1=$(($start / $nt)) 1418 set -- $d1 1419 shift $s1 1420 t1=$1 1421 if [ "$t1" = v ]; then 1422 warn "$i: pty unit conflicts with console ttyv0 device" 1423 continue 1424 fi 1425 s2=$(($start % ($nt - $s1 * $mult))) 1426 set -- $d2 1427 shift $s2 1428 t2=$1 1429 unit=$(($start + $offset - $s1 * $mult)) 1430 end=$(($unit + 16)) 1431 while [ "$unit" -lt "$end" ] 1432 do 1433 mkdev tty$t1$t2 c %pts_chr% $unit 666 1434 mkdev pty$t1$t2 c %ptc_chr% $unit 666 1435 shift 1436 t2=$1 1437 if [ -z "$t2" ] 1438 then 1439 break 1440 fi 1441 unit=$(($unit + 1)) 1442 done 1443 ;; 1444 1445 stic[0-9]*) 1446 unit=${i#stic} 1447 mkdev stic$unit c %stic_chr% $unit 1448 ;; 1449 1450 st[0-9]*) 1451 name=st; unit=${i#st}; chr=%st_chr%; blk=%st_blk% 1452 mkdev $name$unit b $blk $(($unit * 16 + 0)) 660 $g_operator 1453 mkdev n$name$unit b $blk $(($unit * 16 + 1)) 660 $g_operator 1454 mkdev e$name$unit b $blk $(($unit * 16 + 2)) 660 $g_operator 1455 mkdev en$name$unit b $blk $(($unit * 16 + 3)) 660 $g_operator 1456 mkdev r$name$unit c $chr $(($unit * 16 + 0)) 660 $g_operator 1457 mkdev nr$name$unit c $chr $(($unit * 16 + 1)) 660 $g_operator 1458 mkdev er$name$unit c $chr $(($unit * 16 + 2)) 660 $g_operator 1459 mkdev enr$name$unit c $chr $(($unit * 16 + 3)) 660 $g_operator 1460 ;; 1461 1462 ses[0-9]*|ch[0-9]*|uk[0-9]*) 1463 case $i in 1464 ch*) name=ch; unit=${i#ch}; chr=%ch_chr%;; 1465 uk*) name=uk; unit=${i#uk}; chr=%uk_chr%;; 1466 ses*) name=ses; unit=${i#ses}; chr=%ses_chr%;; 1467 esac 1468 mkdev $name$unit c $chr $unit 640 $g_operator 1469 ;; 1470 1471 cd[0-9]*) 1472 makedisk_minimal cd ${i#cd} %cd_blk% %cd_chr% 1473 ;; 1474 1475 mcd[0-9]*) 1476 makedisk_minimal mcd ${i#mcd} %mcd_blk% %mcd_chr% 1477 ;; 1478 1479 gdrom[0-9]*) 1480 makedisk_minimal gdrom ${i#gdrom} %gdrom_blk% %gdrom_chr% 1481 ;; 1482 1483 lpt[0-9]*|lpa[0-9]*) 1484 case $i in 1485 lpt*) name=lpt; unit=${i#lpt}; chr=%lpt_chr%; flags=0;; 1486 lpa*) name=lpa; unit=${i#lpa}; chr=%lpt_chr%; flags=128;; 1487 esac 1488 mkdev $name$unit c $chr $(($unit + $flags)) 1489 mkdev lpt${unit}ctl c $chr $(($unit + 256)) 1490 ;; 1491 1492 bpf) 1493 mkdev bpf c %bpf_chr% 0 1494 lndev bpf bpf0 1495 ;; 1496 1497 npf) 1498 mkdev npf c %npf_chr% 0 1499 ;; 1500 1501 bthub) 1502 mkdev bthub c %bthub_chr% 0 1503 ;; 1504 1505 tun[0-9]*) 1506 unit=${i#tun} 1507 mkdev tun$unit c %tun_chr% $unit 1508 ;; 1509 1510 joy[0-9]*) 1511 unit=${i#joy} 1512 mkdev joy$unit c %joy_chr% $unit 1513 ;; 1514 1515 ipl) 1516 mkdev ipl c %ipl_chr% 0 1517 mkdev ipnat c %ipl_chr% 1 1518 mkdev ipstate c %ipl_chr% 2 1519 mkdev ipauth c %ipl_chr% 3 1520 mkdev ipsync c %ipl_chr% 4 1521 mkdev ipscan c %ipl_chr% 5 1522 mkdev iplookup c %ipl_chr% 6 1523 ;; 1524 1525 pf) 1526 mkdev pf c %pf_chr% 0 1527 ;; 1528 1529 crypto) 1530 mkdev crypto c %crypto_chr% 0 666 1531 ;; 1532 1533 cmos) 1534 mkdev cmos c %cmos_chr% 0 644 1535 ;; 1536 1537 speaker) 1538 mkdev speaker c %spkr_chr% 0 1539 ;; 1540 1541 lockstat) 1542 mkdev lockstat c %lockstat_chr% 0 1543 ;; 1544 1545 cpuctl) 1546 mkdev cpuctl c %cpuctl_chr% 0 666 1547 ;; 1548 1549 audio|audio[0-9]*) 1550 unit=${i#audio} 1551 audio=audio$unit 1552 sound=sound$unit 1553 mixer=mixer$unit 1554 audioctl=audioctl$unit 1555 : ${unit:-0} 1556 mkdev $sound c %audio_chr% $(($unit + 0)) 666 1557 mkdev $audio c %audio_chr% $(($unit + 128)) 666 1558 mkdev $mixer c %audio_chr% $(($unit + 16)) 666 1559 mkdev $audioctl c %audio_chr% $(($unit + 192)) 666 1560 ;; 1561 1562 hdaudio[0-9]*) 1563 unit=${i#hdaudio} 1564 mkdev hdaudio$unit c %hdaudio_chr% $unit 644 1565 ;; 1566 1567 hdmicec[0-9]*) 1568 uint=${i#hdmicec} 1569 mkdev hdmicec$unit c %hdmicec_chr% $unit 644 1570 ;; 1571 1572 gpio[0-9]*) 1573 unit=${i#gpio} 1574 mkdev gpio$unit c %gpio_chr% $unit 664 $g_gpio 1575 ;; 1576 1577 gpioirq[0-9]*) 1578 unit=${i#gpioirq} 1579 mkdev gpioirq$unit c %gpioirq_chr% $unit 444 $g_gpio 1580 ;; 1581 1582 gpiopps[0-9]*) 1583 unit=${i#gpiopps} 1584 mkdev gpiopps$unit c %gpiopps_chr% $unit 664 $g_gpio 1585 ;; 1586 1587 lua[0-9]*) 1588 unit=${i#lua} 1589 mkdev lua$unit c %lua_chr% $unit 600 1590 ;; 1591 1592 rmidi[0-9]*) 1593 unit=${i#rmidi} 1594 mkdev rmidi$unit c %midi_chr% $unit 666 1595 ;; 1596 1597 music|music[0-9]*) 1598 unit=${i#music} 1599 : ${unit:-0} 1600 mkdev music$unit c %sequencer_chr% $(($unit + 0)) 666 1601 mkdev sequencer$unit c %sequencer_chr% $(($unit + 128)) 666 1602 ;; 1603 1604 radio|radio[0-9]*) 1605 unit=${i#radio} 1606 : ${unit:-0} 1607 mkdev radio$unit c %radio_chr% $unit 666 1608 ;; 1609 1610 video|video[0-9]*) 1611 unit=${i#video} 1612 : ${unit:-0} 1613 mkdev video$unit c %video_chr% $unit 666 1614 ;; 1615 1616 dtv[0-9]*) 1617 unit=${i#dtv} 1618 makedir dvb 755 1619 makedir dvb/adapter$unit 755 1620 mkdev dvb/adapter$unit/frontend0 c %dtv_chr% $(($unit + 0)) 666 1621 mkdev dvb/adapter$unit/demux0 c %dtv_chr% $(($unit + 16)) 666 1622 mkdev dvb/adapter$unit/dvr0 c %dtv_chr% $(($unit + 32)) 666 1623 ;; 1624 1625 iic[0-9]*) 1626 unit=${i#iic} 1627 : ${unit:-0} 1628 mkdev iic$unit c %iic_chr% $unit 600 1629 ;; 1630 1631 spi[0-9]*) 1632 unit=${i#spi} 1633 : ${unit:-0} 1634 mkdev spi$unit c %spi_chr% $unit 600 1635 ;; 1636 1637 amr[0-9]*) 1638 unit=${i#amr} 1639 mkdev amr$unit c %amr_chr% $unit 1640 ;; 1641 1642 apm) 1643 mkdev apm c %apm_chr% 0 644 1644 mkdev apmctl c %apm_chr% 8 644 1645 ;; 1646 1647 apm) 1648 # hpcmips uses `apmdev_chr' instead of `apm_chr' 1649 mkdev apm c %apmdev_chr% 0 644 1650 mkdev apmctl c %apmdev_chr% 8 644 1651 ;; 1652 1653 random) 1654 mkdev random c %rnd_chr% 0 444 1655 mkdev urandom c %rnd_chr% 1 644 1656 ;; 1657 1658 cfs) 1659 makedev cfs0 1660 ;; 1661 1662 cfs[0-9]*) 1663 unit=${i#cfs} 1664 mkdev cfs$unit c %vcoda_chr% $unit 1665 ;; 1666 1667 sysmon) 1668 mkdev sysmon c %sysmon_chr% 0 644 1669 mkdev watchdog c %sysmon_chr% 1 644 1670 mkdev power c %sysmon_chr% 2 640 1671 ;; 1672 1673 scsibus[0-9]*) 1674 unit=${i#scsibus} 1675 mkdev scsibus$unit c %scsibus_chr% $unit 644 1676 ;; 1677 1678 bktr) 1679 makedev bktr0 bktr1 1680 lndev bktr0 bktr 1681 lndev tuner0 tuner 1682 lndev vbi0 vbi 1683 ;; 1684 1685 bktr[0-9]*) 1686 unit=${i#bktr} 1687 mkdev bktr$unit c %bktr_chr% $(($unit + 0)) 444 1688 mkdev tuner$unit c %bktr_chr% $(($unit + 16)) 444 1689 mkdev vbi$unit c %bktr_chr% $(($unit + 32)) 444 1690 ;; 1691 1692 io) 1693 mkdev io c %mem_chr% 14 600 1694 ;; 1695 1696 iop[0-9]*) 1697 unit=${i#iop} 1698 mkdev iop$unit c %iop_chr% $unit 1699 ;; 1700 1701 mfi[0-9]*) 1702 unit=${i#mfi} 1703 mkdev mfi$unit c %mfi_chr% $unit 1704 ;; 1705 1706 mlx[0-9]*) 1707 unit=${i#mlx} 1708 mkdev mlx$unit c %mlx_chr% $unit 1709 ;; 1710 1711 mly[0-9]*) 1712 unit=${i#mly} 1713 mkdev mly$unit c %mly_chr% $unit 1714 ;; 1715 1716 twa[0-9]*) 1717 unit=${i#twa} 1718 mkdev twa$unit c %twa_chr% $unit 1719 ;; 1720 1721 twe[0-9]*) 1722 unit=${i#twe} 1723 mkdev twe$unit c %twe_chr% $unit 1724 ;; 1725 1726 icp[0-9]*) 1727 unit=${i#icp} 1728 mkdev icp$unit c %icp_chr% $unit 1729 ;; 1730 1731 agp[0-9]*) 1732 unit=${i#agp} 1733 mkdev agp$unit c %agp_chr% $unit 644 1734 if [ "$unit" = "0" ]; then 1735 lndev agp$unit agpgart 1736 fi 1737 ;; 1738 1739 pci[0-9]*) 1740 unit=${i#pci} 1741 mkdev pci$unit c %pci_chr% $unit 640 1742 ;; 1743 1744 dpti[0-9]*) 1745 unit=${i#dpti} 1746 mkdev dpti$unit c %dpti_chr% $unit 1747 ;; 1748 1749 dpt[0-9]*) 1750 unit=${i#dpt} 1751 mkdev dpt$unit c %dpt_chr% $unit 1752 ;; 1753 1754 altq) 1755 makedir altq 755 1756 unit=0 1757 for dev in altq cbq wfq afm fifoq red rio localq hfsc cdnr blue priq jobs 1758 do 1759 mkdev altq/$dev c %altq_chr% $unit 644 1760 unit=$(($unit + 1)) 1761 done 1762 ;; 1763 1764 wsfont) 1765 mkdev wsfont c %wsfont_chr% 0 644 1766 ;; 1767 1768 cir[0-9]*) 1769 unit=${i#cir} 1770 mkdev cir$unit c %cir_chr% $unit 666 1771 ;; 1772 1773 irframe[0-9]*) 1774 unit=${i#irframe} 1775 mkdev irframe$unit c %irframe_chr% $unit 1776 ;; 1777 1778 fcom[0-9]*) 1779 unit=${i#fcom} 1780 mkdev fcom$unit c %fcom_chr% $unit "" "" $u_uucp 1781 ;; 1782 1783 openfirm) 1784 mkdev openfirm c %openfirm_chr% 0 444 1785 ;; 1786 1787 pad[0-9]*) 1788 unit=${i#pad} 1789 mkdev pad$unit c %pad_chr% $unit 444 1790 ;; 1791 1792 qemufwcfg[0-9]*) 1793 unit=${i#qemufwcfg} 1794 mkdev qemufwcfg$unit c %qemufwcfg_chr% $unit 660 1795 ;; 1796 1797 vio9p[0-9]*) 1798 unit=${i#vio9p} 1799 mkdev vio9p$unit c %vio9p_chr% $unit 660 1800 ;; 1801 1802 fault) 1803 mkdev fault c %fault_chr% 0 1804 ;; 1805 1806 nvram) 1807 mkdev nvram c %nvram_chr% 0 644 1808 ;; 1809 1810 rtc) 1811 mkdev rtc c %rtc_chr% 0 644 1812 ;; 1813 1814 clockctl) 1815 mkdev clockctl c %clockctl_chr% 0 660 $g_ntpd 1816 ;; 1817 1818 kttcp) 1819 mkdev kttcp c %kttcp_chr% 0 1820 ;; 1821 1822 dmoverio) 1823 mkdev dmoverio c %dmoverio_chr% 0 644 1824 ;; 1825 1826 veriexec) 1827 mkdev veriexec c %veriexec_chr% 0 600 1828 ;; 1829 1830 vhci[0-7]*) 1831 unit=${i#vhci} 1832 mkdev vhci$unit c %vhci_chr% $unit 1833 ;; 1834 1835 ttyv[0-9]*) 1836 unit=${i#ttyv} 1837 mkdev ttyv$unit c %pc_chr% $unit 1838 ;; 1839 1840 # arm, acorn32 1841 ttyv[0-9]*) 1842 unit=${i#ttyv} 1843 mkdev ttyv$unit c %physcon_chr% $unit 1844 ;; 1845 1846 arcpp[0-9]*) 1847 unit=${i#arcpp} 1848 mkdev arcpp$unit c %arcpp_chr% $unit 1849 ;; 1850 1851 par[0-9]*) 1852 unit=${i#par} 1853 case $unit in 1854 0) 1855 mkdev par$unit c %par_chr% $unit 1856 ;; 1857 *) 1858 warn "bad unit for par in: $i" 1859 ;; 1860 esac 1861 ;; 1862 1863 cpi[0-9]*) 1864 unit=${i#cpi} 1865 mkdev cpi$unit c %cpi_chr% $unit 1866 ;; 1867 1868 ite[0-9]*|ttye[0-9]*) 1869 case $i in 1870 ite*) unit=${i#ite};; 1871 ttye*) unit=${i#ttye};; 1872 esac 1873 mkdev ttye$unit c %ite_chr% $unit 1874 ;; 1875 1876 pms[0-9]*) 1877 unit=${i#pms} 1878 mkdev pms$unit c %opms_chr% $unit 1879 ;; 1880 1881 qms[0-9]*) 1882 unit=${i#qms} 1883 mkdev qms$unit c %qms_chr% $unit 1884 ;; 1885 1886 lms[0-9]*) 1887 unit=${i#lms} 1888 mkdev lms$unit c %lms_chr% $unit 1889 ;; 1890 1891 mms[0-9]*) 1892 unit=${i#mms} 1893 mkdev mms$unit c %mms_chr% $unit 1894 ;; 1895 1896 mouse-pms[0-9]*|mouse-qms[0-9]*) 1897 case $i in 1898 mouse-pms*) name=pms ;; 1899 mouse-qms*) name=qms ;; 1900 esac 1901 unit=${i#mouse-${name}} 1902 lndev $name$unit mouse 1903 ;; 1904 1905 kbd) 1906 mkdev kbd c %kbd_chr% 0 1907 ;; 1908 1909 kbdctl) 1910 mkdev kbdctl c %kbd_chr% 1 1911 ;; 1912 1913 vidcconsole0) 1914 mkdev vidcconsole0 c %vidcconsole_chr% 0 640 1915 ;; 1916 1917 view[0-9]*) 1918 unit=${i#view} 1919 mkdev view$unit c %view_chr% $unit 666 1920 ;; 1921 1922 mouse[0-9]*) 1923 unit=${i#mouse} 1924 case $unit in 1925 0|1) 1926 mkdev mouse$unit c %ms_chr% $unit 666 1927 if [ $unit = 0 ]; then 1928 lndev mouse$unit mouse 1929 fi 1930 ;; 1931 *) 1932 warn "bad unit for mouse in: $i" 1933 ;; 1934 esac 1935 ;; 1936 1937 panel) 1938 mkdev panel0 c %panel_chr% 0 660 1939 ;; 1940 1941 tslcd) 1942 mkdev tslcd0 c %tslcd_chr% 0 660 1943 ;; 1944 1945 ipty) 1946 mkdev ttyp0 c %pts_chr% 0 666 1947 mkdev ttyp1 c %pts_chr% 1 666 1948 mkdev ptyp0 c %ptc_chr% 0 666 1949 mkdev ptyp1 c %ptc_chr% 1 666 1950 ;; 1951 1952 ptm) 1953 makedir pts 755 1954 mkdev ptmx c %ptm_chr% 0 666 1955 mkdev ptm c %ptm_chr% 1 666 1956 ;; 1957 1958 grf[0-9]*) 1959 unit=${i#grf} 1960 mkdev grf$unit c %grf_chr% $unit 666 1961 ;; 1962 1963 etvme) 1964 mkdev etvme c %et_chr% 0 1965 ;; 1966 1967 leo[0-9]*) 1968 unit=${i#leo} 1969 mkdev leo$unit c %leo_chr% $unit 1970 ;; 1971 1972 scif[0-9]*) 1973 unit=${i#scif} 1974 mkdev scif$unit c %scif_chr% $(($unit + $dialin )) "" "" $u_uucp 1975 mkdev dscif$unit c %scif_chr% $(($unit + $dialout)) "" "" $u_uucp 1976 ;; 1977 1978 sci[0-9]*) 1979 unit=${i#sci} 1980 mkdev sci$unit c %sci_chr% $(($unit + $dialin )) "" "" $u_uucp 1981 mkdev dsci$unit c %sci_chr% $(($unit + $dialout)) "" "" $u_uucp 1982 ;; 1983 1984 maple[ABCD]|maple[ABCD][0-9]*) 1985 case $i in 1986 mapleA*) name="mapleA"; unit=0;; 1987 mapleB*) name="mapleB"; unit=1;; 1988 mapleC*) name="mapleC"; unit=2;; 1989 mapleD*) name="mapleD"; unit=3;; 1990 esac 1991 subunit=${i#$name} 1992 mkdev $name$subunit c %maple_chr% $(($unit * 8 + 0$subunit)) 1993 ;; 1994 1995 mmem[0-9]*) 1996 unit=${i#mmem} 1997 for pt in 0 # 1 2 3 4 ... 255 1998 do 1999 # mkdev mmem${unit}.${pt}a b %mmem_blk% $(($unit * 4096 + $pt * 16 + 0)) 640 $g_operator 2000 mkdev mmem${unit}.${pt}c b %mmem_blk% $(($unit * 4096 + $pt * 16 + 2)) 640 $g_operator 2001 # mkdev rmmem${unit}.${pt}a c %mmem_chr% $(($unit * 4096 + $pt * 16 + 0)) 640 $g_operator 2002 mkdev rmmem${unit}.${pt}c c %mmem_chr% $(($unit * 4096 + $pt * 16 + 2)) 640 $g_operator 2003 done 2004 ;; 2005 2006 mlcd[0-9]*) 2007 unit=${i#mlcd} 2008 for pt in 0 # 1 2 3 4 ... 255 2009 do 2010 mkdev mlcd${unit}.${pt} c %mlcd_chr% $(($unit * 256 + $pt)) 640 $g_operator 2011 done 2012 ;; 2013 2014 ixpcom[0-9]*) 2015 unit=${i#ixpcom} 2016 mkdev ixpcom$unit c %ixpcom_chr% $unit "" "" $u_uucp 2017 ;; 2018 2019 epcom[0-9]*) 2020 unit=${i#epcom} 2021 mkdev epcom$unit c %epcom_chr% $unit "" "" $u_uucp 2022 ;; 2023 2024 plcom[0-9]*) 2025 unit=${i#plcom} 2026 mkdev plcom$unit c %plcom_chr% $unit "" "" $u_uucp 2027 mkdev dplcom$unit c %plcom_chr% $(($unit + $dialout)) "" "" $u_uucp 2028 ;; 2029 2030 wmcom[0-9]*) 2031 unit=${i#wmcom} 2032 mkdev wmcom$unit c %wmcom_chr% $unit "" "" $u_uucp 2033 ;; 2034 2035 ucbsnd) 2036 mkdev ucbsnd c %ucbsnd_chr% 0 666 2037 ;; 2038 2039 adb) 2040 mkdev adb c %aed_chr% 0 666 2041 ;; 2042 2043 asc[0-9]*) 2044 unit=${i#asc} 2045 mkdev asc$unit c %asc_chr% $unit 666 2046 ;; 2047 2048 bwtwo[0-9]*) 2049 unit=${i#bwtwo} 2050 mkdev bwtwo$unit c %bwtwo_chr% $unit 666 2051 ;; 2052 2053 cgtwo[0-9]*) 2054 unit=${i#cgtwo} 2055 mkdev cgtwo$unit c %cgtwo_chr% $unit 666 2056 ;; 2057 2058 cgthree[0-9]*) 2059 unit=${i#cgthree} 2060 mkdev cgthree$unit c %cgthree_chr% $unit 666 2061 ;; 2062 2063 cgfour[0-9]*) 2064 unit=${i#cgfour} 2065 mkdev cgfour$unit c %cgfour_chr% $unit 666 2066 ;; 2067 2068 cgsix[0-9]*) 2069 unit=${i#cgsix} 2070 mkdev cgsix$unit c %cgsix_chr% $unit 666 2071 ;; 2072 2073 cgeight[0-9]*) 2074 unit=${i#cgeight} 2075 mkdev cgeight$unit c %cgeight_chr% $unit 666 2076 ;; 2077 2078 tcx[0-9]*) 2079 unit=${i#tcx} 2080 mkdev tcx$unit c %tcx_chr% $unit 666 2081 ;; 2082 2083 xd[0-9]*|xy[0-9]*) 2084 case $i in 2085 xd*) name=xd; unit=${i#xd}; blk=%xd_blk%; chr=%xd_chr%;; 2086 xy*) name=xy; unit=${i#xy}; blk=%xy_blk%; chr=%xy_chr%;; 2087 esac 2088 %MKDISK% $name $unit $blk $chr 2089 ;; 2090 2091 magma[0-9]*) 2092 unit=${i#magma} 2093 if [ 0$unit -gt 3 ]; then 2094 warn "bad unit for $i: $unit" 2095 break 2096 fi 2097 for j in 0 1 2 3 4 5 6 7 8 9 a b c d e f 2098 do 2099 case $j in 2100 [0-9]) jn=$j ;; 2101 a) jn=10 ;; 2102 b) jn=11 ;; 2103 c) jn=12 ;; 2104 d) jn=13 ;; 2105 e) jn=14 ;; 2106 f) jn=15 ;; 2107 esac 2108 mkdev tty$unit$j c %mtty_chr% $(($unit * 64 + $jn)) 2109 done 2110 mkdev bpp${unit}0 c %mbpp_chr% $(($unit * 64 + 0)) 2111 mkdev bpp${unit}1 c %mbpp_chr% $(($unit * 64 + 1)) 2112 ;; 2113 2114 clcd[0-9]*) 2115 unit=${i#clcd} 2116 if [ 0$unit -gt 7 ]; then 2117 warn "bad unit for $i: $unit" 2118 break 2119 fi 2120 for j in 0 1 2 3 4 5 6 7 2121 do 2122 mkdev ttyA$unit$j c %clcd_chr% $(($unit * 8 + $j + $dialin)) "" "" $u_uucp 2123 mkdev dtyA$unit$j c %clcd_chr% $(($unit * 8 + $j + $dialout)) "" "" $u_uucp 2124 done 2125 ;; 2126 2127 spif[0-9]*) 2128 unit=${i#spif} 2129 if [ 0$unit -gt 3 ]; then 2130 warn "bad unit for $i: $unit" 2131 break 2132 fi 2133 for j in 0 1 2 3 4 5 6 7; do 2134 mkdev ttyS$unit$j c %stty_chr% $(($unit * 64 + $j)) "" "" $u_uucp 2135 done 2136 mkdev bppS${unit}0 c %sbpp_chr% $(($unit * 64 + 0)) 2137 mkdev bppS${unit}1 c %sbpp_chr% $(($unit * 64 + 1)) 2138 ;; 2139 2140 bpp|bpp[0-9]*) 2141 unit=${i#bpp} 2142 mkdev bpp$unit c %bpp_chr% $(($unit + 0)) 2143 ;; 2144 2145 tctrl[0-9]*) 2146 unit=${i#tctrl} 2147 mkdev tctrl$unit c %tctrl_chr% $unit 666 2148 ;; 2149 2150 bmd[0-9]*) 2151 unit=${i#bmd} 2152 mkdev bmd${unit}a b %bmd_blk% $(($unit * 8 + 0)) 640 $g_operator 2153 mkdev bmd${unit}c b %bmd_blk% $(($unit * 8 + 2)) 640 $g_operator 2154 mkdev rbmd${unit}a c %bmd_chr% $(($unit * 8 + 0)) 640 $g_operator 2155 mkdev rbmd${unit}c c %bmd_chr% $(($unit * 8 + 2)) 640 $g_operator 2156 ;; 2157 2158 sram) 2159 mkdev sram c %sram_chr% 0 644 2160 ;; 2161 2162 ttyS[0-9]*) 2163 unit=${i#ttyS} 2164 mkdev ttyS$unit c %sacom_chr% $(($unit + $dialin )) "" "" $u_uucp 2165 mkdev dtyS$unit c %sacom_chr% $(($unit + $dialout)) "" "" $u_uucp 2166 ;; 2167 2168 atabus[0-9]*) 2169 unit=${i#atabus} 2170 mkdev atabus$unit c %atabus_chr% $unit 644 2171 ;; 2172 2173 drm[0-9]*) 2174 unit=${i#drm} 2175 unit2=$((unit + 128)) 2176 makedir dri 755 2177 mkdev dri/card$unit c %drm_chr% $unit 660 2178 mkdev dri/renderD${unit2} c %drm_chr% ${unit2} 660 2179 ;; 2180 2181 drvctl) 2182 mkdev drvctl c %drvctl_chr% 0 644 2183 ;; 2184 2185 isv) 2186 mkdev isv c %isv_chr% 0 644 2187 ;; 2188 2189 tap|tap[0-9]*) 2190 unit=${i#tap} 2191 case "$unit" in 2192 [0-9]*) 2193 mkdev tap${unit} c %tap_chr% ${unit} 600 2194 ;; 2195 "") 2196 mkdev tap c %tap_chr% 0xfffff 600 2197 ;; 2198 esac 2199 ;; 2200 2201 srt[0-9]*) 2202 unit=${i#srt} 2203 mkdev srt$unit c %srt_chr% $unit 600 2204 ;; 2205 2206 tpm) 2207 mkdev tpm c %tpm_chr% 0 600 2208 ;; 2209 2210 dtrace) 2211 makedir dtrace 755 2212 mkdev dtrace/dtrace c %dtrace_chr% 0 600 2213 ;; 2214 2215 fw[0-9]*) 2216 unit=${i#fw} 2217 for j in 0 1 2 3 2218 do 2219 mkdev fw${unit}.${j} c %fw_chr% $((${unit} * 256 + ${j})) 660 ${g_operator} 2220 mkdev fwmem${unit}.${j} c %fw_chr% $((65536 + ${unit} * 256 + ${j})) 660 ${g_operator} 2221 done 2222 ;; 2223 2224 # create putter device and symlinks for all subsystems using it 2225 putter) 2226 mkdev putter c %putter_chr% 0 600 2227 mkdev pud c %putter_chr% 1 600 2228 lndev putter puffs 2229 ;; 2230 2231 zfs) 2232 mkdev zfs c %zfs_chr% 0 600 2233 makedir zpool 755 2234 ;; 2235 2236 iscsi[0-9]*) 2237 unit=${i#iscsi} 2238 mkdev iscsi${unit} c %iscsi_chr% $unit 600 2239 ;; 2240 2241 vchiq) 2242 mkdev vchiq c %vchiq_chr% 0 600 2243 ;; 2244 2245 nvme[0-9]*ns[0-9]*) 2246 unit=${i#nvme} 2247 unit=${unit%ns*} 2248 subunit=${i#nvme${unit}ns} 2249 if [ 0$subunit -le 0 ] || [ 0$subunit -ge 65536 ]; then 2250 warn "bad nsid for $i: $subunit" 2251 break 2252 fi 2253 mkdev nvme${unit}ns$subunit c %nvme_chr% $(($unit * 65536 + $subunit)) 2254 ;; 2255 2256 nvme[0-9]*) 2257 unit=${i#nvme} 2258 mkdev nvme$unit c %nvme_chr% $(($unit * 65536)) 2259 ;; 2260 2261 nvmm) 2262 mkdev nvmm c %nvmm_chr% 0 660 $g_nvmm 2263 ;; 2264 2265 autofs) 2266 mkdev autofs c %autofs_chr% 0 600 2267 ;; 2268 2269 kcov) 2270 mkdev kcov c %kcov_chr% 0 2271 ;; 2272 2273 ipmi[0-9]*) 2274 unit=${i#ipmi} 2275 mkdev ipmi${unit} c %ipmi_chr% $unit 600 2276 ;; 2277 2278 xmm[0-9]) 2279 unit=${i#xmm} 2280 makedir xmm${unit} 755 2281 mkdev xmm${unit}/rpc c %wwanc_chr% $(($unit * 65536 + 1)) 2282 mkdev ttyXMM${unit}0 c %wwanc_chr% $(($unit * 65536 + 2)) 2283 mkdev ttyXMM${unit}1 c %wwanc_chr% $(($unit * 65536 + 4)) 2284 ;; 2285 2286 acpi) 2287 mkdev acpi c %acpi_chr% 0 2288 ;; 2289 2290 smbios) 2291 mkdev smbios c %smbios_chr% 0 2292 ;; 2293 2294 efi) 2295 mkdev efi c %efi_chr% 0 660 2296 ;; 2297 2298 sht3xtemp[0-9]*) 2299 unit=${i#sht3xtemp} 2300 mkdev sht3xtemp$unit c %sht3xtemp_chr% $unit 664 2301 ;; 2302 2303 scmd[0-9]*) 2304 unit=${i#scmd} 2305 mkdev scmd$unit c %scmd_chr% $unit 666 2306 ;; 2307 2308 ttyVI[0-9][0-9]) 2309 port=${i#ttyVI?} 2310 devunit=${i%$port} 2311 unit=${devunit#ttyVI} 2312 mkdev ttyVI$unit$port c %viocon_chr% $((16*$unit + $port)) 2313 ;; 2314 2315 ttyVI) 2316 makedev ttyVI00 ttyVI10 ttyVI20 ttyVI30 2317 ;; 2318 2319 midevend) 2320 %MI_DEVICES_END% 2321 local) 2322 if [ -f "$0.local" ]; then 2323 umask 0 2324 if [ -n "$count_nodes" ]; then 2325 count_nodes=$((count_nodes + \ 2326 $(linecount "$("$HOST_SH" "$0.local" $opts -s all)") )) 2327 else 2328 "$HOST_SH" "$0.local" $opts all 2329 fi 2330 umask 077 2331 fi 2332 ;; 2333 2334 *) 2335 warn "$i: unknown device" 2336 ;; 2337 2338 esac 2339 done 2340 2341 } 2342 2343 2344 # three variants of disk partitions - max 8, max 16, max 16 with highpartoffset 2345 # hack; only the one used by port is retained in final MAKEDEV script 2346 # routine is called as: 2347 # makedisk name unit blk chr 2348 makedisk_p8() 2349 { 2350 name="$1"; unit="$2"; blk="$3"; chr="$4" 2351 2352 ro=%RAWDISK_OFF% 2353 mkdev ${name}${unit} b $blk $(($unit * 8 + $ro)) 640 $g_operator 2354 mkdev r${name}${unit} c $chr $(($unit * 8 + $ro)) 640 $g_operator 2355 2356 mkdev ${name}${unit}a b $blk $(($unit * 8 + 0)) 640 $g_operator 2357 mkdev ${name}${unit}b b $blk $(($unit * 8 + 1)) 640 $g_operator 2358 mkdev ${name}${unit}c b $blk $(($unit * 8 + 2)) 640 $g_operator 2359 mkdev ${name}${unit}d b $blk $(($unit * 8 + 3)) 640 $g_operator 2360 mkdev ${name}${unit}e b $blk $(($unit * 8 + 4)) 640 $g_operator 2361 mkdev ${name}${unit}f b $blk $(($unit * 8 + 5)) 640 $g_operator 2362 mkdev ${name}${unit}g b $blk $(($unit * 8 + 6)) 640 $g_operator 2363 mkdev ${name}${unit}h b $blk $(($unit * 8 + 7)) 640 $g_operator 2364 mkdev r${name}${unit}a c $chr $(($unit * 8 + 0)) 640 $g_operator 2365 mkdev r${name}${unit}b c $chr $(($unit * 8 + 1)) 640 $g_operator 2366 mkdev r${name}${unit}c c $chr $(($unit * 8 + 2)) 640 $g_operator 2367 mkdev r${name}${unit}d c $chr $(($unit * 8 + 3)) 640 $g_operator 2368 mkdev r${name}${unit}e c $chr $(($unit * 8 + 4)) 640 $g_operator 2369 mkdev r${name}${unit}f c $chr $(($unit * 8 + 5)) 640 $g_operator 2370 mkdev r${name}${unit}g c $chr $(($unit * 8 + 6)) 640 $g_operator 2371 mkdev r${name}${unit}h c $chr $(($unit * 8 + 7)) 640 $g_operator 2372 } 2373 2374 makedisk_p12high() 2375 { 2376 ho=524280 # offset for partition 9 to 11 (same as ...p16high) 2377 name="$1"; unit="$2"; blk="$3"; chr="$4" 2378 2379 ro=%RAWDISK_OFF% 2380 mkdev ${name}${unit} b $blk $(($unit * 8 + $ro)) 640 $g_operator 2381 mkdev r${name}${unit} c $chr $(($unit * 8 + $ro)) 640 $g_operator 2382 2383 mkdev ${name}${unit}a b $blk $(($unit * 8 + 0)) 640 $g_operator 2384 mkdev ${name}${unit}b b $blk $(($unit * 8 + 1)) 640 $g_operator 2385 mkdev ${name}${unit}c b $blk $(($unit * 8 + 2)) 640 $g_operator 2386 mkdev ${name}${unit}d b $blk $(($unit * 8 + 3)) 640 $g_operator 2387 mkdev ${name}${unit}e b $blk $(($unit * 8 + 4)) 640 $g_operator 2388 mkdev ${name}${unit}f b $blk $(($unit * 8 + 5)) 640 $g_operator 2389 mkdev ${name}${unit}g b $blk $(($unit * 8 + 6)) 640 $g_operator 2390 mkdev ${name}${unit}h b $blk $(($unit * 8 + 7)) 640 $g_operator 2391 mkdev ${name}${unit}i b $blk $(($unit * 8 + $ho + 8)) 640 $g_operator 2392 mkdev ${name}${unit}j b $blk $(($unit * 8 + $ho + 9)) 640 $g_operator 2393 mkdev ${name}${unit}k b $blk $(($unit * 8 + $ho + 10)) 640 $g_operator 2394 mkdev ${name}${unit}l b $blk $(($unit * 8 + $ho + 11)) 640 $g_operator 2395 mkdev r${name}${unit}a c $chr $(($unit * 8 + 0)) 640 $g_operator 2396 mkdev r${name}${unit}b c $chr $(($unit * 8 + 1)) 640 $g_operator 2397 mkdev r${name}${unit}c c $chr $(($unit * 8 + 2)) 640 $g_operator 2398 mkdev r${name}${unit}d c $chr $(($unit * 8 + 3)) 640 $g_operator 2399 mkdev r${name}${unit}e c $chr $(($unit * 8 + 4)) 640 $g_operator 2400 mkdev r${name}${unit}f c $chr $(($unit * 8 + 5)) 640 $g_operator 2401 mkdev r${name}${unit}g c $chr $(($unit * 8 + 6)) 640 $g_operator 2402 mkdev r${name}${unit}h c $chr $(($unit * 8 + 7)) 640 $g_operator 2403 mkdev r${name}${unit}i c $chr $(($unit * 8 + $ho + 8)) 640 $g_operator 2404 mkdev r${name}${unit}j c $chr $(($unit * 8 + $ho + 9)) 640 $g_operator 2405 mkdev r${name}${unit}k c $chr $(($unit * 8 + $ho + 10)) 640 $g_operator 2406 mkdev r${name}${unit}l c $chr $(($unit * 8 + $ho + 11)) 640 $g_operator 2407 } 2408 2409 makedisk_p16() 2410 { 2411 name="$1"; unit="$2"; blk="$3"; chr="$4" 2412 2413 ro=%RAWDISK_OFF% 2414 mkdev ${name}${unit} b $blk $(($unit * 16 + $ro)) 640 $g_operator 2415 mkdev r${name}${unit} c $chr $(($unit * 16 + $ro)) 640 $g_operator 2416 2417 mkdev ${name}${unit}a b $blk $(($unit * 16 + 0)) 640 $g_operator 2418 mkdev ${name}${unit}b b $blk $(($unit * 16 + 1)) 640 $g_operator 2419 mkdev ${name}${unit}c b $blk $(($unit * 16 + 2)) 640 $g_operator 2420 mkdev ${name}${unit}d b $blk $(($unit * 16 + 3)) 640 $g_operator 2421 mkdev ${name}${unit}e b $blk $(($unit * 16 + 4)) 640 $g_operator 2422 mkdev ${name}${unit}f b $blk $(($unit * 16 + 5)) 640 $g_operator 2423 mkdev ${name}${unit}g b $blk $(($unit * 16 + 6)) 640 $g_operator 2424 mkdev ${name}${unit}h b $blk $(($unit * 16 + 7)) 640 $g_operator 2425 mkdev ${name}${unit}i b $blk $(($unit * 16 + 8)) 640 $g_operator 2426 mkdev ${name}${unit}j b $blk $(($unit * 16 + 9)) 640 $g_operator 2427 mkdev ${name}${unit}k b $blk $(($unit * 16 + 10)) 640 $g_operator 2428 mkdev ${name}${unit}l b $blk $(($unit * 16 + 11)) 640 $g_operator 2429 mkdev ${name}${unit}m b $blk $(($unit * 16 + 12)) 640 $g_operator 2430 mkdev ${name}${unit}n b $blk $(($unit * 16 + 13)) 640 $g_operator 2431 mkdev ${name}${unit}o b $blk $(($unit * 16 + 14)) 640 $g_operator 2432 mkdev ${name}${unit}p b $blk $(($unit * 16 + 15)) 640 $g_operator 2433 mkdev r${name}${unit}a c $chr $(($unit * 16 + 0)) 640 $g_operator 2434 mkdev r${name}${unit}b c $chr $(($unit * 16 + 1)) 640 $g_operator 2435 mkdev r${name}${unit}c c $chr $(($unit * 16 + 2)) 640 $g_operator 2436 mkdev r${name}${unit}d c $chr $(($unit * 16 + 3)) 640 $g_operator 2437 mkdev r${name}${unit}e c $chr $(($unit * 16 + 4)) 640 $g_operator 2438 mkdev r${name}${unit}f c $chr $(($unit * 16 + 5)) 640 $g_operator 2439 mkdev r${name}${unit}g c $chr $(($unit * 16 + 6)) 640 $g_operator 2440 mkdev r${name}${unit}h c $chr $(($unit * 16 + 7)) 640 $g_operator 2441 mkdev r${name}${unit}i c $chr $(($unit * 16 + 8)) 640 $g_operator 2442 mkdev r${name}${unit}j c $chr $(($unit * 16 + 9)) 640 $g_operator 2443 mkdev r${name}${unit}k c $chr $(($unit * 16 + 10)) 640 $g_operator 2444 mkdev r${name}${unit}l c $chr $(($unit * 16 + 11)) 640 $g_operator 2445 mkdev r${name}${unit}m c $chr $(($unit * 16 + 12)) 640 $g_operator 2446 mkdev r${name}${unit}n c $chr $(($unit * 16 + 13)) 640 $g_operator 2447 mkdev r${name}${unit}o c $chr $(($unit * 16 + 14)) 640 $g_operator 2448 mkdev r${name}${unit}p c $chr $(($unit * 16 + 15)) 640 $g_operator 2449 } 2450 2451 makedisk_p16high() 2452 { 2453 ho=524280 # offset for partition 9 to 16 2454 name="$1"; unit="$2"; blk="$3"; chr="$4" 2455 2456 ro=%RAWDISK_OFF% 2457 mkdev ${name}${unit} b $blk $(($unit * 8 + $ro)) 640 $g_operator 2458 mkdev r${name}${unit} c $chr $(($unit * 8 + $ro)) 640 $g_operator 2459 2460 mkdev ${name}${unit}a b $blk $(($unit * 8 + 0)) 640 $g_operator 2461 mkdev ${name}${unit}b b $blk $(($unit * 8 + 1)) 640 $g_operator 2462 mkdev ${name}${unit}c b $blk $(($unit * 8 + 2)) 640 $g_operator 2463 mkdev ${name}${unit}d b $blk $(($unit * 8 + 3)) 640 $g_operator 2464 mkdev ${name}${unit}e b $blk $(($unit * 8 + 4)) 640 $g_operator 2465 mkdev ${name}${unit}f b $blk $(($unit * 8 + 5)) 640 $g_operator 2466 mkdev ${name}${unit}g b $blk $(($unit * 8 + 6)) 640 $g_operator 2467 mkdev ${name}${unit}h b $blk $(($unit * 8 + 7)) 640 $g_operator 2468 mkdev ${name}${unit}i b $blk $(($unit * 8 + $ho + 8)) 640 $g_operator 2469 mkdev ${name}${unit}j b $blk $(($unit * 8 + $ho + 9)) 640 $g_operator 2470 mkdev ${name}${unit}k b $blk $(($unit * 8 + $ho + 10)) 640 $g_operator 2471 mkdev ${name}${unit}l b $blk $(($unit * 8 + $ho + 11)) 640 $g_operator 2472 mkdev ${name}${unit}m b $blk $(($unit * 8 + $ho + 12)) 640 $g_operator 2473 mkdev ${name}${unit}n b $blk $(($unit * 8 + $ho + 13)) 640 $g_operator 2474 mkdev ${name}${unit}o b $blk $(($unit * 8 + $ho + 14)) 640 $g_operator 2475 mkdev ${name}${unit}p b $blk $(($unit * 8 + $ho + 15)) 640 $g_operator 2476 mkdev r${name}${unit}a c $chr $(($unit * 8 + 0)) 640 $g_operator 2477 mkdev r${name}${unit}b c $chr $(($unit * 8 + 1)) 640 $g_operator 2478 mkdev r${name}${unit}c c $chr $(($unit * 8 + 2)) 640 $g_operator 2479 mkdev r${name}${unit}d c $chr $(($unit * 8 + 3)) 640 $g_operator 2480 mkdev r${name}${unit}e c $chr $(($unit * 8 + 4)) 640 $g_operator 2481 mkdev r${name}${unit}f c $chr $(($unit * 8 + 5)) 640 $g_operator 2482 mkdev r${name}${unit}g c $chr $(($unit * 8 + 6)) 640 $g_operator 2483 mkdev r${name}${unit}h c $chr $(($unit * 8 + 7)) 640 $g_operator 2484 mkdev r${name}${unit}i c $chr $(($unit * 8 + $ho + 8)) 640 $g_operator 2485 mkdev r${name}${unit}j c $chr $(($unit * 8 + $ho + 9)) 640 $g_operator 2486 mkdev r${name}${unit}k c $chr $(($unit * 8 + $ho + 10)) 640 $g_operator 2487 mkdev r${name}${unit}l c $chr $(($unit * 8 + $ho + 11)) 640 $g_operator 2488 mkdev r${name}${unit}m c $chr $(($unit * 8 + $ho + 12)) 640 $g_operator 2489 mkdev r${name}${unit}n c $chr $(($unit * 8 + $ho + 13)) 640 $g_operator 2490 mkdev r${name}${unit}o c $chr $(($unit * 8 + $ho + 14)) 640 $g_operator 2491 mkdev r${name}${unit}p c $chr $(($unit * 8 + $ho + 15)) 640 $g_operator 2492 } 2493 2494 # make only the very few basic disk device nodes - 'a' partition 2495 # and raw partition 2496 makedisk_minimal() 2497 { 2498 name=$1; unit=$2; blk=$3; chr=$4 2499 doff=%DISKMINOROFFSET% 2500 ro=%RAWDISK_OFF% 2501 rn=%RAWDISK_NAME% 2502 2503 mkdev ${name}${unit} b $blk $(($unit * $doff + $ro)) 640 $g_operator 2504 mkdev r${name}${unit} c $chr $(($unit * $doff + $ro)) 640 $g_operator 2505 2506 mkdev ${name}${unit}a b $blk $(($unit * $doff + 0)) 640 $g_operator 2507 mkdev ${name}${unit}$rn b $blk $(($unit * $doff + $ro)) 640 $g_operator 2508 mkdev r${name}${unit}a c $chr $(($unit * $doff + 0)) 640 $g_operator 2509 mkdev r${name}${unit}$rn c $chr $(($unit * $doff + $ro)) 640 $g_operator 2510 } 2511 2512 # create_mfs_dev nodes 2513 # Create a memory file system for a given number of device nodes, 2514 # and mount it. Attempts to use mount_tmpfs, or falls back to 2515 # mount_mfs. 2516 # 2517 # If do_redirect, then also redirect output to the console. 2518 # 2519 create_mfs_dev() 2520 { 2521 ndevnodes=${1-1200} 2522 dev_mountpoint=${PWD:-/dev} 2523 2524 # Number of inodes is the specified number of device nodes, plus 2525 # a margin to allow for extra device nodes created later. 2526 ninode=$((ndevnodes * 11 / 10)) 2527 # Add 2 reserved inodes (needed for both mfs and tmpfs), and round 2528 # up to a multiple of 32 (needed for mfs, not needed for tmpfs). 2529 ninode=$(( (ninode + 2 + 31) / 32 * 32 )) 2530 # Try tmpfs; if that fails try mfs. 2531 # 2532 # For tmpfs, allocate 16KB and 512 byte per node. 2533 # Actual requirements are much lower, but the size limit 2534 # is only intended to avoid accidental writing to /dev. 2535 fs_bytes=$((16384 + ninode * 512)) 2536 if mount_tmpfs -s $fs_bytes -n $ninode -m 0755 \ 2537 -o union tmpfs "$dev_mountpoint" 2538 then 2539 fstype=tmpfs 2540 else 2541 # This file system size calculation is exact for mount_mfs(8) 2542 # with 512-byte sectors. 40960 bytes (80 blocks) is the 2543 # minimum size allowed by mount_mfs. 2544 fs_bytes=$((8192 + 2 * 8192 + 4096 + ninode*512 + 8192)) 2545 [ "$fs_bytes" -lt 40960 ] && fs_bytes=40960 2546 fs_blocks=$((fs_bytes/512)) 2547 if mount_mfs -b 4096 -f 512 -s $fs_blocks -n $ninode -p 0755 \ 2548 -o union swap "$dev_mountpoint" 2549 then 2550 fstype=mfs 2551 else 2552 die "Failed to create memory file system" 2553 fi 2554 fi 2555 2556 # Our current directory was in the lower file system; change it to 2557 # the newly mounted upper file system. 2558 cd "$dev_mountpoint" 2559 2560 if $do_redirect; then 2561 # Redirect stdout and stderr to console 2562 ${MKNOD} -m 600 -g 0 -u 0 temp_console c %CONSOLE_CMAJOR% 0 2563 exec >temp_console 2>&1 2564 rm temp_console 2565 fi 2566 2567 echo "Created $fstype $dev_mountpoint" \ 2568 "($fs_bytes byte, $ninode inodes)" 2569 } 2570 2571 # 2572 # MAIN: If MAKEDEV_AS_LIBRARY is set, then we are being used as a 2573 # function library, so just return. Otherwise, do all the real work. 2574 # 2575 [ -n "${MAKEDEV_AS_LIBRARY}" ] && return 2576 makedev_main makedev ${1+"$@"} 2577