From 1cb7b0b53cc643ca5827bbd6bd4bde803a18e2f8 Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Sat, 28 Feb 2009 11:04:47 +0000 Subject: [PATCH] simplify QI GTA03 boot-SD size discovery This patch uses fdisk instead of dmesg to determine the size of the uSD card. This should be less fragile and is much simpler than the previous solution. Signed-off-by: Werner Almesberger --- qiboot/6410-partition-sd.sh | 30 ++---------------------------- 1 file changed, 2 insertions(+), 28 deletions(-) diff --git a/qiboot/6410-partition-sd.sh b/qiboot/6410-partition-sd.sh index 3615de5..7952667 100755 --- a/qiboot/6410-partition-sd.sh +++ b/qiboot/6410-partition-sd.sh @@ -50,34 +50,8 @@ if [ ! -z "`grep $1 /proc/mounts`" ] ; then exit 2 fi -# set CUT_COLUMN for each OS -# set USE_SED=some editing command -# default: use cat as a no-op -USE_SED='cat' -case "$(lsb_release --short --description)" in - Ubuntu\ 7*|Debian\ *) - CUT_COLUMN=5 - ;; - Ubuntu\ 8.04*) - CUT_COLUMN=5 - USE_SED='sed s/^\[[[:space:]]*/[/' - ;; - *) - CUT_COLUMN=4 - ;; -esac - -DMESG_LINE=$(dmesg | ${USE_SED} | grep "$1" | grep "512-byte hardware" | tail -n 1) -SECTORS=$(echo "${DMESG_LINE}" | cut -d' ' -f"${CUT_COLUMN}") - -if ! echo "${SECTORS}" | grep '^[[:digit:]]\+$' -then - echo "problem finding size for /dev/$1 check CUT_COLUMN value for your os" - echo "CUT_COLUMN=${CUT_COLUMN} --> ${SECTORS}" - echo "dmesg line was:" - echo "${DMESG_LINE}" - exit 3 -fi +bytes=`echo p | fdisk /dev/$1 2>&1 | sed '/^Disk.*, \([0-9]*\) bytes/s//\1/p;d'` +SECTORS=`expr $bytes / 512` if [ $SECTORS -le 0 ] ; then echo "problem finding size for /dev/$1"