#!/bin/sh
#
# ftl.sample 1.3 1995/06/11 23:36:44 (David Hinds)
#
# Initialize or shutdown an FTL memory device
#
# The first argument should be either 'start' or 'stop'.  The second
# argument is the base name for the device.  When starting a device,
# there should be two additional arguments, the major and minor device
# numbers.
#
# This script creates one block device file, which maps the first
# common memory region.

usage()
{
    echo "usage: ftl {start|stop} [device name] [major] [minor]"
    exit 1
}

if [ $# -lt 2 ] ; then usage ; fi
action=$1
name=$2

case "${action}" in
'start')
    if [ $# -ne 4 ] ; then usage ; fi
    major=$3
    minor=$4
    rm -f /dev/${name}
    mknod /dev/${name} b $major $minor
    ;;
'stop')
    fuser -k /dev/${name}
    umount /dev/${name}
    rm -f /dev/${name}
    ;;
esac
