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