--- livecd/tools/livecd-iso-to-disk.sh	2010-08-12 11:19:30.000000000 -0700
+++ /usr/bin/livecd-iso-to-disk	2010-08-16 16:11:41.636948177 -0700
@@ -39,10 +39,17 @@
     exit 1
 }
 
+
+isdevloop() {
+    [ x"${1#/dev/loop}" != x"$1" ]
+}
+
+
 getdisk() {
+
     DEV=$1
 
-    if [[ "$DEV" =~ "/dev/loop*" ]]; then
+    if isdevloop "$DEV"; then
        device="$DEV"
        return
     fi
@@ -65,7 +72,7 @@
 }
 
 resetMBR() {
-    if [[ "$DEV" =~ "/dev/loop*" ]]; then
+    if isdevloop "$DEV"; then
        return
     fi
     getdisk $1
@@ -94,7 +101,7 @@
 }
 
 checkMBR() {
-    if [[ "$DEV" =~ "/dev/loop*" ]]; then
+    if isdevloop "$DEV"; then
        return 0
     fi
     getdisk $1
@@ -124,7 +131,7 @@
     if [ "$dev" = "$device" ]; then
 	return
     fi
-    if [[ "$dev" =~ "/dev/loop*" ]]; then
+    if isdevloop "$dev"; then
         return
     fi
 
@@ -184,7 +191,11 @@
     partinfo=$(LC_ALL=C /sbin/parted --script -m $device "unit b print" |grep ^$device:)
     size=$(echo $partinfo |cut -d : -f 2 |sed -e 's/B$//')
     /sbin/parted --script $device unit b mkpart primary fat32 17408 $(($size - 17408)) set 1 boot on
-    USBDEV=${device}1
+    if ! isdevloop "$DEV"; then
+        USBDEV=${device}1
+    else
+        USBDEV=${device}
+    fi
     # Sometimes automount can be _really_ annoying.
     echo "Waiting for devices to settle..."
     /sbin/udevadm settle
