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