2 #==============================================================================
3 # Copyright IBM Corp. 2008.
7 # Script to display zcrypt devices and configuration settings.
9 # Author(s): Ralph Wuerthner <rwuerthn@de.ibm.com>
10 # Felix Beck <felix.beck@de.ibm.com>
12 # This file is part of s390-tools
14 # s390-tools is free software; you can redistribute it and/or modify
15 # it under the terms of the GNU General Public License as published by
16 # the Free Software Foundation; either version 2 of the License, or
17 # (at your option) any later version.
19 # s390-tools is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU General Public License for more details.
24 # You should have received a copy of the GNU General Public License
25 # along with s390-tools; if not, write to the Free Software
26 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 #==============================================================================
29 CMD
="$( basename $0 )"
31 function print_usage
() {
33 Usage: $CMD [<options>] [<cryptographic adapter ids>]
34 Display zcrypt device and configuration information.
38 Show AP bus attributes and exit.
40 Increase verbose level for cryptographic adapter information. Maximum
43 Show version information and exit.
45 Show this help text and exit.
47 <cryptographic adapter ids>
48 List of cryptographic adapter ids separated by blanks which will be displayed.
49 If not ids are given all available adapters are displayed.
53 function print_version
() {
55 $CMD: version %S390_TOOLS_VERSION%
56 Copyright IBM Corp. 2007
62 echo "Try '$CMD --help' for more information." >&2
68 DOMAIN
="$( cat $AP/ap_domain 2> /dev/null )"
69 CONFIG_TIME
="$( cat $AP/config_time 2> /dev/null )"
70 POLL_TIMEOUT
="$( cat $AP/poll_timeout 2> /dev/null )"
71 if [ "$( cat $AP/poll_thread 2> /dev/null )" -eq 1 ] ; then
74 POLL_THREAD
="disabled"
76 if [ "$( cat $AP/ap_interrupts 2> /dev/null )" -eq 1 ] ; then
77 AP_INTERRUPTS
="enabled"
79 AP_INTERRUPTS
="disabled"
81 echo "ap_domain=$DOMAIN"
82 if [ -f "$AP/ap_interrupts" ] ; then
83 echo "ap_interrupts are $AP_INTERRUPTS"
85 echo "config_time=$CONFIG_TIME (seconds)"
86 echo "poll_thread is $POLL_THREAD"
87 if [ -f "$AP/poll_timeout" ] ; then
88 echo "poll_timeout=$POLL_TIMEOUT (nanoseconds)"
94 DEV
="$SYSFS/bus/ap/devices/$CARD"
95 if [ ! -d "$DEV" ] ; then
96 echo "$CMD: error - cryptographic adapter $CARD does not exist!" >&2
99 if [ -r $DEV/type ] ; then
100 TYPE
="$( cat $DEV/type 2> /dev/null )"
104 if [ -r $DEV/online
] ; then
105 if [ "$( cat $DEV/online 2> /dev/null )" -eq 0 ] ; then
114 0) echo "$CARD: $TYPE"
116 1) printf "%s: %-11s %-7s\n" $CARD $TYPE $ONLINE
119 HWTYPE
="$( cat $DEV/hwtype 2> /dev/null )"
120 DEPTH
="$( cat $DEV/depth 2> /dev/null )"
121 REQ_CNT
="$( cat $DEV/request_count 2> /dev/null )"
122 printf "%s: %-11s %-7s hwtype=%-2d depth=%d request_count=%-10d\n" \
123 $CARD $TYPE $ONLINE $HWTYPE $DEPTH $REQ_CNT
128 TEMP
=`getopt -o bhvV \
129 --long bus,help,version,verbose \
131 if [ $?
!= 0 ] ; then
142 -h|
--help) print_usage
144 -v|
--version) print_version
146 -V|
--verbose) let VERBOSE
++
149 *) echo "Internal error!" ; exit 1;;
153 # Check sysfs and zcrypt availability
154 if [ -z "$( cat /proc/filesystems | grep sysfs )" ] ; then
155 echo "$CMD: error - sysfs support required!" >&2
158 SYSFS
="$( cat /proc/mounts | awk '$3=="sysfs
" { print $2 ; exit }' )"
159 if [ -z "$SYSFS" ] ; then
160 echo "$CMD: error - sysfs filesystem must be mounted!" >&2
163 if [ ! -d "$SYSFS/bus/ap" ] ; then
164 echo "$CMD: error - cryptographic device driver zcrypt is not loaded!" >&2
168 if [ -n "$SHOW_BUS" ] ; then
173 if [ $# -eq 0 ] ; then
174 DEVLIST
="$( find $SYSFS/bus/ap/devices -name 'card*' -printf '%f\n' | sort )"
175 for CARD
in $DEVLIST ; do
180 CARD
="$( printf "card
%02x
" "$ID" 2> /dev/null )"
181 if [ $?
-ne 0 ] ; then
182 invalid_cmdline
"error - '$ID' is an invalid cryptographic adapter id!"