[PC-BSD Commits] r6525 - in pcbsd/trunk/pc-sysinstall: backend backend-query
svn at pcbsd.org
svn at pcbsd.org
Wed Apr 7 09:55:20 PDT 2010
Author: kris
Date: 2010-04-07 09:55:20 -0700 (Wed, 07 Apr 2010)
New Revision: 6525
Modified:
pcbsd/trunk/pc-sysinstall/backend-query/disk-info.sh
pcbsd/trunk/pc-sysinstall/backend/functions-disk.sh
Log:
Updated functions for getting heads/sectors/cyls
Modified: pcbsd/trunk/pc-sysinstall/backend/functions-disk.sh
===================================================================
--- pcbsd/trunk/pc-sysinstall/backend/functions-disk.sh 2010-04-07 16:31:49 UTC (rev 6524)
+++ pcbsd/trunk/pc-sysinstall/backend/functions-disk.sh 2010-04-07 16:55:20 UTC (rev 6525)
@@ -2,6 +2,28 @@
# Functions related to disk operations using gpart
+# Function which returns a target disks cylinders
+get_disk_cyl()
+{
+ cyl=`diskinfo -v ${1} | grep "# Cylinders" | tr -s ' ' | cut -f 2`
+ VAL="${cyl}" ; export VAL
+};
+
+# Function which returns a target disks sectors
+get_disk_sectors()
+{
+ sec=`diskinfo -v ${1} | grep "# Sectors" | tr -s ' ' | cut -f 2`
+ VAL="${sec}" ; export VAL
+};
+
+# Function which returns a target disks heads
+get_disk_heads()
+{
+ head=`diskinfo -v ${1} | grep "# Heads" | tr -s ' ' | cut -f 2`
+ VAL="${head}" ; export VAL
+};
+
+
# Function to delete all gparts before starting an install
delete_all_gpart()
{
@@ -387,13 +409,16 @@
# No slice after the new slice, lets figure out the free space remaining and use it
# Get the cyl of this disk
- cyl=`diskinfo -v ${DISK} | grep "# Cylinders" | tr -s ' ' | cut -f 2`
+ get_disk_cyl "${DISK}"
+ cyl="${VAL}"
# Get the heads of this disk
- head=`diskinfo -v ${DISK} | grep "# Heads" | tr -s ' ' | cut -f 2`
+ get_disk_heads "${DISK}"
+ head="${VAL}"
# Get the tracks/sectors of this disk
- sec=`diskinfo -v ${DISK} | grep "# Sectors" | tr -s ' ' | cut -f 2`
+ get_disk_sectors "${DISK}"
+ sec="${VAL}"
# Multiply them all together to get our total blocks
totalblocks="`expr ${cyl} \* ${head}`"
Modified: pcbsd/trunk/pc-sysinstall/backend-query/disk-info.sh
===================================================================
--- pcbsd/trunk/pc-sysinstall/backend-query/disk-info.sh 2010-04-07 16:31:49 UTC (rev 6524)
+++ pcbsd/trunk/pc-sysinstall/backend-query/disk-info.sh 2010-04-07 16:55:20 UTC (rev 6525)
@@ -3,6 +3,7 @@
#############################
. ${PROGDIR}/backend/functions.sh
+. ${PROGDIR}/backend/functions-disk.sh
if [ -z "${1}" ]
then
@@ -16,25 +17,21 @@
exit 1
fi
-fdisk ${1} >${TMPDIR}/disk-${1} 2>/dev/null
+DISK="${1}"
-while read i
-do
- echo "$i" | grep "^cylinders=" >/dev/null 2>/dev/null
- if [ "$?" = "0" ]
- then
- CYLS="`echo $i | tr -s '\t' ' ' | cut -d '=' -f 2 | cut -d ' ' -f 1`"
- HEADS="`echo $i | tr -s '\t' ' ' | cut -d '=' -f 3 | cut -d ' ' -f 1`"
- SECS="`echo $i | tr -s '\t' ' ' | cut -d '=' -f 4 | cut -d ' ' -f 1`"
- echo "cylinders=${CYLS}"
- echo "heads=${HEADS}"
- echo "sectors=${SECS}"
- break
- fi
-done < ${TMPDIR}/disk-${1}
+get_disk_cyl "${DISK}"
+CYLS="${VAL}"
-rm ${TMPDIR}/disk-${1}
+get_disk_heads "${DISK}"
+HEADS="${VAL}"
+get_disk_sectors "${DISK}"
+SECS="${VAL}"
+
+echo "cylinders=${CYLS}"
+echo "heads=${HEADS}"
+echo "sectors=${SECS}"
+
# Now get the disks size in MB
KB="`diskinfo -v ${1} | grep 'bytes' | cut -d '#' -f 1 | tr -s '\t' ' ' | tr -d ' '`"
convert_byte_to_megabyte ${KB}
More information about the Commits
mailing list