MAKEDEV.tmpl revision 1.132
1#!/bin/sh - 2# $NetBSD: MAKEDEV.tmpl,v 1.132 2010/03/06 21:33:20 plunky 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# wscons make wscons devices 46# usbs make USB devices 47# isdns make ISDN devices 48# 49# Tapes: 50# st* SCSI tapes 51# wt* QIC-interfaced (e.g. not SCSI) 3M cartridge tape 52# ht* MASSBUS TM03 and TU?? 53# mt* MSCP tapes (e.g. TU81, TK50) 54# tm* UNIBUS TM11 and TE10 emulations (e.g. Emulex TC-11) 55# ts* UNIBUS TS11 56# ut* UNIBUS TU45 emulations (e.g. si 9700) 57# uu* TU58 cassettes on DL11 controller 58# 59# Disks: 60# ccd* concatenated disk devices 61# cd* SCSI or ATAPI CD-ROM 62# cgd* cryptographic disk devices 63# raid* RAIDframe disk devices 64# sd* SCSI disks 65# wd* "winchester" disk drives (ST506,IDE,ESDI,RLL,...) 66# bmd* Nereid bank memory disks 67# ed* IBM PS/2 ESDI disk devices 68# fd* "floppy" disk drives (3 1/2", 5 1/4") 69# fss* Files system snapshot devices 70# gdrom* Dreamcast "gigadisc" CD-ROM drive 71# hk* UNIBUS RK06 and RK07 72# hp* MASSBUS RM?? 73# ld* Logical disk devices (e.g., hardware RAID) 74# mcd* Mitsumi CD-ROM 75# md* memory pseudo-disk devices 76# ofdisk* OpenFirmware disk devices 77# ra* MSCP disks (RA??, RD??) 78# rb* 730 IDC w/ RB80 and/or RB02 79# rd* HDC9224 RD disks on VS2000 80# rl* UNIBUS RL02 81# rx* MSCP floppy disk (RX33/50/...) 82# up* other UNIBUS devices (e.g. on Emulex SC-21V controller) 83# vnd* "file" pseudo-disks 84# xbd* Xen virtual disks 85# xd* Xylogic 753/7053 disks 86# xy* Xylogic 450/451 disks 87# 88# Pointing devices: 89# wsmouse* wscons mouse events 90# lms* Logitech bus mouse 91# mms* Microsoft bus mouse 92# qms* "quadrature mouse" 93# pms* PS/2 mouse 94# mouse mouse (provides events, for X11) 95# 96# Keyboard devices: 97# wskbd* wscons keyboard events 98# kbd raw keyboard (provides events, for X11) 99# kbdctl keyboard control 100# 101# Terminals/Console ports: 102# tty[01]* standard serial ports 103# tty0* SB1250 ("sbscn") serial ports (sbmips) 104# ttyE* wscons - Workstation console ("wscons") glass-tty emulators 105# ttyCZ? Cyclades-Z multiport serial boards. Each "unit" 106# makes 64 ports. 107# ttyCY? Cyclom-Y multiport serial boards. Each "unit" makes 108# 32 ports. 109# ttye* ITE bitmapped consoles 110# ttyv0 pccons 111# ttyC? NS16550 ("com") serial ports 112# ttyS* SA1110 serial port (hpcarm) 113# ttyTX? TX39 internal serial ports (hpcmips) 114# ttyB? DEC 3000 ZS8530 ("scc") serial ports (alpha) 115# ttyA* mfc serial ports (amiga) 116# ttyB* msc serial ports (amiga) 117# ttyC* com style serial ports (DraCo, HyperCom) (amiga) 118# On the DraCo, units 0 and 1 are the built-in "modem" and 119# "mouse" ports, if configured. 120# ttyA0 8530 Channel A (formerly ser02) (atari) 121# ttyA1 8530 Channel B (formerly mdm02) (atari) 122# ttyB0 UART on first 68901 (formerly mdm01) (atari) 123# ixpcom IXP12x0 COM ports 124# epcom EP93xx COM ports 125# ttyM? HP200/300 4 port serial mux interface (hp300) 126# ttya "ttya" system console (luna68k) 127# ttyb second system serial port (luna68k) 128# tty* Onboard serial ports (mvme68k) 129# On the mvme147 these are: ttyZ1, ttyZ2 and ttyZ3. 130# On the mvme167, and '177: ttyC1, ttyC2 and ttyC3. 131# Note that tty[CZ]0 is grabbed by the console device 132# so is not created by default 133# dc* PMAX 4 channel serial interface (kbd, mouse, modem, printer) 134# scc* 82530 serial interface (pmax) 135# ttyZ* Zilog 8530 ("zstty") serial ports 136# tty[abcd] Built-in serial ports (sparc) 137# tty* Z88530 serial controllers (sparc64) 138# ttyh* SAB82532 serial controllers (sparc64) 139# tty[a-j] Built-in serial ports (sun2, sun3) 140# ttyC? pccons (arc) 141# dz* UNIBUS DZ11 and DZ32 (vax) 142# dh* UNIBUS DH11 and emulations (e.g. Able DMAX, Emulex CS-11) (vax) 143# dmf* UNIBUS DMF32 (vax) 144# dhu* UNIBUS DHU11 (vax) 145# dmz* UNIBUS DMZ32 (vax) 146# dl* UNIBUS DL11 (vax) 147# xencons Xen virtual console 148# 149# Terminal multiplexors: 150# dc* 4 channel serial interface (keyboard, mouse, modem, printer) 151# dh* UNIBUS DH11 and emulations (e.g. Able DMAX, Emulex CS-11) 152# dhu* UNIBUS DHU11 153# dl* UNIBUS DL11 154# dmf* UNIBUS DMF32 155# dmz* UNIBUS DMZ32 156# dz* UNIBUS DZ11 and DZ32 157# scc* 82530 serial interface 158# 159# Call units: 160# dn* UNIBUS DN11 and emulations (e.g. Able Quadracall) 161# 162# Pseudo terminals: 163# ptm pty multiplexor device, and pts directory 164# pty* set of 16 master and slave pseudo terminals 165# opty first 16 ptys, to save inodes on install media 166# ipty first 2 ptys, for install media use only 167# 168# Printers: 169# arcpp* Archimedes parallel port 170# lpt* stock lp 171# lpa* interruptless lp 172# par* Amiga motherboard parallel port 173# cpi* Macintosh Nubus CSI parallel printer card 174# 175# USB devices: 176# usb* USB control devices 177# uhid* USB generic HID devices 178# ulpt* USB printer devices 179# ugen* USB generic devices 180# urio* USB Diamond Rio 500 devices 181# uscanner* USB scanners 182# ttyHS* USB Option N.V. modems 183# ttyU* USB modems 184# ttyY* USB serial adapters 185# 186# ISDN devices: 187# isdn communication between userland isdnd and kernel 188# isdnctl control device 189# isdnbchan* raw b-channel access 190# isdntel* telephony device 191# isdnteld* telephony dialout device 192# isdntrc* trace device 193# 194# Video devices: 195# bwtwo* monochromatic frame buffer 196# cgtwo* 8-bit color frame buffer 197# cgthree* 8-bit color frame buffer 198# cgfour* 8-bit color frame buffer 199# cgsix* accelerated 8-bit color frame buffer 200# cgeight* 24-bit color frame buffer 201# etvme Tseng et-compatible cards on VME (atari) 202# ik* UNIBUS interface to Ikonas frame buffer 203# leo Circad Leonardo VME-bus true color (atari) 204# ps* UNIBUS interface to Picture System 2 205# qv* QVSS (MicroVAX) display 206# tcx* accelerated 8/24-bit color frame buffer 207# 208# Maple bus devices: 209# maple Maple bus control devices 210# mlcd* Maple bus LCD devices 211# mmem* Maple bus storage devices 212# 213# IEEE1394 bus devices: 214# fw* IEEE1394 bus generic node access devices 215# fwmem* IEEE1394 bus physical memory of the remote node access devices 216# 217# Special purpose devices: 218# ad* UNIBUS interface to Data Translation A/D converter 219# agp* AGP GART devices 220# altq ALTQ control interface 221# amr* AMI MegaRaid control device 222# apm power management device 223# audio* audio devices 224# bell* OPM bell device (x68k) 225# bktr Brooktree 848/849/878/879 based TV cards 226# bpf packet filter 227# bthub Bluetooth Device Hub control interface 228# cfs* Coda file system device 229# ch* SCSI media changer 230# cir* Consumer IR 231# clockctl clock control for non root users 232# cpuctl CPU control 233# crypto hardware crypto access driver 234# dmoverio hardware-assisted data movers 235# dpt* DPT/Adaptec EATA RAID management interface 236# dpti* DPT/Adaptec I2O RAID management interface 237# drm* Direct Rendering Manager interface 238# fb* PMAX generic framebuffer pseudo-device 239# fd file descriptors 240# grf* graphics frame buffer device 241# hdaudio* High Definition audio control device 242# hil HP300 HIL input devices 243# icp ICP-Vortex/Intel RAID control interface 244# iic* IIC bus device 245# io x86 IOPL access for COMPAT_10, COMPAT_FREEBSD 246# iop* I2O IOP control 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# mlx* Mylex DAC960 control interface 256# mly* Mylex AcceleRAID/eXtremeRAID control interface 257# np* UNIBUS Ethernet co-processor interface, for downloading. 258# nsmb* SMB requester 259# openfirm OpenFirmware accessor 260# pad* Pseudo-audio device driver 261# pci* PCI bus access devices 262# pf PF packet filter 263# pow* power management device (x68k) 264# putter Pass-to-Userspace Transporter 265# px* PixelStamp Xserver access 266# radio* radio devices 267# random Random number generator 268# rtc* RealTimeClock 269# satlink* PlanetConnect satellite receiver driver 270# scsibus* SCSI busses 271# se* SCSI Ethernet 272# ses* SES/SAF-TE SCSI Devices 273# speaker PC speaker (XXX - installed) 274# sram battery backuped memory (x68k) 275# ss* SCSI scanner 276# stic* PixelStamp interface chip 277# sysmon System Monitoring hardware 278# tap* virtual Ethernet device 279# tun* network tunnel driver 280# twa 3ware Apache control interface 281# twe 3ware Escalade control interface 282# uk* unknown SCSI device 283# veriexec Veriexec fingerprint loader 284# video* video capture devices 285# view* generic interface to graphic displays (Amiga) 286# vmegen* generic VME access 287# wsfont* console font control 288# wsmux* wscons event multiplexor 289# xenevt Xen event interface 290 291 292# 293# NOTE: 294# 295# * MAKEDEV is used both as a standalone script (via "sh ./MAKEDEV 296# all" or similar), and as a function library for MAKEDEV.local (via 297# "MAKEDEV_AS_LIBRARY=1 . MAKEDEV"). Because of this, the script 298# should consist almost entirely of function definitions, apart from a 299# few lines right at the end. 300# 301# * MAKEDEV may be executed in an environment that is missing some 302# common commands. For example, it may be executed from a minimal 303# system used during installation, or it may be executed early in the 304# boot sequence before most file systems have been mounted. It may 305# also be executed in a cross-build environment on a non-NetBSD host. 306# 307 308usage() 309{ 310 cat 1>&2 << _USAGE_ 311Usage: ${0##*/} [-fMs] [-m mknod] [-p pax] [-t mtree] special [...] 312 Create listed special devices. Options: 313 -f Force permissions to be updated on existing devices. 314 -M Create memory file system. 315 -m mknod Name of mknod(8) program. [\$TOOL_MKNOD or mknod] 316 -p pax Name of pax(1) program. [\$TOOL_PAX or pax] 317 -s Generate mtree(8) specfile instead of creating devices. 318 -t mtree Name of mtree(8) program. [\$TOOL_MTREE or mtree] 319 320_USAGE_ 321 exit 1 322} 323 324# zeropad width number 325# display number with a zero (`0') padding of width digits. 326# 327zeropad() 328{ 329 case $(($1 - ${#2})) in 330 5) echo 00000$2;; 331 4) echo 0000$2;; 332 3) echo 000$2;; 333 2) echo 00$2;; 334 1) echo 0$2;; 335 0) echo $2;; 336 *) die "bad padding" ;; 337 esac 338} 339 340# hexprint number 341# display (base10) number as hexadecimal 342# 343hexprint() 344{ 345 val="$(($1 + 0))" 346 hex= 347 set -- 0 1 2 3 4 5 6 7 8 9 a b c d e f 348 while [ "$val" -gt 0 ]; do 349 eval hex=\$$(($val % 16 + 1))\$hex 350 val="$(($val / 16))" 351 done 352 echo "${hex:-0}" 353} 354 355# linecount multiline_string 356# count the number of lines in the string 357# 358linecount() 359{ 360 local IFS=' 361' # just a newline, no other white space between the quotes 362 set -- $1 363 echo $# 364} 365 366# nooutput -12 cmd [args...] 367# run a command with stdout and/or stderr ignored. 368# "nooutput -1 cmd" is like "cmd >/dev/null"; 369# "nooutput -2 cmd" is like "{ cmd ; } 2>/dev/null"; 370# "nooutput -12 cmd" is like "{ cmd ; } >/dev/null 2>&1"; 371# except they should work even if /dev/null doesn't [yet] exist. 372# 373# The "{...}" wrapper used in cases where stderr is redirected 374# serves to capture shell error messages such as "cmd: not found". 375# 376nooutput() 377{ 378 local flags="$1" ; shift 379 local junk 380 case "$flags" in 381 "-1") junk="$( "$@" )" ;; 382 "-2") exec 4>&1 ; junk="$( { "$@" ; } 2>&1 1>&4 )" ; exec 4>&- ;; 383 "-12") junk="$( { "$@" ; } 2>&1 )" ;; 384 *) warn "Incorrect use of nooutput" ;; 385 esac 386} 387 388# check_pax path_to_pax 389# Check whether pax exists and supports the command line options 390# and input format that we will want to use. 391# 392check_pax() 393{ 394 local pax="$1" 395 echo ". type=dir optional" | nooutput -12 "${pax}" -r -w -M -pe . 396} 397 398# check_mtree path_to_mtree 399# Check whether mtree exists and supports the command line options 400# and input format that we will want to use. 401# 402check_mtree() 403{ 404 local mtree="$1" 405 echo ". type=dir optional" | nooutput -12 "${mtree}" -e -U 406} 407 408# setup args... 409# Parse command line arguments, exit on error. 410# Callers should shift $((OPTIND - 1)) afterwards. 411# 412setup() 413{ 414 PATH=/sbin:/usr/sbin:/bin:/usr/bin:/rescue 415 416 : ${TOOL_MKNOD:=mknod} 417 : ${TOOL_MTREE:=mtree} 418 : ${TOOL_PAX:=pax} 419 do_create_mfs=false 420 do_force=false 421 do_mknod=false 422 do_pax=false 423 do_mtree=false 424 do_redirect=false 425 do_specfile=false 426 opts= 427 while getopts Mfm:p:st: ch; do 428 # Note that $opts is only for options pased through to 429 # MAKEDEV.local, not for all options. 430 case ${ch} in 431 M) 432 # "-M" sets do_create_mfs; 433 # "-M -M" is for use from init(8), and sets do_redirect 434 do_redirect=$do_create_mfs 435 do_create_mfs=true 436 ;; 437 f) do_force=true 438 opts="${opts} -f" 439 ;; 440 m) TOOL_MKNOD=${OPTARG} 441 do_mknod=true 442 opts="${opts} -m ${OPTARG}" 443 ;; 444 p) TOOL_PAX="${OPTARG}" 445 if check_pax "${TOOL_PAX}"; then 446 do_pax=true 447 # do not add this to $opts; we will later 448 # add "-s" instead. 449 else 450 warn "Ignored -p option:" \ 451 "${TOOL_PAX} is missing or broken" 452 do_mknod=true 453 fi 454 ;; 455 s) do_specfile=true 456 opts="${opts} -s" 457 ;; 458 t) TOOL_MTREE="${OPTARG}" 459 if check_mtree "${TOOL_MTREE}"; then 460 do_mtree=true 461 # do not add this to $opts; we will later 462 # add "-s" instead. 463 else 464 warn "Ignored -t option:" \ 465 "${TOOL_MTREE} is missing or broken" 466 do_mknod=true 467 fi 468 ;; 469 *) usage ;; 470 esac 471 done 472 473 shift $((${OPTIND} - 1)) 474 [ $# -gt 0 ] || usage 475 476 u_root="%uid_root%" 477 u_uucp="%uid_uucp%" 478 g_kmem="%gid_kmem%" 479 g_ntpd="%gid_ntpd%" 480 g_operator="%gid_operator%" 481 g_wheel="%gid_wheel%" 482 dialin=0 483 dialout=524288 484 callunit=262144 485 486 # only allow read&write for owner by default 487 umask 077 488 489 # Set fdesc_mounted=true if the fdesc file system is mounted 490 # on the current directory (typically "/dev"). 491 # Later, this will be used to suppress creation of device nodes 492 # that are supplied by the fdesc file system. 493 # 494 fdesc_mounted=false 495 if [ -d fd ]; then 496 # Parse the output from "mount -u -o nosuchoption .". 497 # We don't parse the output from df(1) because that's 498 # less likely to be available on install media. 499 # 500 # If the current directory is a mount point for the 501 # fdesc file system, then the expected output (whether 502 # or not the current user is root) is: 503 # mount_fdesc: -o suchoption: option not supported. 504 # 505 # If the current directory is not a mount point, then 506 # the expected output is: 507 # mount: .: unknown special file or file system. 508 # 509 # If we are not running on NetBSD, or mount(8) is not 510 # found, then we should get some other error message. 511 # 512 case "$({ LC_ALL=C mount -u -o nosuchoption . ; } 2>&1)" in 513 *mount_fdesc*) fdesc_mounted=true ;; 514 esac 515 fi 516 517 # do_force requires mknod 518 if $do_force; then 519 if $do_mtree || $do_pax || $do_specfile; then 520 die "-f option works only with mknod" 521 fi 522 do_mknod=true 523 fi 524 525 # If no explicit method was specified on the command line or 526 # forced above, then use one of mtree, pax, or mknod, in that 527 # order of preference. 528 # 529 # mtree is preferred because it's fast and designed for the 530 # purpose. However, it's unlikely to be available early in the 531 # boot sequence, when init(8) may invoke MAKEDEV(8). 532 # 533 # pax is usually acceptable, and it's likely to be available 534 # early in the boot sequence. However, it's much slower than mtree. 535 # 536 # mknod is just very slow, because the shell has to fork for 537 # each device node. 538 # 539 if ! ( $do_mtree || $do_pax || $do_mknod || $do_specfile ); then 540 if check_mtree "${TOOL_MTREE}"; then 541 do_mtree=true 542 elif check_pax "${TOOL_PAX}"; then 543 do_pax=true 544 else 545 do_mknod=true 546 fi 547 fi 548 549 # Now we need exactly one node-creation method. 550 case $(( $($do_mtree && echo 1 || echo 0) + \ 551 $($do_pax && echo 1 || echo 0) + \ 552 $($do_mknod && echo 1 || echo 0) + \ 553 $($do_specfile && echo 1 || echo 0) )) 554 in 555 1) : OK ;; 556 *) die "-m, -p, -s, and -t options are mutually exclusive" ;; 557 esac 558 559 # If we are using mknod, then decide what options to pass it. 560 if $do_mknod; then 561 MKNOD="${TOOL_MKNOD:-mknod} -F netbsd" 562 if $do_force; then 563 MKNOD="${MKNOD} -R" 564 else 565 MKNOD="${MKNOD} -r" 566 fi 567 fi 568 569 # do_mtree or do_pax internally implies do_specfile. 570 # This happens after checking for mutually-exclusive options. 571 if ($do_mtree || $do_pax) && ! $do_specfile; then 572 do_specfile=true 573 opts="${opts} -s" 574 fi 575} 576 577# wrap_makedev makedev_name ... 578# Invoke a makedev-like function, with additional processing 579# as appropriate for use from the outer level. 580# 581wrap_makedev() 582{ 583 if $do_specfile; then 584 # "." must appear as the first line of the specfile. 585 # "optional" means do not create the directory itself. 586 echo ". type=dir optional" 587 fi 588 "$@" 589} 590 591# makedev_main makedev_name args... 592# Perform most of the work of the main program. makedev_name 593# is typically "makedev", but may be the name of some other 594# makedev-like function (if we are invoked from MAKEDEV.local or 595# some other script). The other args to this function are the 596# command line args with which the MAKEDEV (or MAKEDEV.local) 597# script was invoked. 598# 599makedev_main() 600{ 601 local makedev="$1" ; shift 602 603 # Parse command line args 604 setup ${1+"$@"} 605 shift $((${OPTIND}-1)) 606 607 if $do_create_mfs; then 608 # Count inodes and create mfs file system. 609 # The makedev call merely updates $count_nodes. 610 count_nodes=0 611 $makedev ${1+"$@"} 612 create_mfs_dev $count_nodes 613 unset count_nodes 614 fi 615 616 # If using mtree or pax, then wrap_makedev should print an mtree 617 # specification, which we postprocess to create the device nodes. 618 # Otherwise, wrap_makedev should do all the work itself. 619 if $do_mtree ; then 620 wrap_makedev $makedev ${1+"$@"} \ 621 | nooutput -1 "${TOOL_MTREE}" -e -U 622 elif $do_pax ; then 623 wrap_makedev $makedev ${1+"$@"} \ 624 | ( 625 # Run pax in an empty directory, so it pays 626 # attention only to the specfile, without being 627 # confused by the existing contents of the target 628 # directory. Without this, pax would complain "file 629 # would overwrite itself" for already-existing 630 # device nodes. 631 tmpdir=./tmp.$$ 632 mkdir "${tmpdir}" || die "can't create temporary directory" 633 cd "${tmpdir}" || die "can't cd to temporary directory" 634 "${TOOL_PAX}" -r -w -M -pe .. 635 status=$? 636 cd .. # back to where we started 637 rmdir "${tmpdir}" 638 exit $status 639 ) 640 else 641 wrap_makedev $makedev ${1+"$@"} 642 fi 643} 644 645# 646# functions available to create nodes: 647# 648# mkdev name [b|c] major minor [mode{=600} [gid{=0} [uid{=0}]]] 649# create device node `name' with the appropriate permissions 650# 651# lndev src target 652# create a symlink from src to target 653# 654# makedir dir mode 655# create directory with appropriate mode 656# 657 658mkdev() 659{ 660 if [ -n "$count_nodes" ]; then 661 count_nodes=$((count_nodes + 1)) 662 return 663 fi 664 if $do_specfile; then 665 case $2 in 666 b) type=block ;; 667 c) type=char ;; 668 esac 669 echo "./$1 type=${type} device=netbsd,$3,$4 mode=${5:-600} gid=${6:-$g_wheel} uid=${7:-$u_root}" 670 else 671 ${MKNOD} -m ${5:-600} -g \#${6:-$g_wheel} -u \#${7:-$u_root} $1 $2 $3 $4 672 fi 673} 674 675lndev() 676{ 677 if [ -n "$count_nodes" ]; then 678 count_nodes=$((count_nodes + 1)) 679 return 680 fi 681 if $do_specfile; then 682 echo "./$2 type=link link=$1 mode=0700 gid=$g_wheel uid=$u_root" 683 else 684 ln -f -s $1 $2 685 fi 686} 687 688makedir() 689{ 690 if [ -n "$count_nodes" ]; then 691 count_nodes=$((count_nodes + 1)) 692 return 693 fi 694 if $do_specfile; then 695 echo "./$1 type=dir mode=$2 gid=$g_wheel uid=$u_root" 696 else 697 nooutput -2 mkdir $1 698 chmod $2 $1 699 fi 700} 701 702warn() 703{ 704 echo 1>&2 "$0: $*" 705} 706 707die() 708{ 709 echo 1>&2 "$0: $*" 710 exit 1 711} 712 713# makedev special [...] 714# the main loop 715# 716makedev() 717{ 718 719for i 720do 721 722case $i in 723 724%MD_DEVICES% 725 726all) 727 makedev all_md 728 makedev std fd ptm pty0 pty1 pty2 pty3 729 makedev ccd0 ccd1 ccd2 ccd3 730 makedev cgd0 cgd1 cgd2 cgd3 731 makedev fss0 fss1 fss2 fss3 732 makedev md0 md1 733 makedev raid0 raid1 raid2 raid3 raid4 raid5 raid6 raid7 734 makedev vnd0 vnd1 vnd2 vnd3 735 makedev bpf 736 makedev tun0 tun1 tun2 tun3 737 makedev ipl pf crypto random 738 makedev lockstat clockctl cpuctl 739 makedev atabus0 atabus1 atabus2 atabus3 740 makedev tap tap0 tap1 tap2 tap3 741 makedev gpio gpio0 gpio1 gpio2 gpio3 gpio4 gpio5 gpio6 gpio7 742 makedev pad pad0 pad1 pad2 pad3 743 makedev bthub 744 makedev putter 745 makedev drvctl 746 makedev video 747 makedev drm0 748 makedev altmem 749 makedev zfs 750 makedev local # do this last 751 ;; 752 753init) 754 # unless overridden by MD entry, this is equal to 'all' 755 makedev all 756 ;; 757 758%MI_DEVICES_BEGIN% 759audio) 760 makedev audio0 audio1 audio2 audio3 761 makedev hdaudio0 hdaudio1 hdaudio2 hdaudio3 762 lndev sound0 sound 763 lndev audio0 audio 764 lndev mixer0 mixer 765 lndev audioctl0 audioctl 766 ;; 767 768gpio) 769 makedev gpio0 gpio1 gpio2 gpio3 gpio4 gpio5 gpio6 gpio7 770 lndev gpio0 gpio 771 ;; 772 773pad) 774 makedev pad0 pad1 pad2 pad3 775 lndev pad0 pad 776 ;; 777 778radio) 779 makedev radio0 radio1 780 lndev radio0 radio 781 ;; 782 783video) 784 makedev video0 video1 video2 video3 785 ;; 786 787altmem) 788 makedev altmem0 altmem1 789 ;; 790 791ramdisk) 792 makedev floppy md0 793 ;; 794 795usbs) 796 makedev usb usb0 usb1 usb2 usb3 usb4 usb5 usb6 usb7 797 makedev uhid0 uhid1 uhid2 uhid3 798 makedev ulpt0 ulpt1 799 makedev ttyU0 ttyU1 800 makedev ttyY0 ttyY1 801 makedev ttyHS0 802 makedev urio0 803 makedev uscanner0 uscanner1 804 makedev utoppy0 utoppy1 805 makedev ugen0 806 ;; 807 808isdns) 809 makedev isdn isdnctl isdnbchan0 isdnbchan1 isdntel0 isdntel1 isdnteld0 isdnteld1 isdntrc0 isdntrc1 810 ;; 811 812std) 813 mkdev console c %cons_chr% 0 600 814 mkdev constty c %cons_chr% 1 600 815 mkdev drum c %swap_chr% 0 640 $g_kmem 816 mkdev kmem c %mem_chr% 1 640 $g_kmem 817 mkdev mem c %mem_chr% 0 640 $g_kmem 818 mkdev null c %mem_chr% 2 666 819 mkdev zero c %mem_chr% 12 666 820 mkdev klog c %log_chr% 0 600 821 mkdev ksyms c %ksyms_chr% 0 444 822 if ! $fdesc_mounted; then 823 mkdev tty c %ctty_chr% 0 666 824 mkdev stdin c %filedesc_chr% 0 666 825 mkdev stdout c %filedesc_chr% 1 666 826 mkdev stderr c %filedesc_chr% 2 666 827 fi 828 ;; 829 830usb) 831 mkdev usb c %usb_chr% 255 444 832 ;; 833 834usb*) 835 unit=${i#usb} 836 usb=usb$unit 837 mkdev usb$unit c %usb_chr% $unit 838 ;; 839 840uhid*) 841 unit=${i#uhid} 842 mkdev uhid$unit c %uhid_chr% $unit 666 843 ;; 844 845ulpt*) 846 unit=${i#ulpt} 847 mkdev ulpt$unit c %ulpt_chr% $unit 848 mkdev ulpn$unit c %ulpt_chr% $(($unit + 64)) 849 ;; 850 851urio*) 852 unit=${i#urio} 853 mkdev urio$unit c %urio_chr% $unit 666 854 ;; 855 856uscanner*) 857 unit=${i#uscanner} 858 mkdev uscanner$unit c %uscanner_chr% $unit 859 ;; 860 861utoppy*) 862 unit=${i#utoppy} 863 mkdev utoppy$unit c %utoppy_chr% $unit 864 ;; 865 866ttyHS*) 867 unit=${i#ttyHS} 868 for j in 00 01 02 03 04 05 06 07 08 09 10 869 do 870 base=$(($unit * 16 + ${j#0})) 871 mkdev ttyHS$unit.$j c %uhso_chr% $(($base + $dialin )) "" "" $u_uucp 872 mkdev dtyHS$unit.$j c %uhso_chr% $(($base + $dialout )) "" "" $u_uucp 873 mkdev ctyHS$unit.$j c %uhso_chr% $(($base + $callunit)) "" "" $u_uucp 874 done 875 ;; 876 877ttyY*) 878 unit=${i#ttyY} 879 mkdev ttyY$unit c %ucycom_chr% $(($unit + $dialin )) "" "" $u_uucp 880 mkdev dtyY$unit c %ucycom_chr% $(($unit + $dialout )) "" "" $u_uucp 881 mkdev ctyY$unit c %ucycom_chr% $(($unit + $callunit)) "" "" $u_uucp 882 ;; 883 884ttyU*) 885 unit=${i#ttyU} 886 mkdev ttyU$unit c %ucom_chr% $(($unit + $dialin )) "" "" $u_uucp 887 mkdev dtyU$unit c %ucom_chr% $(($unit + $dialout )) "" "" $u_uucp 888 mkdev ctyU$unit c %ucom_chr% $(($unit + $callunit)) "" "" $u_uucp 889 ;; 890 891ugen*) 892 unit=${i#ugen} 893 for j in 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 894 do 895 mkdev ugen$unit.$j c %ugen_chr% $(($unit * 16 + ${j#0})) 896 done 897 ;; 898 899wscons) 900 makedev ttyE0 ttyE1 ttyE2 ttyE3 ttyE4 ttyE5 ttyE6 ttyE7 901 makedev wsmouse0 wsmouse1 wsmouse2 wsmouse3 902 makedev wskbd0 wskbd1 wskbd2 wskbd3 903 makedev wsmux0 wsmux1 wsmux2 wsmux3 904 makedev wsmouse wskbd 905 makedev ttyEcfg ttyEstat 906 makedev wsfont 907 ;; 908 909wsmouse) 910 mkdev wsmouse c %wsmux_chr% 0 911 ;; 912 913wskbd) 914 mkdev wskbd c %wsmux_chr% 1 915 ;; 916 917wsmux*) 918 unit=${i#wsmux} 919 mkdev wsmux$unit c %wsmux_chr% $unit 920 mkdev wsmuxctl$unit c %wsmux_chr% $(($unit + 128)) 200 921 ;; 922 923xenevt) 924 mkdev xenevt c %xenevt_chr% 0 925 ;; 926 927xsd_kva) 928 mkdev xsd_kva c %xenevt_chr% 1 929 ;; 930 931xencons) 932 mkdev xencons c %xencons_chr% 0 933 ;; 934 935ttyEstat) 936 mkdev ttyEstat c %wsdisplay_chr% 254 937 ;; 938 939ttyEcfg) 940 mkdev ttyEcfg c %wsdisplay_chr% 255 941 ;; 942 943ttyE*) 944 unit=${i#ttyE} 945 mkdev ttyE$unit c %wsdisplay_chr% $unit 946 ;; 947 948wsmouse*) 949 unit=${i#wsmouse} 950 mkdev wsmouse$unit c %wsmouse_chr% $unit 951 ;; 952 953wskbd*) 954 unit=${i#wskbd} 955 mkdev wskbd$unit c %wskbd_chr% $unit 956 ;; 957 958fd) 959 if ! $fdesc_mounted; then 960 makedir fd 755 961 n=0 962 while [ $n -lt 64 ] 963 do 964 mkdev fd/$n c %filedesc_chr% $n 666 965 n=$(($n + 1)) 966 done 967 fi 968 ;; 969 970wt*) 971 case $i in 972 wt*) name=wt; unit=${i#wt}; chr=%wt_chr%; blk=%wt_blk%;; 973 esac 974 for sub in $unit $(($unit+8)) $(($unit+16)) 975 do 976 mkdev $name$sub b $blk $(($sub + 0)) 660 $g_operator 977 mkdev n$name$sub b $blk $(($sub + 4)) 660 $g_operator 978 mkdev r$name$sub c $chr $(($sub + 0)) 660 $g_operator 979 mkdev nr$name$sub c $chr $(($sub + 4)) 660 $g_operator 980 done 981 ;; 982 983md*) 984 makedisk_minimal md ${i#md} %md_blk% %md_chr% 985 ;; 986 987fss*) 988 case $i in 989 fss*) name=fss; unit=${i#fss}; blk=%fss_blk%; chr=%fss_chr% 990 esac 991 mkdev $name$unit b $blk $unit 660 $g_operator 992 mkdev r$name$unit c $chr $unit 660 $g_operator 993 ;; 994 995ss*) 996 case $i in 997 ss*) name=ss; unit=${i#ss}; chr=%ss_chr%;; 998 esac 999 mkdev $name$unit c $chr $(($unit * 16 + 0)) 640 $g_operator 1000 mkdev n$name$unit c $chr $(($unit * 16 + 1)) 640 $g_operator 1001 mkdev en$name$unit c $chr $(($unit * 16 + 3)) 640 $g_operator 1002 ;; 1003 1004ccd*|cgd*|raid*|vnd*) 1005 case $i in 1006 ccd*) name=ccd; unit=${i#ccd}; blk=%ccd_blk%; chr=%ccd_chr%;; 1007 cgd*) name=cgd; unit=${i#cgd}; blk=%cgd_blk%; chr=%cgd_chr%;; 1008 raid*) name=raid; unit=${i#raid}; blk=%raid_blk%; chr=%raid_chr%;; 1009 vnd*) name=vnd; unit=${i#vnd}; blk=%vnd_blk%; chr=%vnd_chr%;; 1010 esac 1011 %MKDISK% $name $unit $blk $chr 1012 ;; 1013 1014sd*) 1015 name=sd; unit=${i#sd}; blk=%sd_blk%; chr=%sd_chr% 1016 %MKDISK% $name $unit $blk $chr 1017 ;; 1018 1019wd*) 1020 name=wd; unit=${i#wd}; blk=%wd_blk%; chr=%wd_chr% 1021 %MKDISK% $name $unit $blk $chr 1022 ;; 1023 1024fd*) 1025 name=fd; unit=${i#fd}; blk=%fd_blk%; chr=%fd_chr% 1026 %MKDISK% $name $unit $blk $chr 1027 ;; 1028 1029ld*) 1030 name=ld; unit=${i#ld}; blk=%ld_blk%; chr=%ld_chr% 1031 %MKDISK% $name $unit $blk $chr 1032 ;; 1033 1034altmem*) 1035 name=altmem; unit=${i#altmem}; blk=%altmem_blk%; chr=%altmem_chr% 1036 %MKDISK% $name $unit $blk $chr 1037 ;; 1038 1039bio) 1040 mkdev bio c %bio_chr% 0 1041 ;; 1042 1043ed*) 1044 name=ed; unit=${i#ed}; blk=%ed_blk%; chr=%ed_chr% 1045 %MKDISK% $name $unit $blk $chr 1046 ;; 1047 1048ofdisk*) 1049 name=ofdisk; unit=${i#ofdisk}; blk=%ofdisk_blk%; chr=%ofdisk_chr% 1050 %MKDISK% $name $unit $blk $chr 1051 ;; 1052 1053xbd*) 1054 name=xbd; unit=${i#xbd}; blk=%xbd_blk%; chr=%xbd_chr% 1055 %MKDISK% $name $unit $blk $chr 1056 ;; 1057 1058dk*) 1059 name=dk; unit=${i#dk}; blk=%dk_blk%; chr=%dk_chr% 1060 minor=0 1061 while [ $minor -le ${i#dk} ] 1062 do 1063 mkdev r$name$minor c $chr $minor 0640 $g_operator 1064 mkdev $name$minor b $blk $minor 0640 $g_operator 1065 minor=$(($minor + 1)) 1066 done 1067 ;; 1068 1069ttyCY*) 1070 name=tyCY; chr=%cy_chr%; off=32 1071 unit=${i#t${name}} 1072 minor=$(($unit * $off)) 1073 eminor=$(($minor + $off)) 1074 while [ $minor -lt $eminor ] 1075 do 1076 nminor=000$minor 1077 nminor=${nminor#${nminor%???}} 1078 mkdev t$name$nminor c $chr $(($minor + $dialin )) "" "" $u_uucp 1079 mkdev d$name$nminor c $chr $(($minor + $dialout)) "" "" $u_uucp 1080 minor=$(($minor + 1)) 1081 done 1082 ;; 1083 1084ttyCZ*) 1085 name=tyCZ; chr=%cz_chr%; off=64 1086 unit=${i#t${name}} 1087 minor=$(($unit * $off)) 1088 eminor=$(($minor + $off)) 1089 while [ $minor -lt $eminor ] 1090 do 1091 nminor=0000$minor 1092 nminor=${nminor#${nminor%????}} 1093 mkdev t$name$nminor c $chr $(($minor + $dialin )) "" "" $u_uucp 1094 mkdev d$name$nminor c $chr $(($minor + $dialout)) "" "" $u_uucp 1095 minor=$(($minor + 1)) 1096 done 1097 ;; 1098 1099 1100tty[0-9]|tty0[0-9]) 1101 # some archs have built-in zstty (major %zstty_chr%) instead 1102 # of NS16550; create ttyZ* and hardlink as [dt]ty0*; this 1103 # needs to be before com entry, for archs which have both 1104 unit=${i#tty} 1105 unit=$(($unit + 0)) 1106 makedev ttyZ${unit} 1107 lndev ttyZ$unit tty0${unit} 1108 lndev dtyZ$unit dty0${unit} 1109 ;; 1110 1111tty0*|tty1*|tty[0-9]) 1112 unit=${i#tty} 1113 ounit=00$unit 1114 ounit=${ounit#${ounit%??}} 1115 mkdev tty$ounit c %com_chr% $(($unit + $dialin )) "" "" $u_uucp 1116 mkdev dty$ounit c %com_chr% $(($unit + $dialout)) "" "" $u_uucp 1117 ;; 1118 1119ttyC*) 1120 # some archs call com_chr ttyC traditionally 1121 unit=${i#ttyC}; name=ttyC; dname=dtyC; chr=%com_chr% 1122 mkdev $name$unit c $chr $(($unit + $dialin )) "" "" $u_uucp 1123 mkdev $dname$unit c $chr $(($unit + $dialout)) "" "" $u_uucp 1124 ;; 1125 1126ttyh*) 1127 unit=${i#ttyh}; name=ttyh; dname=dtyh; chr=%sabtty_chr% 1128 mkdev $name$unit c $chr $(($unit + $dialin )) "" "" $u_uucp 1129 mkdev $dname$unit c $chr $(($unit + $dialout)) "" "" $u_uucp 1130 ;; 1131 1132ttyTX*) 1133 unit=${i#ttyTX}; name=ttyTX0; dname=dtyTX0; chr=%txcom_chr% 1134 mkdev $name$unit c $chr $(($unit + $dialin )) "" "" $u_uucp 1135 mkdev $dname$unit c $chr $(($unit + $dialout)) "" "" $u_uucp 1136 ;; 1137 1138ttyZ*) 1139 unit=${i#ttyZ}; name=ttyZ; dname=dtyZ; chr=%zstty_chr% 1140 mkdev $name$unit c $chr $(($unit + $dialin )) "" "" $u_uucp 1141 mkdev $dname$unit c $chr $(($unit + $dialout)) "" "" $u_uucp 1142 ;; 1143 1144opty) 1145 for j in 0 1 2 3 4 5 6 7 8 9 a b c d e f 1146 do 1147 case $j in 1148 [0-9]) jn=$j ;; 1149 a) jn=10 ;; 1150 b) jn=11 ;; 1151 c) jn=12 ;; 1152 d) jn=13 ;; 1153 e) jn=14 ;; 1154 f) jn=15 ;; 1155 esac 1156 mkdev ttyp$j c %pts_chr% $jn 666 1157 mkdev ptyp$j c %ptc_chr% $jn 666 1158 done 1159 ;; 1160 1161pty*) 1162 class=${i#pty} 1163 d1="p q r s t u v w x y z P Q R S T" 1164 if [ "$class" -ge 64 ] 1165 then 1166 warn "$i: pty unit must be between 0 and 63" 1167 continue 1168 elif [ "$class" -lt 16 ] 1169 then 1170 offset=0 1171 mult=0 1172 d2="0 1 2 3 4 5 6 7 8 9 a b c d e f" 1173 else 1174 class=$(($class - 16)) 1175 offset=256 1176 mult=2 1177 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" 1178 fi 1179 start=$(($class * 16)) 1180 set -- $d2 1181 nt=$# 1182 s1=$(($start / $nt)) 1183 set -- $d1 1184 shift $s1 1185 t1=$1 1186 if [ "$t1" = v ]; then 1187 warn "$i: pty unit conflicts with console ttyv0 device" 1188 continue 1189 fi 1190 s2=$(($start % ($nt - $s1 * $mult))) 1191 set -- $d2 1192 shift $s2 1193 t2=$1 1194 unit=$(($start + $offset - $s1 * $mult)) 1195 end=$(($unit + 16)) 1196 while [ "$unit" -lt "$end" ] 1197 do 1198 mkdev tty$t1$t2 c %pts_chr% $unit 666 1199 mkdev pty$t1$t2 c %ptc_chr% $unit 666 1200 shift 1201 t2=$1 1202 if [ -z "$t2" ] 1203 then 1204 break 1205 fi 1206 unit=$(($unit + 1)) 1207 done 1208 ;; 1209 1210stic*) 1211 unit=${i#stic} 1212 mkdev stic$unit c %stic_chr% $unit 1213 ;; 1214 1215st*) 1216 case $i in 1217 st*) name=st; unit=${i#st}; chr=%st_chr%; blk=%st_blk%;; 1218 esac 1219 mkdev $name$unit b $blk $(($unit * 16 + 0)) 660 $g_operator 1220 mkdev n$name$unit b $blk $(($unit * 16 + 1)) 660 $g_operator 1221 mkdev e$name$unit b $blk $(($unit * 16 + 2)) 660 $g_operator 1222 mkdev en$name$unit b $blk $(($unit * 16 + 3)) 660 $g_operator 1223 mkdev r$name$unit c $chr $(($unit * 16 + 0)) 660 $g_operator 1224 mkdev nr$name$unit c $chr $(($unit * 16 + 1)) 660 $g_operator 1225 mkdev er$name$unit c $chr $(($unit * 16 + 2)) 660 $g_operator 1226 mkdev enr$name$unit c $chr $(($unit * 16 + 3)) 660 $g_operator 1227 ;; 1228 1229ses*|ch*|uk*) 1230 case $i in 1231 ch*) name=ch; unit=${i#ch}; chr=%ch_chr%;; 1232 uk*) name=uk; unit=${i#uk}; chr=%uk_chr%;; 1233 ses*) name=ses; unit=${i#ses}; chr=%ses_chr%;; 1234 esac 1235 mkdev $name$unit c $chr $unit 640 $g_operator 1236 ;; 1237 1238cd*) 1239 makedisk_minimal cd ${i#cd} %cd_blk% %cd_chr% 1240 ;; 1241 1242mcd*) 1243 makedisk_minimal mcd ${i#mcd} %mcd_blk% %mcd_chr% 1244 ;; 1245 1246gdrom*) 1247 makedisk_minimal gdrom ${i#gdrom} %gdrom_blk% %gdrom_chr% 1248 ;; 1249 1250lpt*|lpa*) 1251 case $i in 1252 lpt*) name=lpt; unit=${i#lpt}; chr=%lpt_chr%; flags=0;; 1253 lpa*) name=lpa; unit=${i#lpa}; chr=%lpt_chr%; flags=128;; 1254 esac 1255 mkdev $name$unit c $chr $(($unit + $flags)) 1256 mkdev lpt${unit}ctl c $chr $(($unit + 256)) 1257 ;; 1258 1259bpf) 1260 mkdev bpf c %bpf_chr% 0 1261 lndev bpf bpf0 1262 ;; 1263 1264bthub) 1265 mkdev bthub c %bthub_chr% 0 1266 ;; 1267 1268tun*) 1269 unit=${i#tun} 1270 mkdev tun$unit c %tun_chr% $unit 1271 ;; 1272 1273joy*) 1274 unit=${i#joy} 1275 mkdev joy$unit c %joy_chr% $unit 1276 ;; 1277 1278ipl) 1279 mkdev ipl c %ipl_chr% 0 1280 mkdev ipnat c %ipl_chr% 1 1281 mkdev ipstate c %ipl_chr% 2 1282 mkdev ipauth c %ipl_chr% 3 1283 mkdev ipsync c %ipl_chr% 4 1284 mkdev ipscan c %ipl_chr% 5 1285 mkdev iplookup c %ipl_chr% 6 1286 ;; 1287 1288pf) 1289 mkdev pf c %pf_chr% 0 1290 ;; 1291 1292crypto) 1293 mkdev crypto c %crypto_chr% 0 666 1294 ;; 1295 1296cmos) 1297 mkdev cmos c %cmos_chr% 0 644 1298 ;; 1299 1300speaker) 1301 mkdev speaker c %spkr_chr% 0 1302 ;; 1303 1304lockstat) 1305 mkdev lockstat c %lockstat_chr% 0 1306 ;; 1307 1308cpuctl) 1309 mkdev cpuctl c %cpuctl_chr% 0 666 1310 ;; 1311 1312audio*) 1313 unit=${i#audio} 1314 audio=audio$unit 1315 sound=sound$unit 1316 mixer=mixer$unit 1317 audioctl=audioctl$unit 1318 : ${unit:-0} 1319 mkdev $sound c %audio_chr% $(($unit + 0)) 666 1320 mkdev $audio c %audio_chr% $(($unit + 128)) 666 1321 mkdev $mixer c %audio_chr% $(($unit + 16)) 666 1322 mkdev $audioctl c %audio_chr% $(($unit + 192)) 666 1323 ;; 1324 1325hdaudio*) 1326 unit=${i#hdaudio} 1327 mkdev hdaudio$unit c %hdaudio_chr% $unit 644 1328 ;; 1329 1330gpio*) 1331 unit=${i#gpio} 1332 mkdev gpio$unit c %gpio_chr% $unit 644 1333 ;; 1334 1335rmidi*) 1336 unit=${i#rmidi} 1337 mkdev rmidi$unit c %midi_chr% $unit 666 1338 ;; 1339 1340music*) 1341 unit=${i#music} 1342 : ${unit:-0} 1343 mkdev music$unit c %sequencer_chr% $(($unit + 0)) 666 1344 mkdev sequencer$unit c %sequencer_chr% $(($unit + 128)) 666 1345 ;; 1346 1347radio*) 1348 unit=${i#radio} 1349 : ${unit:-0} 1350 mkdev radio$unit c %radio_chr% $unit 666 1351 ;; 1352 1353video*) 1354 unit=${i#video} 1355 : ${unit:-0} 1356 mkdev video$unit c %video_chr% $unit 666 1357 ;; 1358 1359amr*) 1360 unit=${i#amr} 1361 mkdev amr$unit c %amr_chr% $unit 1362 ;; 1363 1364apm) 1365 mkdev apm c %apm_chr% 0 644 1366 mkdev apmctl c %apm_chr% 8 644 1367 ;; 1368 1369apm) 1370 # hpcmips uses `apmdev_chr' instead of `apm_chr' 1371 mkdev apm c %apmdev_chr% 0 644 1372 mkdev apmctl c %apmdev_chr% 8 644 1373 ;; 1374 1375satlink*) 1376 unit=${i#satlink} 1377 mkdev satlink$unit c %satlink_chr% $unit 444 1378 ;; 1379 1380random) 1381 mkdev random c %rnd_chr% 0 444 1382 mkdev urandom c %rnd_chr% 1 644 1383 ;; 1384 1385cfs) 1386 makedev cfs0 1387 ;; 1388 1389cfs*) 1390 unit=${i#cfs} 1391 mkdev cfs$unit c %vcoda_chr% $unit 1392 ;; 1393 1394sysmon) 1395 mkdev sysmon c %sysmon_chr% 0 644 1396 mkdev watchdog c %sysmon_chr% 1 644 1397 mkdev power c %sysmon_chr% 2 640 1398 ;; 1399 1400scsibus*) 1401 unit=${i#scsibus} 1402 mkdev scsibus$unit c %scsibus_chr% $unit 644 1403 ;; 1404 1405bktr) 1406 makedev bktr0 bktr1 1407 lndev bktr0 bktr 1408 lndev tuner0 tuner 1409 lndev vbi0 vbi 1410 ;; 1411 1412bktr*) 1413 unit=${i#bktr} 1414 mkdev bktr$unit c %bktr_chr% $(($unit + 0)) 444 1415 mkdev tuner$unit c %bktr_chr% $(($unit + 16)) 444 1416 mkdev vbi$unit c %bktr_chr% $(($unit + 32)) 444 1417 ;; 1418 1419io) 1420 mkdev io c %mem_chr% 14 600 1421 ;; 1422 1423iop*) 1424 unit=${i#iop} 1425 mkdev iop$unit c %iop_chr% $unit 1426 ;; 1427 1428mlx*) 1429 unit=${i#mlx} 1430 mkdev mlx$unit c %mlx_chr% $unit 1431 ;; 1432 1433mly*) 1434 unit=${i#mly} 1435 mkdev mly$unit c %mly_chr% $unit 1436 ;; 1437 1438twa*) 1439 unit=${i#twa} 1440 mkdev twa$unit c %twa_chr% $unit 1441 ;; 1442 1443twe*) 1444 unit=${i#twe} 1445 mkdev twe$unit c %twe_chr% $unit 1446 ;; 1447 1448icp*) 1449 unit=${i#icp} 1450 mkdev icp$unit c %icp_chr% $unit 1451 ;; 1452 1453agp*) 1454 unit=${i#agp} 1455 mkdev agp$unit c %agp_chr% $unit 644 1456 if [ "$unit" = "0" ]; then 1457 lndev agp$unit agpgart 1458 fi 1459 ;; 1460 1461pci*) 1462 unit=${i#pci} 1463 mkdev pci$unit c %pci_chr% $unit 644 1464 ;; 1465 1466dpti*) 1467 unit=${i#dpti} 1468 mkdev dpti$unit c %dpti_chr% $unit 1469 ;; 1470 1471dpt*) 1472 unit=${i#dpt} 1473 mkdev dpt$unit c %dpt_chr% $unit 1474 ;; 1475 1476altq) 1477 makedir altq 755 1478 unit=0 1479 for dev in altq cbq wfq afm fifoq red rio localq hfsc cdnr blue priq 1480 do 1481 mkdev altq/$dev c %altq_chr% $unit 644 1482 unit=$(($unit + 1)) 1483 done 1484 ;; 1485 1486isdn) 1487 mkdev isdn c %isdn_chr% 0 1488 ;; 1489 1490isdnctl) 1491 mkdev isdnctl c %isdnctl_chr% 0 1492 ;; 1493 1494isdnbchan*) 1495 unit=${i#isdnbchan} 1496 mkdev isdnbchan$unit c %isdnbchan_chr% $unit 1497 ;; 1498 1499isdnteld*) 1500 unit=${i#isdnteld} 1501 mkdev isdnteld$unit c %isdntel_chr% $(($unit + 64)) 1502 ;; 1503 1504isdntel*) 1505 unit=${i#isdntel} 1506 mkdev isdntel$unit c %isdntel_chr% $unit 1507 ;; 1508 1509isdntrc*) 1510 unit=${i#isdntrc} 1511 mkdev isdntrc$unit c %isdntrc_chr% $unit 1512 ;; 1513 1514vmegen) 1515 makedev vmegen0 vmegen1 vmegen2 vmegen3 1516 ;; 1517 1518vmegen*) 1519 unit=${i#vmegen} 1520 mkdev vmegen$unit c %vmegeneric_chr% $(($unit * 16 + 0)) 1521 ;; 1522 1523wsfont) 1524 mkdev wsfont c %wsfont_chr% 0 1525 ;; 1526 1527cir*) 1528 unit=${i#cir} 1529 mkdev cir$unit c %cir_chr% $unit 666 1530 ;; 1531 1532irframe*) 1533 unit=${i#irframe} 1534 mkdev irframe$unit c %irframe_chr% $unit 1535 ;; 1536 1537fcom*) 1538 unit=${i#fcom} 1539 mkdev fcom$unit c %fcom_chr% $unit "" "" $u_uucp 1540 ;; 1541 1542openfirm) 1543 mkdev openfirm c %openfirm_chr% 0 444 1544 ;; 1545 1546pad*) 1547 unit=${i#pad} 1548 mkdev pad$unit c %pad_chr% $unit 444 1549 ;; 1550 1551nvram) 1552 mkdev nvram c %nvram_chr% 0 644 1553 ;; 1554 1555rtc) 1556 mkdev rtc c %rtc_chr% 0 644 1557 ;; 1558 1559clockctl) 1560 mkdev clockctl c %clockctl_chr% 0 660 $g_ntpd 1561 ;; 1562 1563nsmb) 1564 makedev nsmb0 nsmb1 nsmb2 nsmb3 1565 ;; 1566 1567nsmb*) 1568 unit=${i#nsmb} 1569 mkdev nsmb$unit c %nsmb_chr% $unit 644 1570 ;; 1571 1572kttcp) 1573 mkdev kttcp c %kttcp_chr% 0 1574 ;; 1575 1576dmoverio) 1577 mkdev dmoverio c %dmoverio_chr% 0 644 1578 ;; 1579 1580veriexec) 1581 mkdev veriexec c %veriexec_chr% 0 600 1582 ;; 1583 1584ttyv*) 1585 unit=${i#ttyv} 1586 mkdev ttyv$unit c %pc_chr% $unit 1587 ;; 1588 1589# arm, acorn32 1590ttyv*) 1591 unit=${i#ttyv} 1592 mkdev ttyv$unit c %physcon_chr% $unit 1593 ;; 1594 1595arcpp*) 1596 unit=${i#arcpp} 1597 mkdev arcpp$unit c %arcpp_chr% $unit 1598 ;; 1599 1600par*) 1601 unit=${i#par} 1602 case $unit in 1603 0) 1604 mkdev par$unit c %par_chr% $unit 1605 ;; 1606 *) 1607 warn "bad unit for par in: $i" 1608 ;; 1609 esac 1610 ;; 1611 1612cpi*) 1613 unit=${i#cpi} 1614 mkdev cpi$unit c %cpi_chr% $unit 1615 ;; 1616 1617ite*|ttye*) 1618 case $i in 1619 ite*) unit=${i#ite};; 1620 ttye*) unit=${i#ttye};; 1621 esac 1622 mkdev ttye$unit c %ite_chr% $unit 1623 ;; 1624 1625pms*) 1626 unit=${i#pms} 1627 mkdev pms$unit c %opms_chr% $unit 1628 ;; 1629 1630qms*) 1631 unit=${i#qms} 1632 mkdev qms$unit c %qms_chr% $unit 1633 ;; 1634 1635lms*) 1636 unit=${i#lms} 1637 mkdev lms$unit c %lms_chr% $unit 1638 ;; 1639 1640mms*) 1641 unit=${i#mms} 1642 mkdev mms$unit c %mms_chr% $unit 1643 ;; 1644 1645mouse-*) 1646 case $i in 1647 mouse-pms*) name=pms ;; 1648 mouse-qms*) name=qms ;; 1649 esac 1650 unit=${i#mouse-${name}} 1651 lndev $name$unit mouse 1652 ;; 1653 1654kbd) 1655 mkdev kbd c %kbd_chr% 0 1656 ;; 1657 1658kbdctl) 1659 mkdev kbdctl c %kbd_chr% 1 1660 ;; 1661 1662vidcconsole0) 1663 mkdev vidcconsole0 c %vidcconsole_chr% 0 640 1664 ;; 1665 1666view*) 1667 unit=${i#view} 1668 mkdev view$unit c %view_chr% $unit 666 1669 ;; 1670 1671mouse*) 1672 unit=${i#mouse} 1673 case $unit in 1674 0|1) 1675 mkdev mouse$unit c %ms_chr% $unit 666 1676 if [ $unit = 0 ]; then 1677 lndev mouse$unit mouse 1678 fi 1679 ;; 1680 *) 1681 warn "bad unit for mouse in: $i" 1682 ;; 1683 esac 1684 ;; 1685 1686panel) 1687 mkdev panel0 c %panel_chr% 0 660 1688 ;; 1689 1690tslcd) 1691 mkdev tslcd0 c %tslcd_chr% 0 660 1692 ;; 1693 1694ipty) 1695 mkdev ttyp0 c %pts_chr% 0 666 1696 mkdev ttyp1 c %pts_chr% 1 666 1697 mkdev ptyp0 c %ptc_chr% 0 666 1698 mkdev ptyp1 c %ptc_chr% 1 666 1699 ;; 1700 1701ptm) 1702 makedir pts 755 1703 mkdev ptmx c %ptm_chr% 0 666 1704 mkdev ptm c %ptm_chr% 1 666 1705 ;; 1706 1707grf*) 1708 unit=${i#grf} 1709 mkdev grf$unit c %grf_chr% $unit 666 1710 ;; 1711 1712etvme) 1713 mkdev etvme c %et_chr% 0 1714 ;; 1715 1716leo*) 1717 unit=${i#leo} 1718 mkdev leo$unit c %leo_chr% $unit 1719 ;; 1720 1721scif*) 1722 unit=${i#scif} 1723 mkdev scif$unit c %scif_chr% $(($unit + $dialin )) "" "" $u_uucp 1724 mkdev dscif$unit c %scif_chr% $(($unit + $dialout)) "" "" $u_uucp 1725 ;; 1726 1727sci*) 1728 unit=${i#sci} 1729 mkdev sci$unit c %sci_chr% $(($unit + $dialin )) "" "" $u_uucp 1730 mkdev dsci$unit c %sci_chr% $(($unit + $dialout)) "" "" $u_uucp 1731 ;; 1732 1733maple*) 1734 case $i in 1735 mapleA*) name="mapleA"; unit=0;; 1736 mapleB*) name="mapleB"; unit=1;; 1737 mapleC*) name="mapleC"; unit=2;; 1738 mapleD*) name="mapleD"; unit=3;; 1739 esac 1740 subunit=${i#$name} 1741 mkdev $name$subunit c %maple_chr% $(($unit * 8 + 0$subunit)) 1742 ;; 1743 1744mmem*) 1745 unit=${i#mmem} 1746 for pt in 0 # 1 2 3 4 ... 255 1747 do 1748# mkdev mmem${unit}.${pt}a b %mmem_blk% $(($unit * 4096 + $pt * 16 + 0)) 640 $g_operator 1749 mkdev mmem${unit}.${pt}c b %mmem_blk% $(($unit * 4096 + $pt * 16 + 2)) 640 $g_operator 1750# mkdev rmmem${unit}.${pt}a c %mmem_chr% $(($unit * 4096 + $pt * 16 + 0)) 640 $g_operator 1751 mkdev rmmem${unit}.${pt}c c %mmem_chr% $(($unit * 4096 + $pt * 16 + 2)) 640 $g_operator 1752 done 1753 ;; 1754 1755mlcd*) 1756 unit=${i#mlcd} 1757 for pt in 0 # 1 2 3 4 ... 255 1758 do 1759 mkdev mlcd${unit}.${pt} c %mlcd_chr% $(($unit * 256 + $pt)) 640 $g_operator 1760 done 1761 ;; 1762 1763ixpcom*) 1764 unit=${i#ixpcom} 1765 mkdev ixpcom$unit c %ixpcom_chr% $unit "" "" $u_uucp 1766 ;; 1767 1768epcom*) 1769 unit=${i#epcom} 1770 mkdev epcom$unit c %epcom_chr% $unit "" "" $u_uucp 1771 ;; 1772 1773ucbsnd) 1774 mkdev ucbsnd c %ucbsnd_chr% 0 666 1775 ;; 1776 1777adb) 1778 mkdev adb c %aed_chr% 0 666 1779 ;; 1780 1781asc*) 1782 unit=${i#asc} 1783 mkdev asc$unit c %asc_chr% $unit 666 1784 ;; 1785 1786bwtwo*) 1787 unit=${i#bwtwo} 1788 mkdev bwtwo$unit c %bwtwo_chr% $unit 666 1789 ;; 1790 1791cgtwo*) 1792 unit=${i#cgtwo} 1793 mkdev cgtwo$unit c %cgtwo_chr% $unit 666 1794 ;; 1795 1796cgthree*) 1797 unit=${i#cgthree} 1798 mkdev cgthree$unit c %cgthree_chr% $unit 666 1799 ;; 1800 1801cgfour*) 1802 unit=${i#cgfour} 1803 mkdev cgfour$unit c %cgfour_chr% $unit 666 1804 ;; 1805 1806cgsix*) 1807 unit=${i#cgsix} 1808 mkdev cgsix$unit c %cgsix_chr% $unit 666 1809 ;; 1810 1811cgeight*) 1812 unit=${i#cgeight} 1813 mkdev cgeight$unit c %cgeight_chr% $unit 666 1814 ;; 1815 1816tcx*) 1817 unit=${i#tcx} 1818 mkdev tcx$unit c %tcx_chr% $unit 666 1819 ;; 1820 1821xd*|xy*) 1822 case $i in 1823 xd*) name=xd; unit=${i#xd}; blk=%xd_blk%; chr=%xd_chr%;; 1824 xy*) name=xy; unit=${i#xy}; blk=%xy_blk%; chr=%xy_chr%;; 1825 esac 1826 %MKDISK% $name $unit $blk $chr 1827 ;; 1828 1829magma*) 1830 unit=${i#magma} 1831 if [ 0$unit -gt 3 ]; then 1832 warn "bad unit for $i: $unit" 1833 break 1834 fi 1835 for j in 0 1 2 3 4 5 6 7 8 9 a b c d e f 1836 do 1837 case $j in 1838 [0-9]) jn=$j ;; 1839 a) jn=10 ;; 1840 b) jn=11 ;; 1841 c) jn=12 ;; 1842 d) jn=13 ;; 1843 e) jn=14 ;; 1844 f) jn=15 ;; 1845 esac 1846 mkdev tty$unit$j c %mtty_chr% $(($unit * 64 + $jn)) 1847 done 1848 mkdev bpp${unit}0 c %mbpp_chr% $(($unit * 64 + 0)) 1849 mkdev bpp${unit}1 c %mbpp_chr% $(($unit * 64 + 1)) 1850 ;; 1851 1852clcd*) 1853 unit=${i#clcd} 1854 if [ 0$unit -gt 7 ]; then 1855 warn "bad unit for $i: $unit" 1856 break 1857 fi 1858 for j in 0 1 2 3 4 5 6 7 1859 do 1860 mkdev ttyA$unit$j c %clcd_chr% $(($unit * 8 + $j + $dialin)) "" "" $u_uucp 1861 mkdev dtyA$unit$j c %clcd_chr% $(($unit * 8 + $j + $dialout)) "" "" $u_uucp 1862 done 1863 ;; 1864 1865spif*) 1866 unit=${i#spif} 1867 if [ 0$unit -gt 3 ]; then 1868 warn "bad unit for $i: $unit" 1869 break 1870 fi 1871 for j in 0 1 2 3 4 5 6 7; do 1872 mkdev ttyS$unit$j c 102 $(($unit * 64 + $j)) "" "" $u_uucp 1873 done 1874 mkdev bppS${unit}0 c 103 $(($unit * 64 + 0)) 1875 mkdev bppS${unit}1 c 103 $(($unit * 64 + 1)) 1876 ;; 1877 1878bpp*) 1879 unit=${i#bpp} 1880 mkdev bpp$unit c %bpp_chr% $(($unit + 0)) 1881 ;; 1882 1883tctrl*) 1884 unit=${i#tctrl} 1885 mkdev tctrl$unit c %tctrl_chr% $unit 666 1886 ;; 1887 1888bmd*) 1889 unit=${i#bmd} 1890 mkdev bmd${unit}a b %bmd_blk% $(($unit * 8 + 0)) 640 $g_operator 1891 mkdev bmd${unit}c b %bmd_blk% $(($unit * 8 + 2)) 640 $g_operator 1892 mkdev rbmd${unit}a c %bmd_chr% $(($unit * 8 + 0)) 640 $g_operator 1893 mkdev rbmd${unit}c c %bmd_chr% $(($unit * 8 + 2)) 640 $g_operator 1894 ;; 1895 1896sram) 1897 mkdev sram c %sram_chr% 0 644 1898 ;; 1899 1900pow*) 1901 unit=${i#pow} 1902 case $unit in 1903 0|1) 1904 mkdev pow${unit} c %pow_chr% ${unit} 644 1905 if [ $unit = 0 ]; then 1906 lndev pow${unit} pow 1907 fi 1908 ;; 1909 *) 1910 warn "bad unit for pow in: $i" 1911 ;; 1912 esac 1913 ;; 1914 1915ttyS*) 1916 unit=${i#ttyS} 1917 mkdev ttyS$unit c %sacom_chr% $(($unit + $dialin )) "" "" $u_uucp 1918 mkdev dtyS$unit c %sacom_chr% $(($unit + $dialout)) "" "" $u_uucp 1919 ;; 1920 1921atabus*) 1922 unit=${i#atabus} 1923 mkdev atabus$unit c %atabus_chr% $unit 644 1924 ;; 1925 1926drm*) 1927 unit=${i#drm} 1928 makedir dri 755 1929 mkdev dri/card$unit c %drm_chr% $unit 660 1930 ;; 1931 1932drvctl) 1933 mkdev drvctl c %drvctl_chr% 0 644 1934 ;; 1935 1936isv) 1937 mkdev isv c %isv_chr% 0 644 1938 ;; 1939 1940tap*) 1941 unit=${i#tap} 1942 case "$unit" in 1943 [0-9]*) 1944 mkdev tap${unit} c %tap_chr% ${unit} 600 1945 ;; 1946 *) 1947 mkdev tap c %tap_chr% 0xfffff 600 1948 ;; 1949 esac 1950 ;; 1951 1952fw*) 1953 unit=${i#fw} 1954 for j in 0 1 2 3 1955 do 1956 mkdev fw${unit}.${j} c %fw_chr% $((${unit} * 256 + ${j})) 660 ${g_operator} 1957 mkdev fwmem${unit}.${j} c %fw_chr% $((65536 + ${unit} * 256 + ${j})) 660 ${g_operator} 1958 done 1959 ;; 1960 1961# create putter device and symlinks for all subsystems using it 1962putter) 1963 mkdev putter c %putter_chr% 0 600 1964 mkdev pud c %putter_chr% 1 600 1965 lndev putter puffs 1966 ;; 1967 1968zfs) 1969 mkdev zfs c %zfs_chr% 0 600 1970 makedir zpool 755 1971 ;; 1972 1973midevend) 1974%MI_DEVICES_END% 1975local) 1976 if [ -f "$0.local" ]; then 1977 umask 0 1978 if [ -n "$count_nodes" ]; then 1979 count_nodes=$((count_nodes + \ 1980 $(linecount "$(sh "$0.local" $opts -s all)") )) 1981 else 1982 sh "$0.local" $opts all 1983 fi 1984 umask 077 1985 fi 1986 ;; 1987 1988*) 1989 warn "$i: unknown device" 1990 ;; 1991 1992esac 1993done 1994 1995} 1996 1997 1998# three variants of disk partitions - max 8, max 16, max 16 with highpartoffset 1999# hack; only the one used by port is retained in final MAKEDEV script 2000# routine is called as: 2001# makedisk name unit blk chr 2002makedisk_p8() 2003{ 2004 name="$1"; unit="$2"; blk="$3"; chr="$4" 2005 2006 mkdev ${name}${unit}a b $blk $(($unit * 8 + 0)) 640 $g_operator 2007 mkdev ${name}${unit}b b $blk $(($unit * 8 + 1)) 640 $g_operator 2008 mkdev ${name}${unit}c b $blk $(($unit * 8 + 2)) 640 $g_operator 2009 mkdev ${name}${unit}d b $blk $(($unit * 8 + 3)) 640 $g_operator 2010 mkdev ${name}${unit}e b $blk $(($unit * 8 + 4)) 640 $g_operator 2011 mkdev ${name}${unit}f b $blk $(($unit * 8 + 5)) 640 $g_operator 2012 mkdev ${name}${unit}g b $blk $(($unit * 8 + 6)) 640 $g_operator 2013 mkdev ${name}${unit}h b $blk $(($unit * 8 + 7)) 640 $g_operator 2014 mkdev r${name}${unit}a c $chr $(($unit * 8 + 0)) 640 $g_operator 2015 mkdev r${name}${unit}b c $chr $(($unit * 8 + 1)) 640 $g_operator 2016 mkdev r${name}${unit}c c $chr $(($unit * 8 + 2)) 640 $g_operator 2017 mkdev r${name}${unit}d c $chr $(($unit * 8 + 3)) 640 $g_operator 2018 mkdev r${name}${unit}e c $chr $(($unit * 8 + 4)) 640 $g_operator 2019 mkdev r${name}${unit}f c $chr $(($unit * 8 + 5)) 640 $g_operator 2020 mkdev r${name}${unit}g c $chr $(($unit * 8 + 6)) 640 $g_operator 2021 mkdev r${name}${unit}h c $chr $(($unit * 8 + 7)) 640 $g_operator 2022} 2023 2024makedisk_p16() 2025{ 2026 name="$1"; unit="$2"; blk="$3"; chr="$4" 2027 2028 mkdev ${name}${unit}a b $blk $(($unit * 16 + 0)) 640 $g_operator 2029 mkdev ${name}${unit}b b $blk $(($unit * 16 + 1)) 640 $g_operator 2030 mkdev ${name}${unit}c b $blk $(($unit * 16 + 2)) 640 $g_operator 2031 mkdev ${name}${unit}d b $blk $(($unit * 16 + 3)) 640 $g_operator 2032 mkdev ${name}${unit}e b $blk $(($unit * 16 + 4)) 640 $g_operator 2033 mkdev ${name}${unit}f b $blk $(($unit * 16 + 5)) 640 $g_operator 2034 mkdev ${name}${unit}g b $blk $(($unit * 16 + 6)) 640 $g_operator 2035 mkdev ${name}${unit}h b $blk $(($unit * 16 + 7)) 640 $g_operator 2036 mkdev ${name}${unit}i b $blk $(($unit * 16 + 8)) 640 $g_operator 2037 mkdev ${name}${unit}j b $blk $(($unit * 16 + 9)) 640 $g_operator 2038 mkdev ${name}${unit}k b $blk $(($unit * 16 + 10)) 640 $g_operator 2039 mkdev ${name}${unit}l b $blk $(($unit * 16 + 11)) 640 $g_operator 2040 mkdev ${name}${unit}m b $blk $(($unit * 16 + 12)) 640 $g_operator 2041 mkdev ${name}${unit}n b $blk $(($unit * 16 + 13)) 640 $g_operator 2042 mkdev ${name}${unit}o b $blk $(($unit * 16 + 14)) 640 $g_operator 2043 mkdev ${name}${unit}p b $blk $(($unit * 16 + 15)) 640 $g_operator 2044 mkdev r${name}${unit}a c $chr $(($unit * 16 + 0)) 640 $g_operator 2045 mkdev r${name}${unit}b c $chr $(($unit * 16 + 1)) 640 $g_operator 2046 mkdev r${name}${unit}c c $chr $(($unit * 16 + 2)) 640 $g_operator 2047 mkdev r${name}${unit}d c $chr $(($unit * 16 + 3)) 640 $g_operator 2048 mkdev r${name}${unit}e c $chr $(($unit * 16 + 4)) 640 $g_operator 2049 mkdev r${name}${unit}f c $chr $(($unit * 16 + 5)) 640 $g_operator 2050 mkdev r${name}${unit}g c $chr $(($unit * 16 + 6)) 640 $g_operator 2051 mkdev r${name}${unit}h c $chr $(($unit * 16 + 7)) 640 $g_operator 2052 mkdev r${name}${unit}i c $chr $(($unit * 16 + 8)) 640 $g_operator 2053 mkdev r${name}${unit}j c $chr $(($unit * 16 + 9)) 640 $g_operator 2054 mkdev r${name}${unit}k c $chr $(($unit * 16 + 10)) 640 $g_operator 2055 mkdev r${name}${unit}l c $chr $(($unit * 16 + 11)) 640 $g_operator 2056 mkdev r${name}${unit}m c $chr $(($unit * 16 + 12)) 640 $g_operator 2057 mkdev r${name}${unit}n c $chr $(($unit * 16 + 13)) 640 $g_operator 2058 mkdev r${name}${unit}o c $chr $(($unit * 16 + 14)) 640 $g_operator 2059 mkdev r${name}${unit}p c $chr $(($unit * 16 + 15)) 640 $g_operator 2060} 2061 2062makedisk_p16high() 2063{ 2064 ho=524280 # offset for partition 9 to 16 2065 name="$1"; unit="$2"; blk="$3"; chr="$4" 2066 2067 mkdev ${name}${unit}a b $blk $(($unit * 8 + 0)) 640 $g_operator 2068 mkdev ${name}${unit}b b $blk $(($unit * 8 + 1)) 640 $g_operator 2069 mkdev ${name}${unit}c b $blk $(($unit * 8 + 2)) 640 $g_operator 2070 mkdev ${name}${unit}d b $blk $(($unit * 8 + 3)) 640 $g_operator 2071 mkdev ${name}${unit}e b $blk $(($unit * 8 + 4)) 640 $g_operator 2072 mkdev ${name}${unit}f b $blk $(($unit * 8 + 5)) 640 $g_operator 2073 mkdev ${name}${unit}g b $blk $(($unit * 8 + 6)) 640 $g_operator 2074 mkdev ${name}${unit}h b $blk $(($unit * 8 + 7)) 640 $g_operator 2075 mkdev ${name}${unit}i b $blk $(($unit * 8 + $ho + 8)) 640 $g_operator 2076 mkdev ${name}${unit}j b $blk $(($unit * 8 + $ho + 9)) 640 $g_operator 2077 mkdev ${name}${unit}k b $blk $(($unit * 8 + $ho + 10)) 640 $g_operator 2078 mkdev ${name}${unit}l b $blk $(($unit * 8 + $ho + 11)) 640 $g_operator 2079 mkdev ${name}${unit}m b $blk $(($unit * 8 + $ho + 12)) 640 $g_operator 2080 mkdev ${name}${unit}n b $blk $(($unit * 8 + $ho + 13)) 640 $g_operator 2081 mkdev ${name}${unit}o b $blk $(($unit * 8 + $ho + 14)) 640 $g_operator 2082 mkdev ${name}${unit}p b $blk $(($unit * 8 + $ho + 15)) 640 $g_operator 2083 mkdev r${name}${unit}a c $chr $(($unit * 8 + 0)) 640 $g_operator 2084 mkdev r${name}${unit}b c $chr $(($unit * 8 + 1)) 640 $g_operator 2085 mkdev r${name}${unit}c c $chr $(($unit * 8 + 2)) 640 $g_operator 2086 mkdev r${name}${unit}d c $chr $(($unit * 8 + 3)) 640 $g_operator 2087 mkdev r${name}${unit}e c $chr $(($unit * 8 + 4)) 640 $g_operator 2088 mkdev r${name}${unit}f c $chr $(($unit * 8 + 5)) 640 $g_operator 2089 mkdev r${name}${unit}g c $chr $(($unit * 8 + 6)) 640 $g_operator 2090 mkdev r${name}${unit}h c $chr $(($unit * 8 + 7)) 640 $g_operator 2091 mkdev r${name}${unit}i c $chr $(($unit * 8 + $ho + 8)) 640 $g_operator 2092 mkdev r${name}${unit}j c $chr $(($unit * 8 + $ho + 9)) 640 $g_operator 2093 mkdev r${name}${unit}k c $chr $(($unit * 8 + $ho + 10)) 640 $g_operator 2094 mkdev r${name}${unit}l c $chr $(($unit * 8 + $ho + 11)) 640 $g_operator 2095 mkdev r${name}${unit}m c $chr $(($unit * 8 + $ho + 12)) 640 $g_operator 2096 mkdev r${name}${unit}n c $chr $(($unit * 8 + $ho + 13)) 640 $g_operator 2097 mkdev r${name}${unit}o c $chr $(($unit * 8 + $ho + 14)) 640 $g_operator 2098 mkdev r${name}${unit}p c $chr $(($unit * 8 + $ho + 15)) 640 $g_operator 2099} 2100 2101# make only the very few basic disk device nodes - 'a' partition 2102# and raw partition 2103makedisk_minimal() 2104{ 2105 name=$1; unit=$2; blk=$3; chr=$4 2106 doff=%DISKMINOROFFSET% 2107 ro=%RAWDISK_OFF% 2108 rn=%RAWDISK_NAME% 2109 2110 mkdev ${name}${unit}a b $blk $(($unit * $doff + 0)) 640 $g_operator 2111 mkdev ${name}${unit}$rn b $blk $(($unit * $doff + $ro)) 640 $g_operator 2112 mkdev r${name}${unit}a c $chr $(($unit * $doff + 0)) 640 $g_operator 2113 mkdev r${name}${unit}$rn c $chr $(($unit * $doff + $ro)) 640 $g_operator 2114} 2115 2116# create_mfs_dev nodes 2117# Create a memory file system for a given number of device nodes, 2118# and mount it. Attempts to use mount_tmpfs, or falls back to 2119# mount_mfs. 2120# 2121# If do_redirect, then also redirect output to the console. 2122# 2123create_mfs_dev() 2124{ 2125 ndevnodes=${1-1200} 2126 dev_mountpoint=${PWD:-/dev} 2127 2128 # Number of inodes is the specified number of device nodes, plus 2129 # a margin to allow for extra device nodes created later. 2130 ninode=$((ndevnodes * 11 / 10)) 2131 # Add 2 reserved inodes (needed for both mfs and tmpfs), and round 2132 # up to a multiple of 32 (needed for mfs, not needed for tmpfs). 2133 ninode=$(( (ninode + 2 + 31) / 32 * 32 )) 2134 # Try tmpfs; if that fails try mfs. 2135 # 2136 # For tmpfs, allocate 16KB and 512 byte per node. 2137 # Actual requirements are much lower, but the size limit 2138 # is only intended to avoid accidental writing to /dev. 2139 fs_bytes=$((16384 + ninode * 512)) 2140 if mount_tmpfs -s $fs_bytes -n $ninode -m 0755 \ 2141 -o union tmpfs "$dev_mountpoint" 2142 then 2143 fstype=tmpfs 2144 else 2145 # This file system size calculation is exact for mount_mfs(8) 2146 # with 512-byte sectors. 40960 bytes (80 blocks) is the 2147 # minimum size allowed by mount_mfs. 2148 fs_bytes=$((8192 + 2 * 8192 + 4096 + ninode*512 + 8192)) 2149 [ "$fs_bytes" -lt 40960 ] && fs_bytes=40960 2150 fs_blocks=$((fs_bytes/512)) 2151 if mount_mfs -b 4096 -f 512 -s $fs_blocks -n $ninode -p 0755 \ 2152 -o union swap "$dev_mountpoint" 2153 then 2154 fstype=mfs 2155 else 2156 die "Failed to create memory file system" 2157 fi 2158 fi 2159 2160 # Our current directory was in the lower file system; change it to 2161 # the newly mounted upper file system. 2162 cd "$dev_mountpoint" 2163 2164 if $do_redirect; then 2165 # Redirect stdout and stderr to console 2166 mknod -m 600 -g 0 -u 0 temp_console c 0 0 2167 exec >temp_console 2>&1 2168 rm temp_console 2169 fi 2170 2171 echo "Created $fstype $dev_mountpoint" \ 2172 "($fs_bytes byte, $ninode inodes)" 2173} 2174 2175# 2176# MAIN: If MAKEDEV_AS_LIBRARY is set, then we are being used as a 2177# function library, so just return. Otherwise, do all the real work. 2178# 2179[ -n "${MAKEDEV_AS_LIBRARY}" ] && return 2180makedev_main makedev ${1+"$@"} 2181