#!/bin/sh

if [ ! -x /sbin/mdev ]
then
    exit 0
fi

case "$1" in
    start)
        echo "/sbin/mdev" > /proc/sys/kernel/hotplug
        
        # put /dev in a tmpfs
        #mount -n -o mode=0755 -t devtmpfs mdev /dev
        mount -n -t devtmpfs devtmpfs /dev

        # Create static device nodes in /dev
        #mknod /dev/console c 5 1
        #chmod 600 /dev/console
        #mknod /dev/null c 1 3
        #chmod 666 /dev/null

        # make and mount devpts
        mkdir /dev/pts
        mount -n -t devpts devpts /dev/pts

        # populating /dev
        if [ ! -d /dev/input ]
        then
          mkdir /dev/input
        fi
        if [ ! -d /dev/snd ]
        then
          mkdir /dev/snd
        fi

        echo "Starting the hotplug events dispatcher mdev"
        /sbin/mdev -s

        mkdir /dev/shm
        ;;
    stop)
        ;;
    *)
        echo "Usage: /etc/rc.d/init.d/mdev {start|stop}"
        echo 
        exit 1
        ;;
esac

exit 0
