: '	NAME
		mknod - Creates a special file

	SYNTAX
		mknod name [bc] major minor
	or
		mknod name p

	DESCRIPTION
		Creates a special file named "name". Type is either
			c - character device
			b - block device
			p - pipe (fifo)

		Major and minor number is written onto the file on
		format "major,minor" if type is 'b' or 'c'.

'
NAME=$1 TYPE=$2 MAJOR=$3 MINOR=$4
if test -z "$TYPE"; then
	echo 'mknod: Usage - mknod name [bcp] major minor'
	exit 1
fi
case $TYPE in
	p)	>$NAME;
		chmod 10666 $NAME >/dev/null 2>&1 
		if test "$?" != 0; then
			echo "mknod: Unable to change mode of file $NAME"
			rm $NAME
			exit 1
		fi
		exit ;;
	[bc])	if test -z "$MINOR"; then
			echo "mknod: Invalid major/minor number"
			exit 1
		fi ;;
	*)	echo "mknod: Invalid type - use c,b or p"
		exit 1 ;;
esac
if test "$MAJOR" -lt 0 -o "$MAJOR" -gt 255; then
	echo 'mknod: Major number not in range 0 to 255'
	exit 1
fi
if test "$MINOR" -lt 0 -o "$MINOR" -gt 255; then
	echo 'mknod: Minor number not in range 0 to 255'
	exit 1
fi
echo $MAJOR,$MINOR >$NAME
if test "$TYPE" = c; then
	chmod 20666 $NAME >/dev/null 2>&1
else
	chmod 60666 $NAME >/dev/null 2>&1
fi
if test "$?" != 0; then
	echo "mknod: Unable to change mode of file $NAME"
	rm $NAME
fi
