aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorDouglas Gilbert <dgilbert@interlog.com>2014-06-12 13:35:52 +0000
committerDouglas Gilbert <dgilbert@interlog.com>2014-06-12 13:35:52 +0000
commit717f9ffc8f236831c8553f279515d5b87e8738d8 (patch)
tree854a101f006c1553e49a182529e7d51bfc031c2e /examples
parent9e32a38efe010c94758c41b3270d81055a637e83 (diff)
downloadsg3_utils-717f9ffc8f236831c8553f279515d5b87e8738d8.tar.gz
examples/sg_persist_tst.sh: add --exclusive option
git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@588 6180dd3e-e324-4e3e-922d-17de1ae2f315
Diffstat (limited to 'examples')
-rwxr-xr-xexamples/sg_persist_tst.sh18
1 files changed, 12 insertions, 6 deletions
diff --git a/examples/sg_persist_tst.sh b/examples/sg_persist_tst.sh
index c7483811..b6b926bb 100755
--- a/examples/sg_persist_tst.sh
+++ b/examples/sg_persist_tst.sh
@@ -3,19 +3,22 @@
# in the sg3_utils package. This script works as expected on the
# author's Fujitsu MAM3184, Seagate ST373455 and ST9146803SS disks.
#
-# Version 1.8 20140521
+# Version 1.9 20140612
# N.B. make sure the device name is correct for your environment.
key="123abc"
key2="333aaa"
kk=${key}
+rtype="1"
verbose=""
usage()
{
- echo "Usage: sg_persist_tst.sh [-h] [-s] [-v] <device>"
+ echo "Usage: sg_persist_tst.sh [-e] [-h] [-s] [-v] <device>"
echo " where:"
+ echo -n " -e, --exclusive exclusive access (def: write "
+ echo "exclusive)"
echo " -h, --help print usage message"
echo " -s, --second use second key"
echo " -v, --verbose more verbose output"
@@ -25,14 +28,17 @@ usage()
echo "Test SCSI Persistent Reservations with sg_persist utility."
echo "Default key is ${key} and alternate, second key is ${key2} ."
echo "Should be harmless (unless one of those keys is already in use)."
- echo "Also the APTPL bit is not set on the PR register so a power cycle"
- echo "on the device will clear it."
+ echo "The APTPL bit is not set in the PR register so a power cycle"
+ echo "on the device will clear the reservation if this script stops"
+ echo "(or is stopped) before clearing it. Tape drives only seem to "
+ echo "support 'exclusive access' type (so use '-e')."
}
opt="$1"
while test ! -z "$opt" -a -z "${opt##-*}"; do
opt=${opt#-}
case "$opt" in
+ e|-exclusive) rtype="3" ;;
h|-help) usage ; exit 0 ;;
s|-second) kk=${key2} ;;
vvv) verbose="-vvv" ;;
@@ -90,7 +96,7 @@ sleep 1
echo
echo ">>> reserve the device (based on key ${kk}):"
-sg_persist -n --out --reserve --param-rk=${kk} --prout-type=1 ${verbose} $1
+sg_persist -n --out --reserve --param-rk=${kk} --prout-type=${rtype} ${verbose} $1
sleep 1
echo
@@ -105,7 +111,7 @@ sleep 1
echo
echo ">>> now release reservation:"
-sg_persist -n --out --release --param-rk=${kk} --prout-type=1 ${verbose} $1
+sg_persist -n --out --release --param-rk=${kk} --prout-type=${rtype} ${verbose} $1
sleep 1
echo