new tarball, no version change. This fixes another possible glitch with bsd handling of -D/-d data, because

/var/run/dmesg.boot can contain repeated data when not recreated at boot, you can have the same disks discovered
two times, so I made the gawk arrays use the disk id as part of their array key.
This commit is contained in:
inxi-svn 2014-09-20 18:36:36 +00:00
parent 36ea961bdb
commit 23cbb0455f

45
inxi
View file

@ -4,7 +4,7 @@
######################################################################## ########################################################################
#### Script Name: inxi #### Script Name: inxi
#### Version: 2.2.7 #### Version: 2.2.7
#### Date: 2014-09-19 #### Date: 2014-09-20
#### Patch Number: 00 #### Patch Number: 00
######################################################################## ########################################################################
#### SPECIAL THANKS #### SPECIAL THANKS
@ -6102,22 +6102,21 @@ get_hard_drive_data_bsd()
A_HDD_DATA=( $( gawk -v hddUsed="$1" -F ':' ' A_HDD_DATA=( $( gawk -v hddUsed="$1" -F ':' '
BEGIN { BEGIN {
IGNORECASE=1 IGNORECASE=1
nr=0
size=0 size=0
bSetSize="false" bSetSize="false"
} }
# sde,3.9GB,STORE_N_GO,USB,C200431546D3CF49-0:0,0
# sdd,250.1GB,ST3250824AS,,9ND08GKX,45
$1 ~ /^(ad|ada|sd|wd)[0-9]+(|[[:space:]]at.*)$/ { $1 ~ /^(ad|ada|sd|wd)[0-9]+(|[[:space:]]at.*)$/ {
diskId=gensub(/^((ad|ada|sd|wd)[0-9]+)[^0-9].*/,"\\1",1,$1) diskId=gensub(/^((ad|ada|sd|wd)[0-9]+)[^0-9].*/,"\\1",1,$1)
# note: /var/run/dmesg.boot may repeat items since it is not created
# fresh every boot, this way, only the last items will be used per disk id
if (aIds[diskId] == "" ) { if (aIds[diskId] == "" ) {
nr++
aIds[diskId]=diskId aIds[diskId]=diskId
if ( $0 !~ /raid/) { if ( $0 !~ /raid/) {
bSetSize="true" bSetSize="true"
} }
} }
aDisks[nr, "id"] = diskId aDisks[diskId, "id"] = diskId
if ($0 ~ /[^0-9][0-9\.]+[[:space:]]*[MG]B/ && $0 !~ /MB\/s/) { if ($0 ~ /[^0-9][0-9\.]+[[:space:]]*[MG]B/ && $0 !~ /MB\/s/) {
workingSize=gensub(/.*[^0-9]([0-9\.]+[[:space:]]*[MG]B).*/,"\\1",1,$0) workingSize=gensub(/.*[^0-9]([0-9\.]+[[:space:]]*[MG]B).*/,"\\1",1,$0)
if (workingSize ~ /GB/ ) { if (workingSize ~ /GB/ ) {
@ -6128,7 +6127,7 @@ get_hard_drive_data_bsd()
sub(/[[:space:]]*MB/,"",workingSize) sub(/[[:space:]]*MB/,"",workingSize)
workingSize=workingSize workingSize=workingSize
} }
aDisks[nr, "size"] = workingSize aDisks[diskId, "size"] = workingSize
if ( bSetSize == "true" ) { if ( bSetSize == "true" ) {
if ( workingSize != "" ){ if ( workingSize != "" ){
size=size+workingSize size=size+workingSize
@ -6138,21 +6137,23 @@ get_hard_drive_data_bsd()
} }
if ( $NF ~ /<.*>/ ){ if ( $NF ~ /<.*>/ ){
gsub(/.*<|>.*/,"",$NF) gsub(/.*<|>.*/,"",$NF)
aDisks[nr, "model"] = $NF aDisks[diskId, "model"] = $NF
} }
if ( $NF ~ /serial number/ ){ if ( $NF ~ /serial number/ ){
sub(/serial[[:space:]]+number[[:space:]]*/,"",$NF) sub(/serial[[:space:]]+number[[:space:]]*/,"",$NF)
aDisks[nr, "serial"] = $NF aDisks[diskId, "serial"] = $NF
} }
} }
END { END {
for (i=1;i<=nr;i++) { # sde,3.9GB,STORE_N_GO,USB,C200431546D3CF49-0:0,0
# sdd,250.1GB,ST3250824AS,,9ND08GKX,45
for ( key in aIds ) {
# we are not adding to size above for raid, and we do not print it for raid # we are not adding to size above for raid, and we do not print it for raid
# this is re openbsd raid, which uses sd0 for raid array, even though sd is for scsi # this is re openbsd raid, which uses sd0 for raid array, even though sd is for scsi
if ( aDisks[i, "model"] !~ /raid/ ) { if ( aDisks[aIds[key], "model"] !~ /raid/ ) {
workingSize = aDisks[i, "size"]/1000 workingSize = aDisks[aIds[key], "size"]/1000
workingSize = sprintf( "%.1fGB", workingSize ) workingSize = sprintf( "%.1fGB", workingSize )
print aDisks[i, "id"] "," workingSize "," aDisks[i, "model"] "," "," aDisks[i, "serial"] "," print aDisks[aIds[key], "id"] "," workingSize "," aDisks[aIds[key], "model"] "," "," aDisks[aIds[key], "serial"] ","
} }
} }
size = size/1000 # calculate size in GB size size = size/1000 # calculate size in GB size
@ -7427,44 +7428,44 @@ get_optical_drive_data_bsd()
A_OPTICAL_DRIVE_DATA=( $( gawk -F ':' ' A_OPTICAL_DRIVE_DATA=( $( gawk -F ':' '
BEGIN { BEGIN {
IGNORECASE=1 IGNORECASE=1
nr=0
} }
# sde,3.9GB,STORE_N_GO,USB,C200431546D3CF49-0:0,0 # sde,3.9GB,STORE_N_GO,USB,C200431546D3CF49-0:0,0
# sdd,250.1GB,ST3250824AS,,9ND08GKX,45 # sdd,250.1GB,ST3250824AS,,9ND08GKX,45
$1 ~ /^(cd|dvd)[0-9]+/ { $1 ~ /^(cd|dvd)[0-9]+/ {
diskId=gensub(/^((cd|dvd)[0-9]+)[^0-9].*/,"\\1",1,$1) diskId=gensub(/^((cd|dvd)[0-9]+)[^0-9].*/,"\\1",1,$1)
# note: /var/run/dmesg.boot may repeat items since it is not created
# fresh every boot, this way, only the last items will be used per disk id
if (aIds[diskId] == "" ) { if (aIds[diskId] == "" ) {
nr++
aIds[diskId]=diskId aIds[diskId]=diskId
} }
aDisks[nr, "id"] = diskId aDisks[diskId, "id"] = diskId
if ( $NF ~ /<.*>/ ){ if ( $NF ~ /<.*>/ ){
gsub(/.*<|>.*/,"",$NF) gsub(/.*<|>.*/,"",$NF)
rev_number=gensub(/.*[^0-9\.]([0-9\.]+)$/,"\\1",1,$NF) rev_number=gensub(/.*[^0-9\.]([0-9\.]+)$/,"\\1",1,$NF)
if (rev_number ~ /^[0-9\.]+$/) { if (rev_number ~ /^[0-9\.]+$/) {
aDisks[nr, "rev"] = rev_number aDisks[diskId, "rev"] = rev_number
} }
model=gensub(/(.*[^0-9\.])[0-9\.]+$/,"\\1",1,$NF) model=gensub(/(.*[^0-9\.])[0-9\.]+$/,"\\1",1,$NF)
sub(/[[:space:]]+$/,"",model) sub(/[[:space:]]+$/,"",model)
aDisks[nr, "model"] = model aDisks[diskId, "model"] = model
} }
if ( $NF ~ /serial number/ ){ if ( $NF ~ /serial number/ ){
sub(/serial[[:space:]]+number[[:space:]]*/,"",$NF) sub(/serial[[:space:]]+number[[:space:]]*/,"",$NF)
aDisks[nr, "serial"] = $NF aDisks[diskId, "serial"] = $NF
} }
if ( $NF ~ /[GM]B\/s/ ){ if ( $NF ~ /[GM]B\/s/ ){
speed=gensub(/^([0-9\.]+[[:space:]]*[GM]B\/s).*/,"\\1",1,$NF) speed=gensub(/^([0-9\.]+[[:space:]]*[GM]B\/s).*/,"\\1",1,$NF)
sub(/\.[0-9]+/,"",speed) sub(/\.[0-9]+/,"",speed)
if ( speed ~ /^[0-9]+/ ) { if ( speed ~ /^[0-9]+/ ) {
aDisks[nr, "speed"] = speed aDisks[diskId, "speed"] = speed
} }
} }
} }
# "$link,dev-readlinks,$vendor,$model,$rev_number,$proc_info_string,$state" # "$link,dev-readlinks,$vendor,$model,$rev_number,$proc_info_string,$state"
# $proc_info_string: print speed "," multisession "," mcn "," audio "," cdr "," cdrw "," dvd "," dvdr "," dvdram # $proc_info_string: print speed "," multisession "," mcn "," audio "," cdr "," cdrw "," dvd "," dvdr "," dvdram
END { END {
for (i=1;i<=nr;i++) { for ( key in aIds ) {
print aDisks[i, "id"] ",,," aDisks[i, "model"] "," aDisks[i, "rev"] "," aDisks[i, "speed"] ",,,,,,,," print aDisks[aIds[key], "id"] ",,," aDisks[aIds[key], "model"] "," aDisks[aIds[key], "rev"] "," aDisks[aIds[key], "speed"] ",,,,,,,,"
} }
}' <<< "$Dmesg_Boot_Data" ) ) }' <<< "$Dmesg_Boot_Data" ) )
IFS="$ORIGINAL_IFS" IFS="$ORIGINAL_IFS"