fixed bug with space in user partition names in hard disk size

This commit is contained in:
inxi-svn 2009-01-09 02:24:25 +00:00
parent 7006e1a062
commit 1b19321e2c

43
inxi
View file

@ -1,8 +1,8 @@
#!/bin/bash #!/bin/bash
######################################################################## ########################################################################
#### Script Name: inxi #### Script Name: inxi
#### version: 0.9.3 #### version: 0.9.4
#### Date: January 6, 2009 #### Date: January 8, 2009
######################################################################## ########################################################################
#### SPECIAL THANKS #### SPECIAL THANKS
######################################################################## ########################################################################
@ -1862,25 +1862,28 @@ get_hdd_data_basic()
local hdd_used='' local hdd_used=''
hdd_used=$( df | gawk ' hdd_used=$( df | gawk '
p { /^\/dev\/(mapper\/|[hs]d[a-z][0-9]+)/ {
if (/^\/dev\/(mapper\/|[hs]d[a-z][0-9]+)/) { # this handles the case where the first item is too long
if (NF == 1) { # and makes df wrap output to next line, so here we advance
getline # it to the next line for that single case
if (NF == 5) { if ( NF == 1 ) {
c += $2 getline
} }
else { # if the first item caused a wrap, use one less than standard
next if ( $4 ~ /.*\%/ ) {
} used += $2
} }
else if (NF == 6) { # otherwise use standard
c += $3 else if ( $5 ~ /.*\%/ ) {
} used += $3
}
# and if this is not detected, give up, we need user data to debug
else {
next
} }
} }
/^Filesystem/ { p++ }
END { END {
print c print used
}' ) }' )
if [[ -z $hdd_used ]];then if [[ -z $hdd_used ]];then
@ -1903,7 +1906,9 @@ get_hdd_data_basic()
# See http://lanana.org/docs/device-list/devices-2.6+.txt for major numbers used below # See http://lanana.org/docs/device-list/devices-2.6+.txt for major numbers used below
# $1 ~ /^(3|22|33|8)$/ && $2 % 16 == 0 {size+=$3} # $1 ~ /^(3|22|33|8)$/ && $2 % 16 == 0 {size+=$3}
# special case from this data: 8 0 156290904 sda # special case from this data: 8 0 156290904 sda
$1 ~ /^(3|22|33|8)$/ && $NF ~ /[hs]d[a-z]$/ && ( $2 % 16 == 0 || $2 % 16 == 8 ) {size+=$3} $1 ~ /^(3|22|33|8)$/ && $NF ~ /[hs]d[a-z]$/ && ( $2 % 16 == 0 || $2 % 16 == 8 ) {
size += $3
}
END { END {
size = size*1024/1000**3 # calculate size in GB size size = size*1024/1000**3 # calculate size in GB size
workingUsed = hddused*1024/1000**3 # calculate workingUsed in GB used workingUsed = hddused*1024/1000**3 # calculate workingUsed in GB used