#!/bin/sh # # memory.sample 1.2 1995/05/30 15:48:37 (David Hinds) # # Initialize or shutdown a PCMCIA 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 character and block device files for one common # memory region and one attribute memory region: # # /dev/{name}c0c - common memory region 0, character device # /dev/{name}c0b - common memory region 0, block device # /dev/{name}a0c - attribute memory region 0, character device # /dev/{name}a0b - attribute memory region 0, block device # # Also, it creates two shorthand links: # # /dev/{name}c -> /dev/{name}c0c # /dev/{name}b -> /dev/{name}c0b usage() { echo "usage: memory [action] [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}c0c c $major $minor mknod /dev/${name}c0b b $major $minor mknod /dev/${name}a0c c $major `expr $minor + 4` mknod /dev/${name}a0b b $major `expr $minor + 4` ln -s /dev/${name}c0c /dev/${name}c ln -s /dev/${name}c0b /dev/${name}b ;; 'stop') fuser -k /dev/${name}* rm -f /dev/${name}* ;; esac