Subject: MI MAKEDEV code
To: None <tech-kern@netbsd.org>
From: Christos Zoulas <christos@zoulas.com>
List: tech-kern
Date: 05/24/2003 22:07:07
Hello,

The following code contains changes to the classic MAKEDEV script, to
include a MAKEDEV.majors thus making it largely machine independent.
The following shar contains a copy of the new MAKEDEV script, a simple
shell script (mkdev) to generate MAKEDEV.majors, and a patch to the
Makefile. To use extract in in /usr/src/etc, then apply the patch and
remove etc.i386/MAKEDEV. Please note that the new script is a lot smaller
and somewhat slower than the old one, because it does individual rm's
chmod's and chown's. This can be easily fixed by adding the necessary
options to mknod(1). Now there is only one mknod invocation in the file.

Please let me know what you think. It is pretty easy to convert the new
archs to use it, but it might break the script that generates the man
pages.

christos

# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
#	Makefile.diff
#	MAKEDEV
#	mkdev
#
echo x - Makefile.diff
sed 's/^X//' >Makefile.diff << 'END-of-Makefile.diff'
XIndex: Makefile
X===================================================================
XRCS file: /cvsroot/src/etc/Makefile,v
Xretrieving revision 1.252
Xdiff -u -u -r1.252 Makefile
X+++ Makefile	2003/05/25 01:59:48
X@@ -178,7 +178,17 @@
X 	) | ${METALOG.add}
X .endif	# UNPRIVED
X 	${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 555 \
X-	    MAKEDEV.local etc.${MACHINE}/MAKEDEV ${DESTDIR}/dev
X+	    MAKEDEV.local ${DESTDIR}/dev
X+	@set +x; if [ -f etc.${MACHINE}/MAKEDEV ]; then \
X+		${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 555 \
X+		    etc.${MACHINE}/MAKEDEV ${DESTDIR}/dev; \
X+	else \
X+		${HOST_SH} ${.CURDIR}/mkdev < \
X+		    ${.CURDIR}/../sys/arch/${MACHINE}/conf/majors.${MACHINE} > \
X+		    ${.OBJDIR}/MAKEDEV.majors; \
X+		${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 555 \
X+		    ${.OBJDIR}/MAKEDEV.majors MAKEDEV ${DESTDIR}/dev; \
X+	fi
X 	${ETC_INSTALL_FILE} -o root -g wheel -m 600 \
X 	    minfree ${DESTDIR}/var/crash
X .for file in cshrc login profile shrc
X@@ -520,6 +530,6 @@
X 
X 
X clean:
X-	-rm -rf ${CDROM.dir} ${CDROM.pathlist} ${OBSOLETE.dir}
X+	-rm -rf ${CDROM.dir} ${CDROM.pathlist} ${OBSOLETE.dir} MAKEDEV.majors
X 
X .include <bsd.prog.mk>
END-of-Makefile.diff
echo x - MAKEDEV
sed 's/^X//' >MAKEDEV << 'END-of-MAKEDEV'
X#!/bin/sh -
X#	$NetBSD: MAKEDEV,v 1.110 2003/05/07 13:41:35 christos Exp $
X#
X# Copyright (c) 1990 The Regents of the University of California.
X# All rights reserved.
X#
X# Redistribution and use in source and binary forms, with or without
X# modification, are permitted provided that the following conditions
X# are met:
X# 1. Redistributions of source code must retain the above copyright
X#    notice, this list of conditions and the following disclaimer.
X# 2. Redistributions in binary form must reproduce the above copyright
X#    notice, this list of conditions and the following disclaimer in the
X#    documentation and/or other materials provided with the distribution.
X# 3. All advertising materials mentioning features or use of this software
X#    must display the following acknowledgement:
X#	This product includes software developed by the University of
X#	California, Berkeley and its contributors.
X# 4. Neither the name of the University nor the names of its contributors
X#    may be used to endorse or promote products derived from this software
X#    without specific prior written permission.
X#
X# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
X# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
X# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
X# ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
X# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
X# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
X# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
X# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
X# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
X# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
X# SUCH DAMAGE.
X#
X###########################################################################
X#
X#   PLEASE RUN "cd ../share/man/man8 ; make makedevs"
X#   AFTER CHANGING THIS FILE, AND COMMIT THE UPDATED MANPAGE!
X#
X###########################################################################
X#
X#   PLEASE RUN "cd ../share/man/man8 ; make makedevs"
X#   AFTER CHANGING THIS FILE, AND COMMIT THE UPDATED MANPAGE!
X#
X###########################################################################
X#
X# Device "make" file.  Valid arguments:
X#	all	makes all known devices, including local devices.
X#		Tries to make the 'standard' number of each type.
X#	init	A set of devices that is used for MFS /dev by init.
X#		May be equal to "all".
X#	floppy	devices to be put on install floppies
X#	ramdisk	devices to be put into INSTALL kernel ramdisks.
X#	std	standard devices
X#	local	configuration specific devices
X#	usbs	make USB devices
X#	isdns	make ISDN devices
X#
X# Tapes:
X#	wt*	QIC-interfaced (e.g. not SCSI) 3M cartridge tape
X#	st*	SCSI tapes
X#
X# Disks:
X#	ccd*	concatenated disk devices
X#	cd*	SCSI or ATAPI CD-ROM
X#	cgd*	cryptographic disk devices
X#	ed*	PS/2 ESDI disk devices
X#	fd*	"floppy" disk drives (3 1/2", 5 1/4")
X#	ld*	Logical disk devices (e.g., hardware RAID)
X#	mcd*	Mitsumi CD-ROM
X#	md*	memory pseudo-disk devices
X#	raid*	RAIDframe disk devices
X#	sd*	SCSI disks
X#	vnd*	"file" pseudo-disks
X#	wd*	"winchester" disk drives (ST506,IDE,ESDI,RLL,...)
X#
X# Console ports:
X#	ttyv0	pccons
X#	ttyE*	wscons
X#
X# Pointing devices:
X#	wsmouse* wscons mouse events
X#
X# Keyboard devices:
X#	wskbd*	wscons keyboard events
X#
X# Terminal ports:
X#	com*	standard PC COM ports			(XXX)
X#	tty*	alias for PC COM ports, this is what the system really wants
X#	ttyCZ*	Cyclades-Z multiport serial boards.  Each "unit"
X#		makes 64 ports.
X#	ttyCY*	Cyclom-Y multiport serial boards. Each "unit" makes
X#		32 ports.
X#
X# Pseudo terminals:
X#	pty*	set of 62 master and slave pseudo terminals
X#	opty	first 16 ptys, to save inodes on install media
X#
X# Printers:
X#	lpt*	stock lp
X#	lpa*	interruptless lp
X#
X# USB devices:
X#	usb*	USB control devices
X#	uhid*	USB generic HID devices
X#	ulpt*	USB printer devices
X#	ugen*	USB generic devices
X#	urio*	USB Diamond Rio 500 devices
X#	uscanner*	USB scanners
X#	ttyU*	USB modems
X#
X# ISDN devices:
X#	isdn	communication between userland isdnd and kernel
X#	isdnctl	control device
X#	isdnbchan* raw b-channel access
X#	isdntel*	telephony device
X#	isdntrc*	trace device
X#
X# Special purpose devices:
X#	clockctl clock control for non root users
X#	fd	file descriptors
X#	bpf*	packet filter
X#	cir*	Consumer IR
X#	ipl	IP Filter
X#	irframe* IrDA physical frame
X#	random	Random number generator, see rnd(4)
X#	speaker	PC speaker		(XXX - installed)
X#	lkm	loadable kernel modules interface
X#	audio*	audio devices
X#	apm	power management device
X#	tun*	network tunnel driver
X#	joy*	joystick device
X#	satlink* PlanetConnect satellite receiver driver
X#	scsibus* SCSI busses, see scsi(4), scsictl(8)
X#	ses*	SES/SAF-TE SCSI Devices
X#	ss*	SCSI scanner
X#	uk*	unknown SCSI device
X#	ch*	SCSI media changer
X#	cfs*	Coda file system device
X#	sysmon	System Monitoring hardware
X#	bktr	Brooktree 848/849/878/879 based TV cards
X#	iop*	I2O IOP control interface
X#	mlx*	Mylex DAC960 control interface
X#	mly*	Mylex AcceleRAID/eXtremeRAID control interface
X#	altq	ALTQ control interface
X#	vmegen*	generic VME access
X#	wsfont*	console font control
X#	wsmux*	wscons event multiplexor
X#	agp*	AGP GART devices
X#	pci*	PCI bus access devices
X#	dpt*	DPT/Adaptec EATA RAID management interface
X#	dpti*	DPT/Adaptec I2O RAID management interface
X#	radio*	radio devices
X#	nsmb*	SMB requester
X#	systrace syscall tracer
X#	kttcp	kernel ttcp helper device
X#	dmoverio hardware-assisted data movers
X#	veriexec verified executable fingerprint loader
X#	twe	3ware Escalade control interface
X#	icp	ICP-Vortex/Intel RAID control interface
X#
X
Xdialin=0
Xdialout=524288		# high bit of the minor number
Xcallunit=262144
X
Xhighpartoffset=524280	# offset for partition 9 to 16
X
XPATH=/sbin:/usr/sbin:/bin:/usr/bin
Xumask 77
X
X. $(dirname $0)/MAKEDEV.majors
X
X# Check if we have fdesc mounted
Xif [ -d fd ]; then
X	case "`df fd`" in
X	*fdesc*) nofdesc=false;;
X	*) nofdesc=true;;
X	esac
Xelse
X	nofdesc=true
Xfi
X
Xnode()
X{
X	case "$1" in '') return;; esac
X	rm -f $2
X	mknod $2 $3 $1 $4
X	case "$5" in '') return;; esac
X	chmod $5 $2
X	case "$6" in '') return;; esac
X	chown $6 $2
X}
X
Xprepare() {
X	OIFS="$IFS"
X	IFS="0123456789$IFS"
X	set -- $1
X	IFS="$OIFS"
X	name=$1
X	unit=${i#$name}
X	eval bvar=$"${name}_b"
X	eval cvar=$"${name}_c"
X}
X
Xmakedev()
X{
X
Xfor i
Xdo
X
Xcase $i in
X
X# As of 2003-04-17, the "init" case must not create more than 890 entries.
Xinit)
X	makedev std wscons wt0 fd0 fd1 wd0 wd1 wd2 wd3 sd0 sd1 sd2 sd3 sd4
X	makedev tty0 tty1
X	makedev st0 st1 ch0 cd0 cd1 mcd0 vnd0
X	makedev bpf0
X	makedev ccd0 md0 ch0 random
X	makedev cgd0 cgd1
X	makedev iop0 mlx0 mly0 dpti0 dpt0 twe0 icp0
X	makedev ed0 ed1
X	makedev raid0
X	makedev ld0 ld1 ld2 ld3
X	makedev usbs
X	makedev ipty
X	makedev local
X	;;
X
Xall)
X	makedev init
X	makedev fd
X	makedev tty2 tty3 pty0
X	makedev lpa0 lpa1 lpa2
X	makedev lpt0 lpt1 lpt2
X	makedev tun0 tun1 tun2 tun3 ipl
X	makedev bpf1 bpf2 bpf3 bpf4 bpf5 bpf6 bpf7
X	makedev vnd1
X	makedev raid1 raid2 raid3 raid4 raid5 raid6 raid7
X	makedev ccd1 ccd2 ccd3
X	makedev cgd2 cgd3
X	makedev ss0 uk0 uk1
X	makedev speaker lkm joy0 joy1
X	makedev apm satlink0
X	makedev audio
X	makedev radio
X	makedev isdns
X	makedev music rmidi0 rmidi1 rmidi2 rmidi3 rmidi4 rmidi5 rmidi6 rmidi7
X	makedev scsibus0 scsibus1 scsibus2 scsibus3
X	makedev sysmon
X	makedev bktr
X	makedev ttyCZ0 ttyCY0
X	makedev agp0
X	makedev pci0 pci1 pci2 pci3 pci4 pci5 pci6 pci7
X	makedev altq
X	makedev cir0 cir1 irframe0 irframe1
X	makedev clockctl
X	makedev systrace
X	makedev kttcp
X	makedev dmoverio
X	makedev nsmb
X	;;
X
Xaudio)
X	makedev audio0 audio1 audio2 audio3
X	ln -fs sound0 sound
X	ln -fs audio0 audio
X	ln -fs mixer0 mixer
X	ln -fs audioctl0 audioctl
X	;;
X
Xradio)
X	makedev radio0 radio1
X	ln -fs radio0 radio
X	;;
X
Xfloppy)
X	makedev std wt0 fd0 fd1 wd0 wd1 wd2 wd3 sd0 sd1 sd2 sd3 sd4 st0 st1
X	makedev tty0 tty1 tty2 cd0 cd1 mcd0 ttyv0 opty ld0 ld1 ld2 ld3 ed0 ed1
X	;;
X
Xramdisk)
X	makedev floppy md0
X	;;
X
Xusbs)
X	makedev usb usb0 usb1 usb2 usb3 usb4 usb5 usb6 usb7
X	makedev uhid0 uhid1 uhid2 uhid3
X	makedev ulpt0 ulpt1
X	makedev ttyU0 ttyU1
X	makedev urio0
X	makedev uscanner0 uscanner1
X	makedev ugen0
X	;;
X
Xisdns)
X	makedev isdn isdnctl isdnbchan0 isdnbchan1 isdntel0 isdntel1 isdntrc0 isdntrc1
X	;;
X
Xstd)
X	node "$cons_c"	console	c 0
X	node "$swap_c"	drum	c 0 640 root.kmem
X	node "$mem_c"	kmem	c 1 640 root:kmem
X	node "$mem_c"	mem	c 0 640 root:kmem
X	node "$mem_c"	null	c 2 666 
X	node "$mem_c"	zero	c 12 666
X	node "$log_c"	klog	c 0 600
X	node "$ksyms_c" ksyms	c 0 444
X	if $nofdesc; then
X		node "$ctty_c" tty c 0 666
X		node "$filedesc_c" stdin c 0 666
X		node "$filedesc_c" stdout c 1 666
X		node "$filedesc_c" stderr c 1 666
X	fi
X	;;
X
Xusb*)
X	unit=${i#usb}
X	if [ -z "$unit" ]; then
X		unit=255
X		usb=usb
X	else
X		usb=usb$unit
X	fi
X	node "$usb_c" $usb c $unit 600
X	;;
X
Xuhid*)
X	unit=${i#uhid}
X	node "$uhid_c" uhid$unit c $unit 666
X	;;
X
Xulpt*)
X	unit=${i#ulpt}
X	node "$ulpt_c" ulpt$unit c $unit 600
X	node "$ulpt_c" ulpn$unit c $(($unit + 64)) 600
X	;;
X
Xurio*)
X	unit=${i#urio}
X	node "$urio_c" urio$unit c $unit 666
X	;;
X
XttyU*)
X	unit=${i#ttyU}
X	node "$ucom_c" ttyU$unit c $(($unit + $dialin  )) 600 uucp
X	node "$ucom_c" dtyU$unit c $(($unit + $dialout )) 600 uucp
X	node "$ucom_c" ctyU$unit c $(($unit + $callunit)) 600 uucp
X	;;
X
Xugen*)
X	unit=${i#ugen}
X	ugen=ugen$unit
X	major=64
X	for j in 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15
X	do
X		ugenj=$ugen.$j
X		node "$ugen_c" $ugenj c $(($unit * 16 + ${j#0})) 600
X	done
X	;;
X
Xttyv0)
X	node "$pc_p" ttyv0 c 0
X	;;
X
Xwscons)
X	makedev ttyE0 ttyE1 ttyE2 ttyE3 ttyE4 ttyE5 ttyE6 ttyE7
X	makedev wsmouse0 wsmouse1 wsmouse2 wsmouse3
X	makedev wskbd0 wskbd1 wskbd2 wskbd3
X	makedev wsmux0 wsmux1 wsmux2 wsmux3
X	makedev wsmouse wskbd
X	makedev ttyEcfg ttyEstat
X	makedev wsfont
X	;;
X
Xwsmouse)
X	node "$wsmux_c" wsmouse c 0 600
X	;;
X
Xwskbd)
X	node "$wsmux_c" wskbd c 1 600
X	;;
X
Xwsmux*)
X	unit=${i#wsmux}
X	unitctl=$(($unit + 128))
X	wsmux=wsmux$unit
X	wsmuxctl=wsmuxctl$unit
X	node "$wsmux_c" $wsmux c $unit 600
X	node "$wsmux_c" $wsmuxctl c $unitctl 200
X	;;
X
XttyEstat)
X	node "$wsdisplay_c" ttyEstat c 254 600
X	;;
X
XttyEcfg)
X	node "$wsdisplay_c" ttyEcfg c 255 600
X	;;
X
XttyE*)
X	unit=${i#ttyE}
X	node "$wsdisplay_c" ttyE$unit c $unit
X	;;
X
Xwsmouse*)
X	unit=${i#wsmouse}
X	wsmouse=wsmouse$unit
X	node "$wsmouse_c" $wsmouse c $unit 600
X	;;
X
Xwskbd*)
X	unit=${i#wskbd}
X	wskbd=wskbd$unit
X	node "$wskbd_c" $wskbd c $unit
X	;;
X
Xfd)
X	if $nofdesc; then
X		rm -f fd/*
X		mkdir fd 2>/dev/null
X		n=0
X		while [ $n -lt 64 ]; do
X			node "$filedesc_c" fd/$n c $n 666
X			n=$(($n + 1))
X		done
X		chmod 755 fd
X	fi
X	;;
X
Xwt*)
X	unit=${i#wt}
X	for sub in $unit $(($unit+8)) $(($unit+16))
X	do
X	    node "$wt_b" wt$sub		b $(($sub + 0)) 660 root:operator
X	    node "$wt_b" nwt$sub	b $(($sub + 4)) 660 root:operator
X	    node "$wt_c" rwt$sub	c $(($sub + 0)) 660 root:operator
X	    node "$wt_c" nrwt$sub	c $(($sub + 4)) 660 root:operator
X	done
X	;;
X
Xmd*)
X	unit=${i#md}
X	node "$md_b" md${unit}a  b $(($unit * 8 + 0)) 640 root:operator
X	node "$md_b" md${unit}d  b $(($unit * 8 + 3)) 640 root:operator
X#	node "$md_c" rmd${unit}a c $(($unit * 8 + 0)) 640 root:operator
X#	node "$md_c" rmd${unit}d c $(($unit * 8 + 3)) 640 root:operator
X	;;
X
Xss*)
X	unit=${i#ss}
X	node "$ss_c" ss$unit	c $(($unit * 16 + 0)) 640 root:operator
X	node "$ss_c" nss$unit	c $(($unit * 16 + 1)) 640 root:operator
X	node "$ss_c" enss$unit	c $(($unit * 16 + 3)) 640 root:operator
X	;;
X
Xccd*|cgd*|fd*|ld*|raid*|sd*|vnd*|wd*|ed*)
X	prepare $i
X	num=0
X	for p in a b c d e f g h
X	do
X		m=$(($unit * 8 + $num))
X		node $bvar ${name}${unit}${p}  b $m 640 root.operator
X		node $cvar r${name}${unit}${p} c $m 640 root.operator
X		num=$(($num + 1))
X	done
X	num=$(($num + $highpartoffset))
X	for p in i j k l m n o p
X	do
X		m=$(($unit * 8 + $num))
X		node $bvar ${name}${unit}${p}  b $m 640 root.operator
X		node $cvar r${name}${unit}${p} c $m 640 root.operator
X		num=$(($num + 1))
X	done
X	;;
X
XttyCZ*)
X	unit=${i#ttyCZ}
X	min=$(($unit * 64))
X	emin=$(($min + 64))
X	while [ $min -lt $emin ]; do
X		if [ $min -lt 10 ]; then
X			nmin=000$min
X		elif [ $min -lt 100 ]; then
X			nmin=00$min
X		elif [ $min -lt 1000 ]; then
X			nmin=0$min
X		else
X			nmin=$min
X		fi
X		node "$cz_c" ttyCZ$nmin c $(($min + $dialin )) 600 uucp
X		node "$cz_c" dtyCZ$nmin c $(($min + $dialout)) 600 uucp
X		min=$(($min + 1))
X	done
X	;;
X
XttyCY*)
X	unit=${i#ttyCY}
X	min=$(($unit * 32))
X	emin=$(($min + 32))
X	while [ $min -lt $emin ]; do
X		if [ $min -lt 10 ]; then
X			nmin=00$min
X		elif [ $min -lt 100 ]; then
X			nmin=0$min
X		else
X			nmin=$min
X		fi
X		node "$cy_c" ttyCY$nmin c $(($min + $dialin )) 600 uucp
X		node "$cy_c" dtyCY$nmin c $(($min + $dialout)) 600 uucp
X		min=$(($min + 1))
X	done
X	;;
X
Xcom*|tty*)					# (XXX -- com should die)
X	ounit=${i#???}
X	ounit=$(($ounit + 0))
X	if [ $ounit -lt 10 ]; then
X		unit=0$ounit
X		rm -f com$ounit
X	else
X		unit=$ounit
X	fi
X	node "$com_c" tty$unit c $(($ounit + $dialin )) 600 uucp
X	node "$com_c" dty$unit c $(($ounit + $dialout)) 600 uucp
X	;;
X
Xopty)
X	rm -f ttyp[0-9a-f] ptyp[0-9a-f]
X	for j in 0 1 2 3 4 5 6 7 8 9 a b c d e f
X	do
X		case $j in
X		[0-9])	jn=$j ;;
X		a)	jn=10 ;;
X		b)	jn=11 ;;
X		c)	jn=12 ;;
X		d)	jn=13 ;;
X		e)	jn=14 ;;
X		f)	jn=15 ;;
X		esac
X		node "$pts_c" ttyp$j c $jn 666
X		node "$ptc_c" ptyp$j c $jn 666
X	done
X	;;
X
Xipty)   
X	for j in 0 1
X	do
X		node "$pts_c" ttyp$j c $j 666
X		node "$ptc_c" ptyp$j c $j 666
X	done
X	;;
X
Xpty*)
X	class=${i#pty}
X	name=`echo pqrstuvwxyzPQRST | dd bs=1 count=1 skip=$class 2>/dev/null`
X	case $name in
X	v)	echo "$0: $i: pty unit conflicts with console ttyv0 device."
X		continue ;;
X	?)	;;
X	*)	echo "$0: $i: pty unit must be between 0 and 15"
X		continue ;;
X	esac
X	jn=0
X	while [ $jn -lt 62 ]
X	do
X		j=`echo 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ | dd bs=1 count=1 skip=$jn 2>/dev/null`
X		skip=0
X		if [ $jn -ge 16 ]; then
X			skip=$(($class * 30 + 256 - 16))
X		fi
X		unit=$(($class * 16 + $jn + $skip))
X		node "$pts_c" tty$name$j c $unit 666
X		node "$ptc_c" pty$name$j c $unit 666
X		jn=$(($jn + 1))
X	done
X	;;
X
Xst*)
X	unit=${i#st}
X	node "$st_b" st$unit	b $(($unit * 16 + 0)) 660 root:operator
X	node "$st_b" nst$unit	b $(($unit * 16 + 1)) 660 root:operator
X	node "$st_b" est$unit	b $(($unit * 16 + 2)) 660 root:operator
X	node "$st_b" enst$unit	b $(($unit * 16 + 3)) 660 root:operator
X	node "$st_c" rst$unit	c $(($unit * 16 + 0)) 660 root:operator
X	node "$st_c" nrst$unit	c $(($unit * 16 + 1)) 660 root:operator
X	node "$st_c" erst$unit	c $(($unit * 16 + 2)) 660 root:operator
X	node "$st_c" enrst$unit	c $(($unit * 16 + 3)) 660 root:operator
X	;;
X
Xses*|ch*|uk*)
X	prepare $i
X	node "$cvar" $name$unit c $unit 640 root:operator
X	;;
X
Xcd*|mcd*)
X	prepare $i
X	node "$bvar" ${name}${unit}a	b $(($unit * 8 + 0)) 640 root:operator
X	node "$bvar" ${name}${unit}d	b $(($unit * 8 + 3)) 640 root:operator
X	node "$cvar" r${name}${unit}a	c $(($unit * 8 + 0)) 640 root:operator
X	node "$cvar" r${name}${unit}d	c $(($unit * 8 + 3)) 640 root:operator
X	;;
X
Xlpt*)
X	unit=${i#lpt}
X	node "$lpt_c" lpt$unit	c $unit
X	;;
X
Xlpa*)
X	unit=${i#lpa}
X	node "$lpt_c" lpa$unit	c $(($unit + 128))
X	;;
X
Xbpf*|tun*|joy*)
X	prepare $i
X	node "$cvar" $name$unit	c $unit
X	;;
X
Xipl)
X	node "$ipl_c" ipl c 0 600
X	node "$ipl_c" ipnat c 1 600
X	node "$ipl_c" ipstate c 2 600
X	node "$ipl_c" ipauth c 3 600
X	;;
X
Xspeaker)					# (XXX - installed)
X	node "$spkr_c" speaker c 0
X	;;
X
Xlkm)
X	node "$lkm_c" lkm c 0 640 root:kmem
X	;;
X
Xaudio*)
X	unit=${i#audio}
X	audio=audio$unit
X	sound=sound$unit
X	mixer=mixer$unit
X	major=42
X	audioctl=audioctl$unit
X	if [ -z "$unit" ]; then unit=0; fi
X	node "$audio_c" $sound    c $(($unit + 0)) 666
X	node "$audio_c" $audio    c $(($unit + 128)) 666
X	node "$audio_c" $mixer    c $(($unit + 16)) 666
X	node "$audio_c" $audioctl c $(($unit + 192)) 666
X	;;
X
Xrmidi*)
X	unit=${i#rmidi}
X	node "$midi_c" rmidi$unit c $unit 666
X	;;
X
Xmusic*)
X	unit=${i#music}
X	music=music$unit
X	sequencer=sequencer$unit
X	if [ -z "$unit" ]; then unit=0; fi
X	node "$sequencer_c" $music     c $(($unit + 0)) 666
X	node "$sequencer_c" $sequencer c $(($unit + 128)) 666
X	;;
X
Xradio*)
X	unit=${i#radio}
X	if [ -z "$unit" ]; then unit=0; fi
X	node "$radio_c" radio$unit c $unit 666
X	;;
X
Xapm*)
X	node "$apm_c" apm c 0 644
X	node "$apm_c" apmctl c 8 644
X	;;
X
Xsatlink*)
X	unit=${i#satlink}
X	node "$satlink_c" satlink$unit c $unit 444
X	;;
X
Xrandom)
X	node "$rnd_c" random c 0 444
X	node "$rnd_c" urandom c 1 644
X	;;
X
Xcfs*)
X	unit=${i#cfs}
X	node "$vcoda_c" cfs$unit c $unit 600
X	;;
X
Xsysmon)
X	node "$sysmon_c" sysmon c 0 644
X	node "$sysmon_c" watchdog c 1 644
X	node "$sysmon_c" power c 2 640
X	;;
X
Xscsibus*)
X	unit=${i#scsibus}
X	node "$scsibus_c" scsibus$unit c $unit 644
X	;;
X
Xbktr)
X	makedev bktr0 bktr1
X	ln -fs bktr0 bktr
X	ln -fs tuner0 tuner
X	ln -fs vbi0 vbi
X	;;
X
Xbktr*)
X	unit=${i#bktr}
X	node "$bktr_c" bktr$unit c $(($unit + 0)) 444
X	node "$bktr_c" tuner$unit c $(($unit + 16)) 444
X	node "$bktr_c" vbi$unit c $(($unit + 32)) 444
X	;;
X
Xmlx*|mly*|twe*|iop*|icp*|dpt*|uscanner*|isdnb*|isdnn*|isdnt*|irframe*)
X	prepare $i
X	node "$cvar" $name$unit c $unit 600
X	;;
X
Xagp*)
X	unit=${i#agp}
X	node "$agp_c" agp$unit c $unit 644
X	if [ "$unit" = "0" ]; then ln -fs agp$unit agpgart; fi
X	;;
X
Xpci*)
X	unit=${i#pci}
X	node "$pci_c" pci$unit c $unit 644
X	;;
X
Xaltq)
X	mkdir altq 2>/dev/null
X	chmod 755 altq
X	unit=0
X	for dev in altq cbq wfq afm fifoq red rio localq hfsc \
X	    cdnr blue priq; do
X		node "$altq_c" altq/$dev c $unit 644
X		unit=$(($unit + 1))
X	done
X	;;
X
Xvmegen)
X	makedev vmegen0 vmegen1 vmegen2 vmegen3
X	;;
X
Xvmegen*)
X	unit=${i#vmegen}
X	node "$vmegeneric_c" vmegen$unit c $(($unit * 16 + 0)) 600
X	;;
X
Xcir*)
X	unit=${i#cir}
X	node "$cir_c" cir$unit c $unit 666
X	;;
X
Xclockctl)
X	node "$clockctl_c" clockctl c 0 660 root.ntpd
X	;;
X
Xnsmb)
X	makedev nsmb0 nsmb1 nsmb2 nsmb3
X	;;
X
Xnsmb*)
X	unit=${i#nsmb}
X	node "$nsmb_c" nsmb$unit c $unit 644
X	;;
X
Xkttcp|isdn|isdnctl|wsfont)
X	eval cvar=$"${i}_c"
X	node "$cvar" $i c 0 600
X	;;
X
Xdmoverio|systrace)
X	eval cvar=$"${i}_c"
X	node "$cvar" $i c 0 644
X	;;
X
Xveriexec)
X	node "$verifiedexec_c" veriexec c 0 644
X	;;
X
Xlocal)
X	if [ -f "$0.local" ]; then
X		umask 0
X		sh $0.local all
X		umask 77
X	fi
X	;;
X
X*)
X	echo $i: unknown device
X	;;
X
Xesac
Xdone
X
X}
X
Xmakedev $*
END-of-MAKEDEV
echo x - mkdev
sed 's/^X//' >mkdev << 'END-of-mkdev'
X#!/bin/sh
X# 
X# Copyright (c) 2003 The NetBSD Foundation, Inc.
X# All rights reserved.
X#
X# This code is derived from software contributed to The NetBSD Foundation
X# by Christos Zoulas.
X#
X# Redistribution and use in source and binary forms, with or without
X# modification, are permitted provided that the following conditions
X# are met:
X# 1. Redistributions of source code must retain the above copyright
X#    notice, this list of conditions and the following disclaimer.
X# 2. Redistributions in binary form must reproduce the above copyright
X#    notice, this list of conditions and the following disclaimer in the
X#    documentation and/or other materials provided with the distribution.
X# 3. All advertising materials mentioning features or use of this software
X#    must display the following acknowledgement:
X#        This product includes software developed by the NetBSD
X#        Foundation, Inc. and its contributors.
X# 4. Neither the name of The NetBSD Foundation nor the names of its
X#    contributors may be used to endorse or promote products derived
X#    from this software without specific prior written permission.
X#
X# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
X# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
X# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
X# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
X# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
X# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
X# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
X# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
X# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
X# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
X# POSSIBILITY OF SUCH DAMAGE.
X# 
X
Xecho "# Automatically generated file, do not edit"
Xread copy
Xecho -n "# From:"
Xecho "$copy" | tr -d '$' | tr -d '#'
Xecho "# At:	$(date)" 
X
Xwhile read key dev char cnum block bnum rest
Xdo
X	case "$key" in
X	device-major)
X		;;
X	*)
X		continue
X		;;
X	esac
X	case "$char" in
X	char)
X		echo ${dev}_c=$cnum
X		;;
X	esac
X	case "$block" in
X	block)
X		echo ${dev}_b=$bnum
X		;;
X	esac
Xdone
END-of-mkdev
exit