Subject: Unified MAKEDEV
To: None <tech-userland@NetBSD.org>
From: Jaromir Dolecek <jdolecek@NetBSD.org>
List: tech-kern
Date: 10/15/2003 22:49:32
There is a template-driven unidifed MAKEDEV framework now committed
into tree. This produces fully functional MAKEDEV script from
single MAKEDEV template, removing the need to maintain the
separate MAKEDEV scripts for every platform.
This is not activated yet, barring feedback and testing.

There are three compotents of the framework:
1. etc/MAKEDEV.tmpl - the template
2. etc.${MACHINE}/MAKEDEV.conf - MD config file
3. etc/MAKEDEV.awk - script producing the platform MAKEDEV script

Most of the devices in the former MD MAKEDEV scripts
were moved to the unified template. Only small number of the devices
was left in the MD parts, basically unique devices of hp300/vax
or devices/targets varying significantly between platforms (ttyB*,
tty[a-j], init).

The template contains series of entries such as:

wskbd)
        rm -f wskbd
        mknod wskbd c %wskbd_chr% 1
        chmod 600 wskbd
        ;;


If the platform has defined major for such device, the
%*_chr% is replaced by the appropriate character device major
and %*_blk% is replaced by block device major. No explicit
major number is ever hardcoded into the template, all numbers
are taken from sys/conf/majors or sys/arch/*/conf/majors.*
as appropriate.
If the platform doesn't define major for the device, the
entry is not added into output and won't appear in final script.

All the pseudo targets (such as 'audit', 'usbs' etc) are
currently generated into output script even on platforms
which don't have support for appropriate devices. There
is no harm with them being present, and this simplifies
the generation process.

The disk devices are now created using a shell function.  The particular
function used by platform is chosen according to whether the platform
supports 8 partitions, 16 partitions, or 16 partitions with
the high minor offset hack. Every place creating the disk device
calls the appropriate function, avoiding some cut&paste errors. The info
about partitioning used by platform is currently stored
in the MD MAKEDEV.conf file. It is done this way only because
it simplifies the initial implementation a bit, it would be possible
to get the information by parsing kernel include files too.

The platform-dependant MAKEDEV manpages are going to be replaced
by single MI manpage containing entries for all devices for all
platforms, so MAKEDEV(8) would become a cross-platform reference.

Unless there would be serious objections to this thing, I'd
switch over all archs once I'd confirm the list of generated devices
matches the former MD MAKEDEV script.

Before this happens, the script for any given platform can
be generated as:
	> export MACHINE=luna68k MACHINE_ARCH=m68k
	> cd src/etc && awk -f MAKEDEV.awk MAKEDEV.tmpl  > tempfile

Any opinions are welcome :)

Jaromir

(Also CC'ed to tech-kern, since this is related to recent discussions)
-- 
Jaromir Dolecek <jdolecek@NetBSD.org>            http://www.NetBSD.cz/
-=- We should be mindful of the potential goal, but as the tantric    -=-
-=- Buddhist masters say, ``You may notice during meditation that you -=-
-=- sometimes levitate or glow.   Do not let this distract you.''     -=-