Subject: Re: dev/MAKEDEV not portable
To: Chris G. Demetriou <cgd@pa.dec.com>
From: Todd Vierling <tv@pobox.com>
List: current-users
Date: 12/19/1997 09:59:34
On Thu, 18 Dec 1997, Chris G. Demetriou wrote:

: > Perhaps a portable MAKEDEV.minimum would be a solution?
: 
: "see above."  You really need a dev.tar.gz, or a netbsd_mknod program.

Then how's about a 'netbsd_mknod' script that knows about various semantics
of OS's used by those who do diskless serving, checked on uname, and that
does the appropriate math to convert special file numbers?  Every platform I
know of has a constant formula to calculate the 32 bit filesystem constant
from a major and minor number.  This needn't even be a C program if the math
is known for a given OS.

This could cause problems, for instance, on systems where devices can only
have 16 bits and when we switch to 32.  But the semantics of _that_ aren't
yet decided anyhoo.

One thing that has just hit me, though: what if, say, the device constant
for /dev/null on NetBSD is the proper constant for /dev/kmem on a host
platform?  Ew, permissions and constants stickiness. 

=====

#! /bin/sh
# netbsd_mknod - make a NetBSD style node on a diskless host platform
# quick hack example version :)

if [ -z "$1" -o -z "$2" -o -z "$3" -o -z "$4" ]; then
	echo "Usage: $0 filename b|c major minor"
	exit
fi

PATH=/usr/sbin:/usr/bin:/sbin:/bin:/usr/ucb:/usr/5bin; export PATH
devnum=`expr \( $3 \* 256 \) + $4`

case `uname -srm | sed -e 's/ //g'` in
NetBSD[01]*|OpenBSD2.[01]*|SunOS[34]*|SVR[123]*)
	echo mknod $1 $2 $3 $4
	mknod $1 $2 $3 $4
	;;
SunOS5*|SVR4*)
	# is this true for all SVR4's?
	maj=`expr $devnum / 262144`
	min=`expr $devnum % 262144`
	echo mknod $1 $2 $maj $min
	mknod $1 $2 $maj $min
	;;
*)
	echo "$0: don't understand your host platform."
	;;
esac

=====
===== Todd Vierling (Personal tv@pobox.com; Business tv@lucent.com) =====
== "There's a myth that there is a scarcity of justice to go around, so
== that if we extend justice to 'those people,' it will somehow erode the
== quality of justice everyone else receives."  -- Maria Price