From 5eea74f248a7bb1847857bca4a818f15aa72eedc Mon Sep 17 00:00:00 2001 From: Josh Paetzel Date: Sat, 8 Jan 2011 20:25:00 +0000 Subject: [PATCH] More elegant way to detect MBR vs. GPT Submitted by: nwhitehorn Approved by: imp --- usr.sbin/pc-sysinstall/backend-query/disk-part.sh | 10 ++-------- usr.sbin/pc-sysinstall/backend/functions-disk.sh | 7 +------ 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/usr.sbin/pc-sysinstall/backend-query/disk-part.sh b/usr.sbin/pc-sysinstall/backend-query/disk-part.sh index 900cbca8c69..e5e73556597 100755 --- a/usr.sbin/pc-sysinstall/backend-query/disk-part.sh +++ b/usr.sbin/pc-sysinstall/backend-query/disk-part.sh @@ -60,14 +60,8 @@ if [ "$?" != "0" ] ; then fi # Display if this is GPT or MBR formatted -gpart show ${1} | grep "GPT" >/dev/null 2>/dev/null -if [ "$?" = "0" ] ; then - echo "${1}-format: GPT" - TYPE="GPT" -else - echo "${1}-format: MBR" - TYPE="MBR" -fi +TYPE=`gpart show ${1} | awk '/^=>/ { printf("%s",$5); }'` +echo "${1}-format: $TYPE" # Set some search flags PART="0" diff --git a/usr.sbin/pc-sysinstall/backend/functions-disk.sh b/usr.sbin/pc-sysinstall/backend/functions-disk.sh index 0b145918e2f..6ef1c84af89 100755 --- a/usr.sbin/pc-sysinstall/backend/functions-disk.sh +++ b/usr.sbin/pc-sysinstall/backend/functions-disk.sh @@ -180,12 +180,7 @@ get_disk_partitions() return fi - gpart show ${1} | grep "MBR" >/dev/null 2>/dev/null - if [ "$?" = "0" ] ; then - type="MBR" - else - type="GPT" - fi + type=`gpart show ${1} | awk '/^=>/ { printf("%s",$5); }'` SLICES="`gpart show ${1} | grep -v ${1} | grep -v ' free ' |tr -s '\t' ' ' | cut -d ' ' -f 4 | sed '/^$/d'`" for i in ${SLICES}