Subject: improvements to mknod(8)
To: None <tech-userlevel@netbsd.org>
From: David Laight <david@l8s.co.uk>
List: tech-userlevel
Date: 02/07/2003 16:28:20
The MAKEDEV script has to run mknod, chown and chmod a lot of
times, this takes quite a long time (especially on a slow system),
and is one of the first things a user sees on a fresh installation.

The following changes would significantly speed up MAKEDEV.
There is also a possible scurity problem in that the file
permissions are currently set after a device entry has been created.
This does leave a narrow 'window of opportunity...

Add the following arguments to mknod:
	-m mode			set file mode
	-u user			set user id
	-g group		set group id

	-f file			read a list of changes from file
				if file is '-' read from stdin.

This would allow MAKEDEV to run a single copy of mknod.

Additionally allow the name of a driver to be given instead of a
major number.  This ought to allow an architecture independant
MAKEDEV script to be written.  A simple addition to the sysctl
interface to return the contents of the devsw_conv structure
is need to make this work.

For instance the line:
        mknod mem               c 3 0   ; chmod 640 mem ; chgrp kmem mem
would be replaced by:
	mknod -m 640 -g kmem mem c mem 0

I've implemented the above except -f...
'mknod -l' will list the drivers and their major numbers:
$ mknod -l
            cons character major 0
              kd character major 1
            ctty character major 2
             mem character major 3
             ses character major 4
            swap block major 4 character major 7
              xy block major 3 character major 9
           zstty character major 12
...

(I'm not sure that output format is right though)

Any takers?
Should I delete the diffs ?

	David

-- 
David Laight: david@l8s.co.uk