Fixed testing bug for advanced sdx name detection

This commit is contained in:
inxi-svn 2008-11-09 07:07:48 +00:00
parent d63f5d8d39
commit f96ab2c884

78
inxi
View file

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
######################################################################## ########################################################################
#### Script Name: inxi #### Script Name: inxi
#### version: 0.4.18 #### version: 0.4.19
#### Date: November 8 2008 #### Date: November 8 2008
######################################################################## ########################################################################
#### inxi is a fork of infobash, the original bash sys info script by locsmif #### inxi is a fork of infobash, the original bash sys info script by locsmif
@ -1244,49 +1244,47 @@ get_hard_drive_data_advanced()
## then handle libata names ## then handle libata names
# first get the ata device names, put them into an array # first get the ata device names, put them into an array
if [[ -e /proc/scsi/sg/device_strs ]]; then IFS=$'\n'
IFS=$'\n' if [[ -e /proc/scsi/sg/device_strs && $B_TESTING_FLAG == 'true' ]]; then
## prints out hdd device if field one is ATA type (sata compatibility mode) or prints out scsi device ## prints out hdd device if field one is ATA type (sata compatibility mode) or prints out scsi device
# note: pmap handles usb mounted devices, which have a null first field # note: pmap handles usb mounted devices, which have a null first field
if [[ $B_TESTING_FLAG == 'true' ]];then a_temp_scsi=( $( gawk -F'\t' '
a_temp_scsi=( $( gawk -F'\t' ' BEGIN { IGNORECASE=1 }
BEGIN { IGNORECASE=1 } # if the item starts with empty, void field, assume it is flash drive
# if the item starts with empty, void field, assume it is flash drive /^ata|^scsi|^ |^corsair|^wdc|^kingston/ {
/^ata|^scsi|^ |^corsair|^wdc|^kingston/ { gsub(/,/, " ", $(NF -1) )
gsub(/,/, " ", $(NF -1) ) gsub(/^ +| +$/, "", $(NF -1) )
gsub(/^ +| +$/, "", $(NF -1) ) print $(NF -1)
print $(NF -1) }
} ' /proc/scsi/sg/device_strs ) )
' /proc/scsi/sg/device_strs ) ) elif [[ -e /proc/scsi/scsi ]]; then
else a_temp_scsi=( $( gawk '
a_temp_scsi=( $( gawk ' BEGIN { IGNORECASE=1 }
BEGIN { IGNORECASE=1 } /host/ {
/host/ { getline a[$0]
getline a[$0] getline b[$0]
getline b[$0] }
} END {
END { for (i in a) {
for (i in a) { if (b[i] ~ / *type: *direct-access.*/) {
if (b[i] ~ / *type: *direct-access.*/) { #c=gensub(/^ *vendor: (.+) +model: (.+) +rev: (.+)$/,"\\1 \\2 \\3","g",a[i])
#c=gensub(/^ *vendor: (.+) +model: (.+) +rev: (.+)$/,"\\1 \\2 \\3","g",a[i]) #c=gensub( /^ *vendor: (.+) +model: (.+) +rev:.*$/,"\\1 \\2","g",a[i] )
#c=gensub( /^ *vendor: (.+) +model: (.+) +rev:.*$/,"\\1 \\2","g",a[i] ) # the vendor: string is useless, and is a bug, ATA is not a vendor for example
# the vendor: string is useless, and is a bug, ATA is not a vendor for example c=gensub( /^ *vendor: (.+) +model: (.+) +rev:.*$/, "\\2", "g", a[i] )
c=gensub( /^ *vendor: (.+) +model: (.+) +rev:.*$/, "\\2", "g", a[i] ) gsub(/,/, " ", c)
gsub(/,/, " ", c) gsub(/^ +| +$/, "", c)
gsub(/^ +| +$/, "", c) gsub(/ [ \t]+/, " ", c)
gsub(/ [ \t]+/, " ", c) #print a[i]
#print a[i] # we actually want this data, so leaving this off for now
# we actually want this data, so leaving this off for now # if (c ~ /\<flash\>|\<pendrive\>|memory stick|memory card/) {
# if (c ~ /\<flash\>|\<pendrive\>|memory stick|memory card/) { # continue
# continue # }
# } print c
print c
}
} }
}' /proc/scsi/scsi) ) }
fi }' /proc/scsi/scsi) )
IFS="$ORIGINAL_IFS"
fi fi
IFS="$ORIGINAL_IFS"
## then we'll loop through that array looking for matches. Note, with identical drives this will fail, sigh.. ## then we'll loop through that array looking for matches. Note, with identical drives this will fail, sigh..
## for future use, that should be tightened up, but for now it's fine. ## for future use, that should be tightened up, but for now it's fine.