Annotation of coherent/b/STREAMS/conf/bin/src/idcheck, revision 1.1

1.1     ! root        1: # Shell version of something similar to the System V 'idcheck' command
        !             2: 
        !             3: ##################### FUNCTION DEFINITIONS #######################
        !             4: 
        !             5: # Call with the $0 of the script as a parameter; this commands writes the
        !             6: # name of the directory containing the script to standard output.
        !             7: # Example:
        !             8: #      conf_path $0
        !             9: 
        !            10: conf_path () {
        !            11:        set `which $1 2>/dev/null` X
        !            12:        if [ $# -ne 2 ]; then
        !            13:                echo .          # Assume the current directory.
        !            14:                return 1
        !            15:        fi
        !            16:        set `expr $1 : '\(.*\)/.*'` X
        !            17:        if [ $# -ne 2 ]; then
        !            18:                echo .          # Must be in the current directory.
        !            19:        else
        !            20:                echo $1
        !            21:        fi
        !            22:        return 0
        !            23: }
        !            24: 
        !            25: # Report a usage message to standard output, with the name of the script
        !            26: # passed as the argument to this function.
        !            27: 
        !            28: usage () {
        !            29:        echo $1 ": Check conditions related to installable devices"
        !            30:        echo "usage :\t-p device_name [-i dir] [-r]"
        !            31:        echo "\t-v vector [-i dir] [-r]"
        !            32:        echo "\t-d dma_channel [-i dir] [-r]"
        !            33:        echo "\t-a -l lower_address -u upper_address [-i dir] [-r]"
        !            34:        echo "\t-c -l lower_address -u upper_address [-i dir] [-r]"
        !            35: }
        !            36: 
        !            37: # Check whether the indicated package is installed already
        !            38: 
        !            39: check_name () {
        !            40:        grep "^$1" $CONF_DIR/mdevice 2>/dev/null 1>&2
        !            41:        set $?
        !            42:        if [ $1 -gt 1 ]; then
        !            43:                echo Unable to check $CONF_DIR/mdevice 1>&2
        !            44:        fi
        !            45:        return $1
        !            46: }
        !            47: 
        !            48: # Check to see whether the indicated interrupt vector is in use. We do this
        !            49: # by telling 'devadm' about a bogus new device that requires that vector for
        !            50: # exclusive use, and asking it to list conflicting devices to stdout.
        !            51: 
        !            52: check_vector () {
        !            53:        set X `$HOME_DIR/devadm -M"foo - H foo 0 0 0 0 -1 -1" \
        !            54:                                -S"foo Y 0 7 1 $1 0x0 0x0 0x0 0x0" \
        !            55:                                -r -I $CONF_DIR`
        !            56:        if [ $# -gt 1 ]; then
        !            57:                if [ -n "$REPORT_CONFLICTS" ]; then
        !            58:                        shift; echo $*
        !            59:                fi
        !            60:                return 1
        !            61:        fi
        !            62:        return 0
        !            63: }
        !            64: 
        !            65: # Check to see whether the indicated IOA range is in use. We use this by
        !            66: # telling 'devadm' about a bogus new device that requires that IOA range for
        !            67: # its own use, and asking it to list conflicting devices to stdout.
        !            68: 
        !            69: check_ioa () {
        !            70:        set X `$HOME_DIR/devadm -M"foo - H foo 0 0 0 0 -1 -1" \
        !            71:                                -S"foo Y 0 0 0 0 $LOWER $UPPER 0x0 0x0" \
        !            72:                                -r -I $CONF_DIR`
        !            73:        if [ $# -gt 1 ]; then
        !            74:                if [ -n "$REPORT_CONFLICTS" ]; then
        !            75:                        shift; echo $*
        !            76:                fi
        !            77:                return 1
        !            78:        fi
        !            79:        return 0
        !            80: }
        !            81: 
        !            82: # Check to see whether the indicated CMA range is in use. We use this by
        !            83: # telling 'devadm' about a bogus new device that requires that CMA range for
        !            84: # its own use, and asking it to list conflicting devices to stdout.
        !            85: 
        !            86: check_cma () {
        !            87:        set X `$HOME_DIR/devadm -M"foo - H foo 0 0 0 0 -1 -1" \
        !            88:                                -S"foo Y 0 0 0 0 0x0 0x0 $LOWER $UPPER" \
        !            89:                                -r -I $CONF_DIR`
        !            90:        if [ $# -gt 1 ]; then
        !            91:                if [ -n "$REPORT_CONFLICTS" ]; then
        !            92:                        shift; echo $*
        !            93:                fi
        !            94:                return 1
        !            95:        fi
        !            96:        return 0
        !            97: }
        !            98: 
        !            99: # Check to see whether the indicated DMA channel is in use.
        !           100: 
        !           101: check_dma () {
        !           102:        echo DMA channel configuration is not yet supported 1>&2
        !           103:        return 1
        !           104: }
        !           105: 
        !           106: 
        !           107: # internal function used by check_block (), and check_char () to invoke
        !           108: # 'devadm' with a similar bogus device but different flags
        !           109: 
        !           110: check_dev () {
        !           111:        set X `$HOME_DIR/devadm -M"foo - $1 foo $LOWER $UPPER 0 0 -1 -1" \
        !           112:                                -S"foo Y 0 0 0 0 0x0 0x0 0x0 0x0" \
        !           113:                                -r -I $CONF_DIR`
        !           114:        if [ $# -gt 1 ]; then
        !           115:                if [ -n "$REPORT_CONFLICTS" ]; then
        !           116:                        shift; echo $*
        !           117:                fi
        !           118:                return 1
        !           119:        fi
        !           120:        return 0
        !           121: }
        !           122: 
        !           123: # Check to see whether the indicated block major range is in use. We use this
        !           124: # by telling 'devadm' about a bogus new device that requires that range for
        !           125: # its own use, and asking it to list conflicting devices to stdout.
        !           126: 
        !           127: check_block () {
        !           128:        if [ $LOWER -lt 32 ]; then
        !           129:                check_dev CGo
        !           130:        else
        !           131:                check_dev bD
        !           132:        fi
        !           133:        return $?
        !           134: }
        !           135: 
        !           136: # Check to see whether the indicated character major range is in use. We use
        !           137: # this by telling 'devadm' about a bogus new device that requires that range
        !           138: # for its own use, and asking it to list conflicting devices to stdout.
        !           139: 
        !           140: check_char () {
        !           141:        if [ $LOWER -lt 32 ]; then
        !           142:                check_dev CGo
        !           143:        else
        !           144:                check_dev cD
        !           145:        fi
        !           146:        return $?
        !           147: }
        !           148: 
        !           149: HOME_DIR=`conf_path $0`
        !           150: CONF_DIR=$HOME_DIR/..
        !           151: 
        !           152: if [ $# -lt 1 ]; then
        !           153:        usage $0 1>&2
        !           154:        exit 100
        !           155: fi
        !           156: 
        !           157: while [ $# -gt 0 ]; do
        !           158:        ARG=$1; shift
        !           159:        case $ARG in
        !           160:        -p)     NEW_COMMAND="check_name $1" ; shift
        !           161:                ;;
        !           162: 
        !           163:        -i)     CONF_DIR=$1; shift
        !           164:                ;;
        !           165: 
        !           166:        -v)     NEW_COMMAND="check_vector $1" ; shift
        !           167:                ;;
        !           168: 
        !           169:        -l)     LOWER="$1"; : ${UPPER:=$1}; shift
        !           170:                ;;
        !           171: 
        !           172:        -u)     UPPER="$1"; : ${LOWER:=$1}; shift
        !           173:                ;;
        !           174: 
        !           175:        -a)     NEW_COMMAND="check_ioa"
        !           176:                ;;
        !           177: 
        !           178:        -c)     NEW_COMMAND="check_cma"
        !           179:                ;;
        !           180: 
        !           181:        -d)     NEW_COMMAND="check_dma $1"; shift
        !           182:                ;;
        !           183: 
        !           184:        -B)     NEW_COMMAND="check_block"
        !           185:                ;;
        !           186: 
        !           187:        -C)     NEW_COMMAND="check_char"
        !           188:                ;;
        !           189: 
        !           190:        -r)     REPORT_CONFLICTS=1
        !           191:                ;;
        !           192: 
        !           193:        *)      echo Bad argument ": $ARG" 1>&2
        !           194:                usage $0 1>&2
        !           195:                exit 100
        !           196:                ;;
        !           197:        esac
        !           198: 
        !           199:        if [ -n "$NEW_COMMAND" ]; then
        !           200:                if [ -n "$COMMAND" ]; then
        !           201:                        echo Bad argument ": $ARG" 1>&2
        !           202:                        usage $0 1>&2
        !           203:                        exit 100
        !           204:                fi
        !           205:                COMMAND="$NEW_COMMAND"
        !           206:                NEW_COMMAND=
        !           207:        fi
        !           208: done
        !           209: 
        !           210: $COMMAND

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.