[PC-BSD Commits] r6526 - pcbsd/trunk/pc-sysinstall/backend

svn at pcbsd.org svn at pcbsd.org
Wed Apr 7 10:22:20 PDT 2010


Author: kris
Date: 2010-04-07 10:22:19 -0700 (Wed, 07 Apr 2010)
New Revision: 6526

Modified:
   pcbsd/trunk/pc-sysinstall/backend/functions-disk.sh
Log:

Updated some functions in the disk-backend



Modified: pcbsd/trunk/pc-sysinstall/backend/functions-disk.sh
===================================================================
--- pcbsd/trunk/pc-sysinstall/backend/functions-disk.sh	2010-04-07 16:55:20 UTC (rev 6525)
+++ pcbsd/trunk/pc-sysinstall/backend/functions-disk.sh	2010-04-07 17:22:19 UTC (rev 6526)
@@ -1,7 +1,41 @@
 #!/bin/sh
 # Functions related to disk operations using gpart
 
+# Function which returns the partitions on a target disk
+get_disk_partitions()
+{
+  gpart show ${1} >/dev/null 2>/dev/null
+  if [ "$?" != "0" ] ; then
+    VAL="" ; export VAL
+    return
+  fi
 
+  gpart show ${1} | grep "MBR" >/dev/null 2>/dev/null
+  if [ "$?" = "0" ] ; then
+    type="MBR"
+  else
+    type="GPT"
+  fi
+
+  SLICES="`gpart show ${1} | grep -v ${1} | grep -v ' free ' |tr -s '\t' ' ' | cut -d ' ' -f 4 | sed '/^$/d'`"
+  for i in ${SLICES}
+  do
+    case $type in
+       MBR) name="${1}s${i}" ;;
+       GPT) name="${1}p${i}";;
+       *) name="${1}s${i}";;
+    esac
+    if [ -z "${RSLICES}" ]
+    then
+      RSLICES="${name}"
+    else
+      RSLICES="${RSLICES} ${name}"
+    fi
+  done
+
+  VAL="${RSLICES}" ; export VAL
+};
+
 # Function which returns a target disks cylinders
 get_disk_cyl()
 {



More information about the Commits mailing list