From cafa625166c2b11ee2818246a622b39511873863 Mon Sep 17 00:00:00 2001 From: inxi-svn Date: Thu, 24 Apr 2014 18:56:23 +0000 Subject: [PATCH] New version, tarball. This fixes one small oversight, placing USB in front of ID-[x] of disk drive lists. Was showing USB ID-1: /dev/sde now shows: ID-1: USB /dev/sde that is more intuitive and keeps the columns in alignment more or less, easier to read. Second, fixes a bug with some file systems / usb drives where they do not use usb- in the /dev/disk/by-id line but only wwn- https://access.redhat.com/site/documentation/en -US/Red_Hat_Enterprise_Linux/5/html/Online_Storage_Reconfiguration_Guide/persistent_naming.html explains it somewhat. the fix is adding a second if null test of the device /dev/sdx in by-path, that seems to fix the issue. by-path does have the usb- item, though it does not have the name so it's not as reliable in absolute terms, but it's fine as a second step fallback option. --- inxi | 18 +++++++++++++----- inxi.changelog | 26 ++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/inxi b/inxi index ace75e2..5caace4 100755 --- a/inxi +++ b/inxi @@ -1,8 +1,8 @@ #!/usr/bin/env bash ######################################################################## #### Script Name: inxi -#### Version: 2.1.20 -#### Date: 2014-04-08 +#### Version: 2.1.21 +#### Date: 2014-04-24 #### Patch Number: 00 ######################################################################## #### SPECIAL THANKS @@ -1763,6 +1763,8 @@ debug_data_collector() ls -l /dev/disk/by-id &> $debug_data_dir/dev-disk-id-data.txt ls -l /dev/disk/by-label &> $debug_data_dir/dev-disk-label-data.txt ls -l /dev/disk/by-uuid &> $debug_data_dir/dev-disk-uuid-data.txt + # http://comments.gmane.org/gmane.linux.file-systems.zfs.user/2032 + ls -l /dev/disk/by-wwn &> $debug_data_dir/dev-disk-wwn-data.txt ls -l /dev/disk/by-path &> $debug_data_dir/dev-disk-path-data.txt ls -l /dev/mapper &> $debug_data_dir/dev-disk-mapper-data.txt readlink /dev/root &> $debug_data_dir/dev-root.txt @@ -5544,7 +5546,7 @@ get_hard_drive_data_advanced() { eval $LOGFS local a_temp_working='' a_temp_scsi='' temp_holder='' temp_name='' i='' j='' - local sd_ls_by_id='' ls_disk_by_id='' usb_exists='' a_temp='' + local sd_ls_by_id='' ls_disk_by_id='' ls_disk_by_path='' usb_exists='' a_temp='' ## check for all ide type drives, non libata, only do it if hdx is in array ## this is now being updated for new /sys type paths, this may handle that ok too @@ -5614,6 +5616,7 @@ get_hard_drive_data_advanced() # first pack the main ls variable so we don't have to keep using ls /dev... # not all systems have /dev/disk/by-id ls_disk_by_id="$( ls -l /dev/disk/by-id 2>/dev/null )" + ls_disk_by_path="$( ls -l /dev/disk/by-path 2>/dev/null )" for (( i=0; i < ${#A_HDD_DATA[@]} - 1; i++ )) do if [[ -n $( grep -E '^sd[a-z]' <<< ${A_HDD_DATA[$i]} ) ]];then @@ -5648,8 +5651,13 @@ get_hard_drive_data_advanced() if [[ -z $temp_name ]];then temp_name="Name n/a" + # maybe remove this from the conditional, detection of usb may not depend on the name else usb_exists=$( grep -Em1 "usb-.*$temp_name.*${a_temp_working[0]}$" <<< "$ls_disk_by_id" ) + # note: sometimes with wwn- numbering usb does not appear in by-id but it does in by-path + if [[ -z $usb_exists ]];then + usb_exists=$( grep -Em1 "usb-.*${a_temp_working[0]}$" <<< "$ls_disk_by_path" ) + fi if [[ -n $usb_exists ]];then a_temp_working[3]='USB' fi @@ -9919,7 +9927,7 @@ print_hard_disk_data() fi hdd_serial=" ${C1}serial$SEP3${C2} $hdd_serial" fi - dev_data="${C1}ID-$((i+1))$SEP3${C2} /dev/${a_hdd_working[0]} " + dev_data="/dev/${a_hdd_working[0]} " fi if [[ -n ${a_hdd_working[2]} ]];then hdd_name_temp=${a_hdd_working[2]} @@ -9928,7 +9936,7 @@ print_hard_disk_data() fi # echo "loop: $i" hdd_name="${C1}model$SEP3${C2} $hdd_name_temp" - hdd_string="$usb_data$dev_data$hdd_name$size_data$hdd_serial$hdd_temp_data" + hdd_string="${C1}ID-$((i+1))$SEP3${C2} $usb_data$dev_data$hdd_name$size_data$hdd_serial$hdd_temp_data" part_1_data="$hdd_model$hdd_string " if [[ $i -eq 0 ]];then diff --git a/inxi.changelog b/inxi.changelog index a464559..870eb49 100755 --- a/inxi.changelog +++ b/inxi.changelog @@ -1,3 +1,29 @@ +===================================================================================== +Version: 2.1.21 +Patch Version: 00 +Script Date: 2014-04-24 +----------------------------------- +Changes: +----------------------------------- +New version, tarball. This fixes one small oversight, placing USB in front of ID-[x] +of disk drive lists. Was showing USB ID-1: /dev/sde now shows: ID-1: USB /dev/sde +that is more intuitive and keeps the columns in alignment more or less, easier +to read. + +Second, fixes a bug with some file systems / usb drives +where they do not use usb- in the /dev/disk/by-id line but only wwn- +https://access.redhat.com/site/documentation/en +-US/Red_Hat_Enterprise_Linux/5/html/Online_Storage_Reconfiguration_Guide/persistent_naming.html +explains it somewhat. + +the fix is adding a second if null test of the device /dev/sdx in by-path, that seems +to fix the issue. by-path does have the usb- item, though it does not have the name +so it's not as reliable in absolute terms, but it's fine as a second step fallback +option. + +----------------------------------- +-- Harald Hope - Thu, 24 Apr 2014 11:47:08 -0700 + ===================================================================================== Version: 2.1.20 Patch Version: 00