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