branch one, second test to handle dual port infiniband device for networking

This commit is contained in:
inxi-svn 2014-07-22 18:20:49 +00:00
parent 8e8c78d8ef
commit 8463de14ab

44
inxi
View file

@ -2,8 +2,8 @@
########################################################################
#### Script Name: inxi
#### Version: 2.1.28
#### Date: 2014-07-21
#### Patch Number: 01-b1
#### Date: 2014-07-22
#### Patch Number: 02-b1
########################################################################
#### SPECIAL THANKS
########################################################################
@ -6414,8 +6414,8 @@ get_network_advanced_data()
{
eval $LOGFS
local a_network_adv_working='' if_path='' working_path='' working_uevent_path='' dir_path=''
local if_id='' speed='' duplex='' mac_id='' oper_state='' chip_id='' b_infiniband='false'
local usb_data='' usb_vendor='' usb_product='' product_path='' driver_test=''
local if_id='' speed='' duplex='' mac_id='' oper_state='' chip_id='' b_path_made='true'
local usb_data='' usb_vendor='' usb_product='' product_path='' driver_test='' array_counter=0
for (( i=0; i < ${#A_NETWORK_DATA[@]}; i++ ))
do
@ -6447,15 +6447,18 @@ get_network_advanced_data()
# now we want the real one, that xiin also displays, without symbolic links.
if [[ -n $working_path && -e $working_path ]];then
working_path=$( readlink -f $working_path 2>/dev/null )
# first look for infiniband, don't run this check if it's infiniband
else
working_path=$( find -P /sys/ -type d -name "*:${a_network_adv_working[4]}" 2>/dev/null )
# just on off chance we get two returns, just one one
working_path=${working_path%% *}
fi
# sometimes there is another directory between the path and /net
if [[ ! -e $working_path/net ]];then
if [[ -n $working_path && ! -e $working_path/net ]];then
# using find here, probably will need to also use it in usb part since the grep
# method seems to not be working now. Slice off the rest, which leaves the basic path
working_path=$( find $working_path/*/net/*/uevent 2>/dev/null | \
sed 's|/net.*||' )
fi
fi
# working_path=$( ls /sys/devices/pci*/*/0000:${a_network_adv_working[4]}/net/*/uevent )
else
# now we'll use the actual vendor:product string instead
@ -6501,14 +6504,11 @@ get_network_advanced_data()
# the short path, minus the last longer numeric directory name, ie:
# from debian squeeze 2.6.32-5-686:
# /sys/devices/pci0000:00/0000:00:0b.1/usb1/1-1/net/wlan0/address
if [[ -e $working_path/net ]];then
# in cases like infiniband dual port devices, there can be two ids, like ib0 ib1,
# with line break in output
if_path=$( ls $working_path/net 2>/dev/null )
if_id=$if_path
# hack for now, for infiniband can have more than one id, so we'll only use the first one
# until I figure out a way to get the whole thing to recognize all the ids
if_path=${if_path%% *}
working_path=$working_path/net/$if_path
b_path_made='false'
# this is the normal usb detection if the first one didn't work
elif [[ -n $usb_data && -e $working_uevent_path/net ]];then
if_path=$( ls $working_uevent_path/net 2>/dev/null )
@ -6521,8 +6521,16 @@ get_network_advanced_data()
working_path=$working_path/$if_path
fi
log_function_data "POST: working_path: $working_path\nif_path: $if_path - if_id: $if_id"
## note: in cases of dual ports with different ids, this loop will create extra array items
if [[ -n $if_path ]];then
for if_item in $if_path
do
# strip out trailing spaces
if_item=${if_item%% }
if [[ $b_path_made == 'false' ]];then
working_path=$working_path/net/$if_item
if_id=$if_item
fi
if [[ -r $working_path/speed ]];then
speed=$( cat $working_path/speed 2>/dev/null )
fi
@ -6535,12 +6543,14 @@ get_network_advanced_data()
if [[ -r $working_path/operstate ]];then
oper_state=$( cat $working_path/operstate 2>/dev/null )
fi
fi
if [[ -n ${a_network_adv_working[10]} ]];then
chip_id=${a_network_adv_working[10]}
fi
A_NETWORK_DATA[i]=${a_network_adv_working[0]}","${a_network_adv_working[1]}","${a_network_adv_working[2]}","${a_network_adv_working[3]}","${a_network_adv_working[4]}","$if_id","$oper_state","$speed","$duplex","$mac_id","$chip_id
# now we create one array index per id found, note that one pcibusid device can have > 1 id
A_NETWORK_DATA[array_counter]=${a_network_adv_working[0]}","${a_network_adv_working[1]}","${a_network_adv_working[2]}","${a_network_adv_working[3]}","${a_network_adv_working[4]}","$if_id","$oper_state","$speed","$duplex","$mac_id","$chip_id
((array_counter++))
done
fi
IFS="$ORIGINAL_IFS"
done