1#!/bin/bash 2# scsi_satl 3# 4# Script to test compliance of SCSI commands on a SCSI to ATA 5# Translation (SAT) Layer (SATL). This script was compiled using 6# sat-r09.pdf found at www.t10.org . 7# The scripts still seems to be valid for sat2r09.pdf . 8# The vintage is SPC-3 and SPC-4 (see www.t10.org). 9# 10# Coverage: 11# Command SATL notes 12# ------------------------------------------------------- 13# INQUIRY (standard) 14# INQUIRY (VPD: 0) 15# INQUIRY (VPD: 0x83) Device identification VPD page 16# INQUIRY (VPD: 0x89) ATA Information VPD page 17# REPORT LUNS SPC-3, SPC-4 (hardly mentioned in sat-r08c) 18# TEST UNIT READY 19# REQUEST SENSE 20# SEND DIAGNOSTIC default self test 21# MODE SENSE(10) draft unclear which mode pages, so ask for all 22# ATA PASS THROUGH(16) send IDENTIFY DEVICE command. Assume non-packet 23# device, if packet device add "-p" option 24# 25# This script uses utilities from sg3_utils package (version 26# 1.22 or later) 27# 28# Douglas Gilbert 20090930 29 30 31log=0 32quiet=0 33verbose="" 34 35file_err=0 36inv_opcode=0 37illeg_req=0 38not_ready=0 39medium=0 40other_err=0 41recovered=0 42sanity=0 43syntax=0 44timeout=0 45unit_attention=0 46aborted_command=0 47 48## total_err=0 49 50usage() 51{ 52 echo "Usage: scsi_satl [-h] [-L] [-q] [-v] <device>" 53 echo " where: -h, --help print usage message" 54 echo " -L, --log append stderr to 'scsi_satl.err'" 55 echo " -q, --quiet suppress some output" 56 echo " -v, --verbose more verbose output" 57 echo "" 58 echo "Check <device> for SCSI to ATA Translation Layer (SATL) support" 59} 60 61opt="$1" 62while test ! -z "$opt" -a -z "${opt##-*}"; do 63 opt=${opt#-} 64 case "$opt" in 65 h|-help) usage ; exit 1 ;; 66 L|-log) let log=$log+1 ;; 67 q|-quiet) let quiet=$quiet+1 ;; 68 v|-verbose) verbose="-v" ;; 69 *) echo "Unknown option: -$opt " ; exit 1 ;; 70 esac 71 shift 72 opt="$1" 73done 74 75if [ $# -lt 1 ] 76 then 77 usage 78 exit 1 79fi 80 81for command in "sg_inq" "sg_vpd" "sg_vpd -p di" "sg_vpd -p ai" "sg_luns" \ 82 "sg_turs" "sg_requests -s" "sg_senddiag -t" "sg_modes -a" \ 83 "sg_sat_identify" 84do 85 if [ $quiet -eq 0 ] 86 then echo "$command" "$1" 87 fi 88 89 if [ $log -eq 0 ] 90 then 91 if [ $verbose ] 92 then 93 $command $verbose "$1" > /dev/null 94 else 95 $command "$1" > /dev/null 2>> /dev/null 96 fi 97 else 98 $command $verbose "$1" > /dev/null 2>> scsi_satl.err 99 fi 100 res=$? 101 case "$res" in 102 0) ;; 103 1) echo " syntax error" ; let syntax=$syntax+1 ;; 104 2) echo " not ready" ; let not_ready=$not_ready+1 ;; 105 3) echo " medium error" ; let medium=$medium+1 ;; 106 5) echo " illegal request, general" ; let illeg_req=$illeg_req+1 ;; 107 6) echo " unit attention" ; let unit_attention=$unit_attention+1 ;; 108 9) echo " illegal request, invalid opcode" ; let inv_opcode=$inv_opcode+1 ;; 109 11) echo " aborted command" ; let aborted_command=$aborted_command+1 ;; 110 15) echo " file error with $1 " ; let file_err=$file_err+1 ;; 111 20) echo " no sense" ; let other_err=$other_err+1 ;; 112 21) echo " recovered error" ; let recovered=$recovered+1 ;; 113 33) echo " timeout" ; let timeout=$timeout+1 ;; 114 97) echo " response fails sanity" ; let sanity=$sanity+1 ;; 115 98) echo " other SCSI error" ; let other_err=$other_err+1 ;; 116 99) echo " other error" ; let other_err=$other_err+1 ;; 117 *) echo " unknown exit status for sg_inq: $res" ; let other_err=$other_err+1 ;; 118 esac 119done 120 121echo "" 122let total_bad_err=$file_err+$inv_opcode+$illeg_req+$medium+$aborted_command 123let total_bad_err+=$other_err+$recovered+$sanity+$syntax+$timeout 124 125let total_allow_err=$not_ready+$unit_attention 126 127 echo "total number of bad errors: $total_bad_err " 128 129if [ $total_allow_err -gt 0 ] 130 then 131 echo "total number of allowable errors: $total_allow_err " 132fi 133 134exit $total_bad_err 135