uvol: fix regression in handling fractional megabytes free

Also, fix off-by-one issue when computing free size.

Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
This commit is contained in:
Philip Prindeville 2023-01-18 15:33:30 -07:00 committed by Daniel Golle
parent 36a45c4ce7
commit b1edbe349f
2 changed files with 5 additions and 14 deletions

View file

@ -1,8 +1,8 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=uvol PKG_NAME:=uvol
PKG_VERSION:=0.8 PKG_VERSION:=0.9
PKG_RELEASE:=$(AUTORELEASE) PKG_RELEASE:=1
PKG_MAINTAINER:=Daniel Golle <daniel@makrotopia.org> PKG_MAINTAINER:=Daniel Golle <daniel@makrotopia.org>
PKG_LICENSE:=GPL-2.0-or-later PKG_LICENSE:=GPL-2.0-or-later

View file

@ -56,23 +56,14 @@ part_fixup() {
get_free_area() { get_free_area() {
local found= local found=
sfdisk -q -F "$1" 2>/dev/null | while read -r start end sectors size; do sfdisk --bytes -q -F "$1" 2>/dev/null | while read -r start end sectors size; do
case $start in case $start in
*"Unpartitioned"* | *"Units:"* | *"Sector"* | *"Start"* ) *"Unpartitioned"* | *"Units:"* | *"Sector"* | *"Start"* )
continue continue
;; ;;
[0-9]*) [0-9]*)
case "$size" in [ $size" -lt $((100 * 1024 * 1024)) ] && continue
*"k" | *"b") [ "$found" ] || echo "start=$start, size=$sectors"
continue
;;
*"M")
[ "${size%%.*M}" -lt 100 ] && continue
;;
*"G" | *"T")
;;
esac
[ "$found" ] || echo "start=$start, size=$((end - start))"
found=1 found=1
;; ;;
esac esac