diff options
author | Douglas Gilbert <dgilbert@interlog.com> | 2007-06-27 03:53:07 +0000 |
---|---|---|
committer | Douglas Gilbert <dgilbert@interlog.com> | 2007-06-27 03:53:07 +0000 |
commit | 2e37f3d2a90d421affd06e01dd05cd7c8194ca84 (patch) | |
tree | d55084e9efd7a1e3426b0389f58338f09faef41b /archive | |
parent | 7502647d46389b2e0e659f658b51f56abd1f9511 (diff) | |
download | sg3_utils-2e37f3d2a90d421affd06e01dd05cd7c8194ca84.tar.gz |
Load sg3_utils-1.24 into trunk/.
git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@76 6180dd3e-e324-4e3e-922d-17de1ae2f315
Diffstat (limited to 'archive')
-rwxr-xr-x | archive/o_scsi_logging_level | 295 | ||||
-rw-r--r-- | archive/sg3_utils_123o.spec | 193 |
2 files changed, 295 insertions, 193 deletions
diff --git a/archive/o_scsi_logging_level b/archive/o_scsi_logging_level new file mode 100755 index 00000000..ecbc8277 --- /dev/null +++ b/archive/o_scsi_logging_level @@ -0,0 +1,295 @@ +#! /bin/bash +############################################################################### +# Conveniently create and set scsi logging level, show SCSI_LOG fields in human +# readable form. +# +# Copyright (C) IBM Corp. 2006 +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. +############################################################################### + +# Contributed by Andreas Herrmann <aherrman@de.ibm.com> 2006/08/18 + +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 + +_ERROR_SHIFT=0 +_TIMEOUT_SHIFT=3 +_SCAN_SHIFT=6 +_MLQUEUE_SHIFT=9 +_MLCOMPLETE_SHIFT=12 +_LLQUEUE_SHIFT=15 +_LLCOMPLETE_SHIFT=18 +_HLQUEUE_SHIFT=21 +_HLCOMPLETE_SHIFT=24 +_IOCTL_SHIFT=27 + +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 +$SCRIPTNAME (s390-tools) %S390_TOOLS_VERSION% +(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 --hlcomplete 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() +{ +# something is wrong with the following if ... dpg 20061027 +# if [ `echo -n $1 | tr --complement [:digit:] 'a' | grep -s 'a'` ] +# then +# invalid_cmdline "log level '$1' out of range [0, 7]" +# fi + + if [ $1 -lt 0 -o $1 -gt 7 ] + then + invalid_cmdline "log level '$1' out of range [0, 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; check_level $2 + shift 2;; + --mlcomplete) _MLCOMPLETE=$2; check_level $2 + shift 2;; + -L|--lowlevel) _LL=$2; check_level $2 + shift 2;; + --llqueue) _LLQUEUE=$2; check_level $2 + shift 2;; + --llcomplete) _LLCOMPLETE=$2; check_level $2 + shift 2;; + -H|--highlevel) _HL=$2; check_level $2 + shift 2;; + --hlqueue) _HLQUEUE=$2; check_level $2 + shift 2;; + --hlcomplete) _HLCOMPLETE=$2; check_level $2 + shift 2;; + -I|--ioctl) _IOCTL=$2; check_level $2 + shift 2;; + --) shift; break;; + *) echo "Internal error!" ; exit 1;; + esac + done + + if [ -n "$*" ] + then + invalid_cmdline invalid parameter $* + fi + + if [ $GET = "1" -a $SET = "1" ] + then + invalid_cmdline options \'-c\', \'-g\' and \'-s\' are mutual exclusive + elif [ $GET = "1" -a $CREATE = "1" ] + then + invalid_cmdline options \'-c\', \'-g\' and \'-s\' are mutual exclusive + elif [ $SET = "1" -a $CREATE = "1" ] + then + invalid_cmdline options \'-c\', \'-g\' and \'-s\' are mutual exclusive + fi + + LOG_ERROR=${_ERROR:-${_ALL:-0}} + LOG_TIMEOUT=${_TIMEOUT:-${_ALL:-0}} + LOG_SCAN=${_SCAN:-${_ALL:-0}} + LOG_MLQUEUE=${_MLQUEUE:-${_ML:-${_ALL:-0}}} + LOG_MLCOMPLETE=${_MLCOMPLETE:-${_ML:-${_ALL:-0}}} + LOG_LLQUEUE=${_LLQUEUE:-${_LL:-${_ALL:-0}}} + LOG_LLCOMPLETE=${_LLCOMPLETE:-${_LL:-${_ALL:-0}}} + LOG_HLQUEUE=${_HLQUEUE:-${_HL:-${_ALL:-0}}} + LOG_HLCOMPLETE=${_HLCOMPLETE:-${_HL:-${_ALL:-0}}} + LOG_IOCTL=${_IOCTL:-${_ALL:-0}} +} + +invalid_cmdline() +{ + echo "$SCRIPTNAME: $*" + echo "$SCRIPTNAME: Try '$SCRIPTNAME --help' for more information." + exit 1 +} + +get_logging_level() +{ + echo "Current scsi logging level:" + LEVEL=`sysctl -n dev.scsi.logging_level` + if [ $? != 0 ] + then + echo "$SCRIPTNAME: could not read scsi logging level" \ + "(kernel probably without SCSI_LOGGING support)" + exit 1 + fi +} + +show_logging_level() +{ + echo "dev.scsi.logging_level = $LEVEL" + + LOG_ERROR=$((($LEVEL>>$_ERROR_SHIFT) & 7)) + LOG_TIMEOUT=$((($LEVEL>>$_TIMEOUT_SHIFT) & 7)) + LOG_SCAN=$((($LEVEL>>$_SCAN_SHIFT) & 7)) + LOG_MLQUEUE=$((($LEVEL>>$_MLQUEUE_SHIFT) & 7)) + LOG_MLCOMPLETE=$((($LEVEL>>$_MLCOMPLETE_SHIFT) & 7)) + LOG_LLQUEUE=$((($LEVEL>>$_LLQUEUE_SHIFT) & 7)) + LOG_LLCOMPLETE=$((($LEVEL>>$_LLCOMPLETE_SHIFT) & 7)) + LOG_HLQUEUE=$((($LEVEL>>$_HLQUEUE_SHIFT) & 7)) + LOG_HLCOMPLETE=$((($LEVEL>>$_HLCOMPLETE_SHIFT) & 7)) + LOG_IOCTL=$((($LEVEL>>$_IOCTL_SHIFT) & 7)) + + echo "SCSI_LOG_ERROR=$LOG_ERROR" + echo "SCSI_LOG_TIMEOUT=$LOG_TIMEOUT" + echo "SCSI_LOG_SCAN=$LOG_SCAN" + echo "SCSI_LOG_MLQUEUE=$LOG_MLQUEUE" + echo "SCSI_LOG_MLCOMPLETE=$LOG_MLCOMPLETE" + echo "SCSI_LOG_LLQUEUE=$LOG_LLQUEUE" + echo "SCSI_LOG_LLCOMPLETE=$LOG_LLCOMPLETE" + echo "SCSI_LOG_HLQUEUE=$LOG_HLQUEUE" + echo "SCSI_LOG_HLCOMPLETE=$LOG_HLCOMPLETE" + echo "SCSI_LOG_IOCTL=$LOG_IOCTL" +} + +set_logging_level() +{ + echo "New scsi logging level:" + sysctl -q -w dev.scsi.logging_level=$LEVEL + if [ $? != 0 ] + then + echo "$SCRIPTNAME: could not write scsi logging level" \ + "(kernel probably without SCSI_LOGGING support)" + exit 1 + fi +} + +create_logging_level() +{ + LEVEL=$((($LOG_ERROR & 7)<<$_ERROR_SHIFT)) + LEVEL=$(($LEVEL|(($LOG_TIMEOUT & 7)<<$_TIMEOUT_SHIFT))) + LEVEL=$(($LEVEL|(($LOG_SCAN & 7)<<$_SCAN_SHIFT))) + LEVEL=$(($LEVEL|(($LOG_MLQUEUE & 7)<<$_MLQUEUE_SHIFT))) + LEVEL=$(($LEVEL|(($LOG_MLCOMPLETE & 7)<<$_MLCOMPLETE_SHIFT))) + LEVEL=$(($LEVEL|(($LOG_LLQUEUE & 7)<<$_LLQUEUE_SHIFT))) + LEVEL=$(($LEVEL|(($LOG_LLCOMPLETE & 7)<<$_LLCOMPLETE_SHIFT))) + LEVEL=$(($LEVEL|(($LOG_HLQUEUE & 7)<<$_HLQUEUE_SHIFT))) + LEVEL=$(($LEVEL|(($LOG_HLCOMPLETE & 7)<<$_HLCOMPLETE_SHIFT))) + LEVEL=$(($LEVEL|(($LOG_IOCTL & 7)<<$_IOCTL_SHIFT))) +} + +check_cmdline $* + +if [ $SET = "1" ] +then + create_logging_level + set_logging_level + show_logging_level +elif [ $GET = "1" ] +then + get_logging_level + show_logging_level +elif [ $CREATE = "1" ] +then + create_logging_level + show_logging_level +else + invalid_cmdline missing option \'-g\', \'-s\' or \'-c\' +fi + diff --git a/archive/sg3_utils_123o.spec b/archive/sg3_utils_123o.spec deleted file mode 100644 index ee8295fa..00000000 --- a/archive/sg3_utils_123o.spec +++ /dev/null @@ -1,193 +0,0 @@ -%define name sg3_utils -%define version 1.23 -%define release 1 - -%define major 1 -%define minor 0 -%define libname %{_lib}sgutils-%{major}_%{minor} - -Summary: Utilities for SCSI devices in Linux -Name: %{name} -Version: %{version} -Release: %{release} -License: GPL/FreeBSD -Group: Utilities/System -URL: http://www.torque.net/sg/sg3_utils.html -Source0: http://www.torque.net/sg/p/%{name}-%{version}.tgz -BuildRoot: %{_tmppath}/%{name}-%{version}-root -Packager: Douglas Gilbert <dgilbert at interlog dot com> - -%description -Collection of Linux utilities for devices that use the SCSI command set. -Includes utilities to copy data based on "dd" syntax and semantics (called -sg_dd, sgp_dd and sgm_dd); check INQUIRY data and VPD pages (sg_inq); check -mode and log pages (sginfo, sg_modes and sg_logs); spin up and down -disks (sg_start); do self tests (sg_senddiag); and various other functions. -See the README, CHANGELOG and COVERAGE files. Requires the linux kernel 2.4 -series or later. In the 2.4 series SCSI generic device names (e.g. /dev/sg0) -must be used. In the 2.6 series other device names may be used as -well (e.g. /dev/sda). - -Warning: Some of these tools access the internals of your system -and the incorrect usage of them may render your system inoperable. - -%package -n %{libname} -Summary: Shared library for %{name} -Group: System/Libraries - -%description -n %{libname} -This package contains the shared library for %{name}. - -%package -n %{libname}-devel -Summary: Static library and header files for the sgutils library -Group: Development/C -Obsoletes: %{name}-devel -Provides: %{name}-devel -Provides: libsgutils-devel -Requires: %{libname} = %{version}-%{release} - -%description -n %{libname}-devel -This package contains the static sgutils library and its header -files. - -%prep - -%setup -q - -%build - -make \ - CFLAGS="%{optflags}" \ - LIBDIR="%{_libdir}" - -%install -[ "%{buildroot}" != "/" ] && rm -rf %{buildroot} - -make install \ - PREFIX=%{_prefix} \ - LIBDIR=%{buildroot}/%{_libdir} \ - INSTDIR=%{buildroot}/%{_bindir} \ - MANDIR=%{buildroot}/%{_mandir} \ - INCLUDEDIR=%{buildroot}/%{_includedir} \ - LIB_VINFO=1:0:0 - -%post -n %{libname} -p /sbin/ldconfig - -%postun -n %{libname} -p /sbin/ldconfig - -%clean -[ "%{buildroot}" != "/" ] && rm -rf %{buildroot} - -%files -%defattr(-,root,root) -%doc CHANGELOG COPYING COVERAGE CREDITS INSTALL README README.sg_start -%attr(0755,root,root) %{_bindir}/* -%{_mandir}/man8/* - -%files -n %{libname} -%defattr(-,root,root) -%{_libdir}/*.so.* - -%files -n %{libname}-devel -%defattr(-,root,root) -%{_includedir}/scsi/*.h -%{_libdir}/*.so -%{_libdir}/*.a -%{_libdir}/*.la - -%changelog -* Tue Jan 30 2007 - dgilbert at interlog dot com -- add sg_read_buffer + sg_write_buffer - * sg3_utils-1.23 - -* Mon Oct 16 2006 - dgilbert at interlog dot com -- add sg_sat_identify, expand sg_format and sg_requests - * sg3_utils-1.22 - -* Thu Jul 06 2006 - dgilbert at interlog dot com -- add sg_vpd and sg_rdac, uniform exit statuses - * sg3_utils-1.21 - -* Tue Apr 18 2006 - dgilbert at interlog dot com -- sg_logs: sas port specific page decoding, sg*_dd updates - * sg3_utils-1.20 - -* Fri Jan 27 2006 - dgilbert at interlog dot com -- sg_get_config: resync features with mmc5 rev 1 - * sg3_utils-1.19 - -* Fri Nov 18 2005 - dgilbert at interlog dot com -- add sg_map26; sg_inq '-rr' option to play with hdparm - * sg3_utils-1.18 - -* Thu Sep 22 2005 - dgilbert at interlog dot com -- add ATA information VPD page to sg_inq - * sg3_utils-1.17 - -* Wed Aug 10 2005 - dgilbert at interlog dot com -- add sg_ident, sg_inq VPD page extensions - * sg3_utils-1.16 - -* Sun Jun 05 2005 - dgilbert at interlog dot com -- use O_NONBLOCK on all fds that use SG_IO ioctl - * sg3_utils-1.15 - -* Fri May 06 2005 - dgilbert at interlog dot com -- produce libsgutils (+ -devel variant) as well as sg3_utils binary rpm - * sg3_utils-1.14 - -* Sun Mar 13 2005 - dgilbert at interlog dot com -- add sg_format, sg_dd extensions - * sg3_utils-1.13 - -* Fri Jan 21 2005 - dgilbert at interlog dot com -- add sg_wr_mode, sg_rtpg + sg_reassign; sginfo sas tweaks - * sg3_utils-1.12 - -* Fri Nov 26 2004 - dgilbert at interlog dot com -- add sg_sync, sg_prevent and sg_get_config; fix sg_requests - * sg3_utils-1.11 - -* Sat Oct 30 2004 - dgilbert at interlog dot com -- fix read capacity (10+16), add sg_luns - * sg3_utils-1.10 - -* Thu Oct 21 2004 - dgilbert at interlog dot com -- sg_requests, sg_ses, sg_verify, libsgutils(sg_lib.c+sg_cmds.c), devel rpm - * sg3_utils-1.09 - -* Tue Aug 31 2004 - dgilbert at interlog dot com -- 'register+move' in sg_persist, sg_opcodes sorts, sg_write_long - * sg3_utils-1.08 - -* Thu Jul 08 2004 - dgilbert at interlog dot com -- add '-fHead' to sginfo, '-i' for sg_inq, new sg_opcodes + sg_persist - * sg3_utils-1.07 - -* Mon Apr 26 2004 - dgilbert at interlog dot com -- sg3_utils.spec for mandrake; more sginfo work, sg_scan, sg_logs - * sg3_utils-1.06 - -* Wed Nov 12 2003 - dgilbert at interlog dot com -- sg_readcap: sizes; sg_logs: double fetch; sg_map 256 sg devices; sginfo - * sg3_utils-1.05 - -* Tue May 13 2003 - dgilbert at interlog dot com -- default sg_turs '-n=' to 1, sg_logs gets '-t' for temperature, CREDITS - * sg3_utils-1.04 - -* Wed Apr 02 2003 - dgilbert at interlog dot com -- 6 byte CDBs for sg_modes, sg_start on block devs, sg_senddiag, man pages - * sg3_utils-1.03 - -* Wed Jan 01 2003 - dgilbert at interlog dot com -- interwork with block SG_IO, fix in sginfo, '-t' for sg_turs - * sg3_utils-1.02 - -* Wed Aug 14 2002 - dgilbert at interlog dot com -- raw switch in sg_inq - * sg3_utils-1.01 - -* Sun Jul 28 2002 - dgilbert at interlog dot com -- decode sg_logs pages, add dio to sgm_dd, drop "gen=1" arg, "of=/dev/null" - * sg3_utils-1.00 |