#!/bin/sh
#
# ftl 1.26 2001/01/01 21:13:39 (David Hinds)
#
# Initialize or shutdown an FTL memory device
#
# The first argument should be the action to be performed, and the
# second, the base name for the device.
#
# The script passes an extended device address to 'ftl.opts' in the 
# ADDRESS variable, to retrieve device-specific configuration options.
# The address format is "scheme,socket,instance" where "scheme" is the
# current PCMCIA configuration scheme, "socket" is the socket number,
# and "instance" is used to number multiple FTL regions on a single
# card.
#

if [ -r ./shared ] ; then . ./shared ; else . /etc/pcmcia/shared ; fi

# Get device attributes
get_info $DEVICE

# Load site-specific settings
ADDRESS="$SCHEME,$SOCKET,$INSTANCE"
. $0.opts

case "$ACTION" in

'start')
    [ -n "$VERBOSE" -a -n "$INFO" ] && echo "$INFO"
    rm -f /dev/$DEVICE
    log mknod /dev/$DEVICE b $MAJOR $MINOR
    log mknod /dev/${DEVICE}p1 b $MAJOR `expr $MINOR + 1`
    log mknod /dev/${DEVICE}p2 b $MAJOR `expr $MINOR + 2`
    log mknod /dev/${DEVICE}p3 b $MAJOR `expr $MINOR + 3`
    log mknod /dev/${DEVICE}p4 b $MAJOR `expr $MINOR + 4`
    add_parts /dev/$DEVICE "$PARTS" || exit 1
    ;;

'check')
    is_true $NO_CHECK && exit 0
    do_fuser -s -m /dev/${DEVICE}* && exit 1
    ;;

'stop')
    rm_parts /dev/$DEVICE "$PARTS"
    rm -f /dev/$DEVICE /dev/${DEVICE}p[1-4]
    ;;

'cksum')
    chk_parts "$NEW_SCHEME,$SOCKET,$INSTANCE" || exit 1
    ;;
    
'suspend'|'resume')
    ;;

*)
    usage
    ;;

esac

exit 0
