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

35
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
# it to the next line for that single case
if ( NF == 1 ) {
getline getline
if (NF == 5) {
c += $2
} }
# if the first item caused a wrap, use one less than standard
if ( $4 ~ /.*\%/ ) {
used += $2
}
# otherwise use standard
else if ( $5 ~ /.*\%/ ) {
used += $3
}
# and if this is not detected, give up, we need user data to debug
else { else {
next next
} }
} }
else if (NF == 6) {
c += $3
}
}
}
/^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