summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--modules/fs/path.inc14
1 files changed, 9 insertions, 5 deletions
diff --git a/modules/fs/path.inc b/modules/fs/path.inc
index fd035b5..714578f 100644
--- a/modules/fs/path.inc
+++ b/modules/fs/path.inc
@@ -71,7 +71,7 @@ fs_path_isvolatile() {
# Returns "<free> <total>"
fs_path_space() {
[ -z "$1" ] && return 1
- local _free _total _dev _type _id _name _bs _tmp _tfree _ttotal
+ local _free _total _dev _type _id _name _bs _tmp _tused _tfree _ttotal
_type="$( fs_path_gettype "$1" )"
[ -z "$_type" ] && return 1
_free="$( df -P "$1" | awk '$6 ~ "^/" {print $4 " " $2}' )"
@@ -95,9 +95,11 @@ fs_path_space() {
case "$_type" in
snapshot)
# Field 4 is used/total in sectors of 512 byte, so divide by two for KiB
- _tmp="$( dmsetup status "$_dev" | awk '{split($4, a, "/"); print (a[2] - a[1]) / 2 " " a[2] / 2}' )"
- _tfree="${_tmp% *}"
+ _tmp="$( dmsetup status "$_dev" | awk '{split($4, a, "/"); print a[1] " " a[2]}' )"
+ _tused="${_tmp% *}"
_ttotal="${_tmp#* }"
+ _tfree=$( echo "($_ttotal - $_tused) / 2" | bc )
+ _ttotal=$( echo "$_ttotal / 2" | bc )
;;
thin)
# Determine matching pool
@@ -109,9 +111,11 @@ fs_path_space() {
_bs="$( dmsetup table "$_name" | awk '{print $6}' )"
if [ "$_bs" -gt 0 ]; then
# Field 6 is used/total (in data blocks), so transform into KiB
- _tmp="$( dmsetup status "$_name" | awk -v "bs=$_bs" '{split($6, a, "/"); print ((a[2] - a[1]) / 2) * bs " " (a[2] / 2) * bs}' )"
- _tfree="${_tmp% *}"
+ _tmp="$( dmsetup status "$_name" | awk '{split($6, a, "/"); print a[1] " " a[2]}' )"
+ _tused="${_tmp% *}"
_ttotal="${_tmp#* }"
+ _tfree=$( echo "(($_ttotal - $_tused) / 2) * $_bs" | bc )
+ _ttotal=$( echo "($_ttotal / 2) * $_bs" | bc )
fi
fi
fi