diff --git a/src/image_mad/remotes/fs/fsrc b/src/image_mad/remotes/fs/fsrc index 423f27e26b..0f49049d1f 100644 --- a/src/image_mad/remotes/fs/fsrc +++ b/src/image_mad/remotes/fs/fsrc @@ -41,14 +41,19 @@ echo "$IMAGE_REPOSITORY_PATH/`echo $CANONICAL_MD5 | cut -d ' ' -f1`" } function fs_du { + SIZE="" -SIZE=`$DU -m $1 2>/dev/null` + QEMU_IMG=`command -v qemu-img` -if [ $? -ne 0 ]; then - SIZE=0 -else - SIZE=`echo $SIZE | cut -f1 -d' '` -fi + if [ "$?" = "0" ]; then + SIZE=$($QEMU_IMG info $1|awk '/^virtual size:/{print substr($4,2)}') + fi -echo "$SIZE" + if [ -z "$SIZE" ]; then + SIZE=$(stat -c %s $1) + fi + + SIZE=$(($SIZE/1048576)) + + echo "$SIZE" }