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