@@ -60,15 +60,21 @@ get_free_sectors()
{
case $FSTYP in
ext4)
+ cluster_size=$($DUMPE2FS_PROG $img_file 2>&1 | sed -n 's/Cluster size: *\(.*\)/\1/p')
+ if [ -n "$cluster_size" ]; then
+ blocks_per_cluster=`expr $cluster_size / $block_size`
+ else
+ blocks_per_cluster=1
+ fi
$UMOUNT_PROG $loop_mnt
$DUMPE2FS_PROG $img_file 2>&1 | grep " Free blocks" | cut -d ":" -f2- | \
tr ',' '\n' | $SED_PROG 's/^ //' | \
- $AWK_PROG -v spb=$sectors_per_block 'BEGIN{FS="-"};
+ $AWK_PROG -v spb=$sectors_per_block -v bpc=$blocks_per_cluster 'BEGIN{FS="-"};
NF {
if($2 != "") # range of blocks
- print spb * $1, spb * ($2 + 1) - 1;
+ print spb * $1, spb * ($2 + bpc) - 1;
else # just single block
- print spb * $1, spb * ($1 + 1) - 1;
+ print spb * $1, spb * ($1 + bpc) - 1;
}'
;;
xfs)