#!/bin/bash 
# 
# Script loads module and makes device node. One can specify the major
# number as an argument to the script. 
#
#	affinity_load [insmod options]
#
#	example: 
#
#	$ affinity_load affinity_major=250
#

module="cpu_affinity"
device="cpu_affinity"
group="users"
mode="664"

# clean out old node
rm -f /dev/${device}0

# insmod - load cpu_affinity module with any options specified on cmd line
/sbin/insmod -f module/$module.o $* || exit 1

# get major number from /proc/devices
major=`cat /proc/devices | awk "\\$2==\"$module\" {print \\$1}"`

# make new node
mknod /dev/${device}0 c $major 0

# make sure permissions are correct
chgrp $group /dev/${device}0
chmod $mode /dev/${device}0

exit 0
