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