From 3e7245a788272e8e1ed4d8ba6ca6165b1842abca Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Tue, 17 Jan 2012 18:19:32 -0500 Subject: [PATCH] image_to_usb: fix typo in flag checking which eats hard drives The variable setup is "FLAGS_force_non_usb", not "FLAGS_force_non". Trying to run this currently results in: ./image_to_usb.sh: line 189: [: -ne: unary operator expected Copying USB image .../chromiumos_image.bin to device /dev/sdb... This should have instead errored out: Error: Device /dev/sdb does not appear to be a USB or MMC disk! Without this fix, image_to_usb.sh proceeds to corrupt the non-usb disk (which in my case happened to be a backing store for lvm where all my source was stored and ext4 not surprisingly barfed). BUG=None TEST=`./image_to_usb.sh --board=x86-alex -y --to=/dev/sdb` (where /dev/sdb is a disk) now errors out instead of clobbering data TEST=`./image_to_usb.sh --board=x86-alex -y --to=/dev/sdc` (where /dev/sdc is USB) still works Change-Id: Id691846393c02cf199309495ae2080b15626e684 Reviewed-on: https://gerrit.chromium.org/gerrit/14334 Reviewed-by: Zdenek Behan Reviewed-by: Chris Wolfe Commit-Ready: Mike Frysinger Tested-by: Mike Frysinger --- image_to_usb.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/image_to_usb.sh b/image_to_usb.sh index 606bd07700..eea95f296a 100755 --- a/image_to_usb.sh +++ b/image_to_usb.sh @@ -186,7 +186,7 @@ if [ -b "${FLAGS_to}" ]; then list_mmc_disks | grep -q '^'${FLAGS_to##*/}'$'; then disk_manufacturer=$(get_disk_info ${FLAGS_to##*/} manufacturer) disk_product=$(get_disk_info ${FLAGS_to##*/} product) - elif [ ${FLAGS_force_non} -ne ${FLAGS_TRUE} ]; then + elif [ ${FLAGS_force_non_usb} -ne ${FLAGS_TRUE} ]; then # Safeguard against writing to a real non-USB disk or non-SD disk echo "Error: Device ${FLAGS_to} does not appear to be a USB or MMC disk!" echo " To override this safeguard, use the --force_non_usb flag"