#!/bin/sh
# 
# Install OBFL driver
#

. /etc/init.d/mod_ins/module-load-functions 

case "$1" in

    start)
        boot_debug "Installing OBFL driver ..."
        insmod -f /lib/modules/klm_obfl.o

        make_chrdev klm_obfl

        # create devices for mtdoops and reaset reason
        makedev mtd0 c 90 0 root root 0644
        makedev mtd1 c 90 2 root root 0644

        ln -s /dev/mtd1 /dev/mtdoops
        ln -s /dev/mtd0 /dev/mtdrr

        # Mount plog for N3K 
        if [ -n "$IS_N3K" ]; then
            makedev mtdblock2 b 31 2 root root 0644
            [ -d $MNT_PLOG_DIR ] || mkdir $MNT_PLOG_DIR
            action "mounting plog:" mount -t jffs2 /dev/mtdblock2 $MNT_PLOG_DIR
        fi

        # Mount pstore 
        [ -d /mnt/pstore ] || mkdir /mnt/pstore
        mount -t pstore none /mnt/pstore
        ;;
    stop)
	    boot_debug "Uninstalling OBFL driver ..."
        /sbin/rmmod klm_obfl
        ;;
esac
