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