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
#### Version: 2.2.7
#### Date: 2014-09-19
#### Date: 2014-09-20
#### Patch Number: 00
########################################################################
#### SPECIAL THANKS
@ -6102,22 +6102,21 @@ get_hard_drive_data_bsd()
A_HDD_DATA=( $( gawk -v hddUsed="$1" -F ':' '
BEGIN {
IGNORECASE=1
nr=0
size=0
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.*)$/ {
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] == "" ) {
nr++
aIds[diskId]=diskId
if ( $0 !~ /raid/) {
bSetSize="true"
}
}
aDisks[nr, "id"] = diskId
aDisks[diskId, "id"] = diskId
if ($0 ~ /[^0-9][0-9\.]+[[:space:]]*[MG]B/ && $0 !~ /MB\/s/) {
workingSize=gensub(/.*[^0-9]([0-9\.]+[[:space:]]*[MG]B).*/,"\\1",1,$0)
if (workingSize ~ /GB/ ) {
@ -6128,7 +6127,7 @@ get_hard_drive_data_bsd()
sub(/[[:space:]]*MB/,"",workingSize)
workingSize=workingSize
}
aDisks[nr, "size"] = workingSize
aDisks[diskId, "size"] = workingSize
if ( bSetSize == "true" ) {
if ( workingSize != "" ){
size=size+workingSize
@ -6138,21 +6137,23 @@ get_hard_drive_data_bsd()
}
if ( $NF ~ /<.*>/ ){
gsub(/.*<|>.*/,"",$NF)
aDisks[nr, "model"] = $NF
aDisks[diskId, "model"] = $NF
}
if ( $NF ~ /serial number/ ){
sub(/serial[[:space:]]+number[[:space:]]*/,"",$NF)
aDisks[nr, "serial"] = $NF
aDisks[diskId, "serial"] = $NF
}
}
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
# this is re openbsd raid, which uses sd0 for raid array, even though sd is for scsi
if ( aDisks[i, "model"] !~ /raid/ ) {
workingSize = aDisks[i, "size"]/1000
if ( aDisks[aIds[key], "model"] !~ /raid/ ) {
workingSize = aDisks[aIds[key], "size"]/1000
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
@ -7427,44 +7428,44 @@ get_optical_drive_data_bsd()
A_OPTICAL_DRIVE_DATA=( $( gawk -F ':' '
BEGIN {
IGNORECASE=1
nr=0
}
# sde,3.9GB,STORE_N_GO,USB,C200431546D3CF49-0:0,0
# sdd,250.1GB,ST3250824AS,,9ND08GKX,45
$1 ~ /^(cd|dvd)[0-9]+/ {
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] == "" ) {
nr++
aIds[diskId]=diskId
}
aDisks[nr, "id"] = diskId
aDisks[diskId, "id"] = diskId
if ( $NF ~ /<.*>/ ){
gsub(/.*<|>.*/,"",$NF)
rev_number=gensub(/.*[^0-9\.]([0-9\.]+)$/,"\\1",1,$NF)
if (rev_number ~ /^[0-9\.]+$/) {
aDisks[nr, "rev"] = rev_number
aDisks[diskId, "rev"] = rev_number
}
model=gensub(/(.*[^0-9\.])[0-9\.]+$/,"\\1",1,$NF)
sub(/[[:space:]]+$/,"",model)
aDisks[nr, "model"] = model
aDisks[diskId, "model"] = model
}
if ( $NF ~ /serial number/ ){
sub(/serial[[:space:]]+number[[:space:]]*/,"",$NF)
aDisks[nr, "serial"] = $NF
aDisks[diskId, "serial"] = $NF
}
if ( $NF ~ /[GM]B\/s/ ){
speed=gensub(/^([0-9\.]+[[:space:]]*[GM]B\/s).*/,"\\1",1,$NF)
sub(/\.[0-9]+/,"",speed)
if ( speed ~ /^[0-9]+/ ) {
aDisks[nr, "speed"] = speed
aDisks[diskId, "speed"] = speed
}
}
}
# "$link,dev-readlinks,$vendor,$model,$rev_number,$proc_info_string,$state"
# $proc_info_string: print speed "," multisession "," mcn "," audio "," cdr "," cdrw "," dvd "," dvdr "," dvdram
END {
for (i=1;i<=nr;i++) {
print aDisks[i, "id"] ",,," aDisks[i, "model"] "," aDisks[i, "rev"] "," aDisks[i, "speed"] ",,,,,,,,"
for ( key in aIds ) {
print aDisks[aIds[key], "id"] ",,," aDisks[aIds[key], "model"] "," aDisks[aIds[key], "rev"] "," aDisks[aIds[key], "speed"] ",,,,,,,,"
}
}' <<< "$Dmesg_Boot_Data" ) )
IFS="$ORIGINAL_IFS"