0x9fc00
  9   3ˆl–Ãa¾”jhŠq@
ãN\ŠbÑ¿Íƒy·ža–Ü4ý()¨‰P@Š»�3q‘)‹FÿÐ !Œ    3#!/usr/bin/bash
###############################################################################
# Conveniently create and set scsi logging level, show SCSI_LOG fields in human
# readable form.
#
# (C) Copyright IBM Corp. 2006
#
# Modified by D. Gilbert to replace the use of sysctl [20080218]
# Lat change: D. Gilbert 20150219
###############################################################################


REVISION="1.0"
SCRIPTNAME="scsi_logging_level"

declare -i LOG_ERROR=0
declare -i LOG_TIMEOUT=0
declare -i LOG_SCAN=0
declare -i LOG_MLQUEUE=0
declare -i LOG_MLCOMPLETE=0
declare -i LOG_LLQUEUE=0
declare -i LOG_LLCOMPLETE=0
declare -i LOG_HLQUEUE=0
declare -i LOG_HLCOMPLETE=0
declare -i LOG_IOCTL=0

declare -i LEVEL=0

SET=0
GET=0
CREATE=0

OPTS=$(getopt -o hvcgsa:E:T:S:I:M:L:H: --long \
help,version,create,get,set,all:,error:,timeout:,scan:,ioctl:,\
midlevel:,mlqueue:,mlcomplete:,lowlevel:,llqueue:,llcomplete:,\
highlevel:,hlqueue:,hlcomplete: -n \'$SCRIPTNAME\' -- "$@")
eval set -- "$OPTS"

# print version info
printversion()
{
    cat <<EOF
%S390_TOOLS_VERSION% ($SCRIPTNAME $REVISION)
(C) Copyright IBM Corp. 2006
EOF
}

# print usage and help
printhelp()
{
    cat <<EOF
Usage: $SCRIPTNAME [OPTIONS]

Create, get or set scsi logging level.

Options:

        -h, --help       print this help
        -v, --version    print version information
        -s, --set        create and set logging level as specified on
                         command line
        -g, --get        get current logging level and display it
        -c, --create     create logging level as specified on command line
        -a, --all        specify value for all SCSI_LOG fields
        -E, --error      specify SCSI_LOG_ERROR
        -T, --timeout    specify SCSI_LOG_TIMEOUT
        -S, --scan       specify SCSI_LOG_SCAN
        -M, --midlevel   specify SCSI_LOG_MLQUEUE and SCSI_LOG_MLCOMPLETE
            --mlqueue    specify SCSI_LOG_MLQUEUE
            --mlcomplete specify SCSI_LOG_MLCOMPLETE
        -L, --lowlevel   specify SCSI_LOG_LLQUEUE and SCSI_LOG_LLCOMPLETE
            --llqueue    specify SCSI_LOG_LLQUEUE
            --llcomplete specify SCSI_LOG_LLCOMPLETE
        -H, --highlevel  specify SCSI_LOG_HLQUEUE and SCSI_LOG_HLCOMPLETE
            --hlqueue    specify SCSI_LOG_HLQUEUE
            --hlcomplete specify SCSI_LOG_HLCOMPLETE
        -I, --ioctl      specify SCSI_LOG_IOCTL

Exactly one of the options "-c", "-g" and "-s" has to be specified.
Valid values for SCSI_LOG fields are integers from 0 to 7.

Note: Several SCSI_LOG fields can be specified using several options.
When multiple options specify same SCSI_LOG field the most specific
option has precedence.

Example: "scsi_logging_level --hlqueue 3 --highlevel 2 --all 1 -s" sets
SCSI_LOG_HLQUEUE=3, SCSI_LOG_HLCOMPLETE=2 and assigns all other SCSI_LOG
fields the value 1.
EOF
}

check_level()
{
    num=$(($1))
    if [ $num != "$1" ] ; then
        invalid_cmdline "log level '$1' not a number"
    elif [ $num -lt 0  ] || [ $num -gt 7 ] ; then
        invalid_cmdline "log level '$1' out of range, expect '0' to '7'"
    fi
}

# check cmd line arguments
check_cmdline()
{
    while true ; do
        case "$1" in
            -a|--all)   _ALL="$2"; check_level "$2"
                        shift 2;;
            -c|--create) CREATE=1;
                        shift 1;;
            -g|--get)   GET=1
                        shift 1;;
            -h|--help) printhelp
                        exit 0;;
            -s|--set)   SET=1
                        shift 1;;
            -v|--version) printversion
                        exit 0;;
            -E|--error) _ERROR="$2"; check_level "$2"
                        shift 2;;
            -T|--timeout) _TIMEOUT="$2"; check_level "$2"
                        shift 2;;
            -S|--scan)  _SCAN="$2"; check_level "$2"
                        shift 2;;
            -M|--midlevel) _ML="$2"; check_level "$2"
                        shift 2;;
            --mlqueue)  _MLQUEUE="$2"