From bb63c1077805f6de5d9377a1660bde82a79a827c Mon Sep 17 00:00:00 2001 From: =?utf8?q?G=C3=A9za=20G=C3=A9mes?= Date: Fri, 24 Mar 2017 19:59:35 +0100 Subject: [PATCH] Fix lopartsetup for util-linux >= 2.27.1 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit fdisk from util-linux >= 2.27.1 returns units in a slightly different structure than earlier versions Signed-off-by: Géza Gémes Signed-off-by: Stefano Stabellini Reviewed-by: Stefano Stabellini --- scripts/lopartsetup | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/scripts/lopartsetup b/scripts/lopartsetup index 04ce3cc..da28b6e 100755 --- a/scripts/lopartsetup +++ b/scripts/lopartsetup @@ -53,7 +53,22 @@ then exit 1 fi -unit="`fdisk -lu $filename 2>/dev/null | grep -e "^Units = " | cut -d " " -f 9`" +unitstring="" +column=0 +if [ `fdisk -lu $filename 2>/dev/null | grep -e "^Units = " | wc -l` -eq 1 ] +then + unitstring="^Units = " + column=9 +else if [ `fdisk -lu $filename 2>/dev/null | grep -e "^Units:" | wc -l` -eq 1 ] +then + unitstring="^Units:" + column=8 +else + exit 1 +fi + +unit="`fdisk -lu $filename 2>/dev/null | grep -e "$unitstring" | cut -d " " -f $column`" + index=0 for i in "`fdisk -lu $filename 2>/dev/null | grep -e "^$filename"`" do -- 2.39.5