Patchwork [3/6] runqemu: simplify process_filename()

login
register
mail settings
Submitter Bernhard Reutner-Fischer
Date May 3, 2012, 5:12 p.m.
Message ID <1336065154-8513-3-git-send-email-rep.dot.nop@gmail.com>
Download mbox | patch
Permalink /patch/26967/
State Accepted
Commit 042efbe653b699bd33175117e1363d87e4602e4f
Headers show

Comments

Bernhard Reutner-Fischer - May 3, 2012, 5:12 p.m.
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
---
 scripts/runqemu |   47 +++++++++++++++++++++++++----------------------
 1 file changed, 25 insertions(+), 22 deletions(-)

Patch

diff --git a/scripts/runqemu b/scripts/runqemu
index 18fd691..dfa7f4b 100755
--- a/scripts/runqemu
+++ b/scripts/runqemu
@@ -62,28 +62,31 @@  process_filename() {
 
     # Extract the filename extension
     EXT=`echo $filename | awk -F . '{ print \$NF }'`
-    # A file ending in .bin is a kernel
-    if [ "x$EXT" = "xbin" ]; then
-        if [ -z "$KERNEL" ]; then
-            KERNEL=$filename
-        else
-            echo "Error: conflicting KERNEL args [$KERNEL] and [$filename]"
-            usage
-        fi
-    elif [ "x$EXT" = "xext2" -o "x$EXT" = "xext3" -o \
-            "x$EXT" = "xjffs2" -o "x$EXT" = "xbtrfs" ]; then
-        # A file ending in a supportted fs type is a rootfs image
-        if [ -z "$FSTYPE" -o "$FSTYPE" = "$EXT" ]; then
-            FSTYPE=$EXT
-            ROOTFS=$filename
-        else
-            echo "Error: conflicting FSTYPE types [$FSTYPE] and [$EXT]"
-            usage
-        fi
-    else
-       echo "Error: unknown file arg [$filename]"
-       usage
-    fi
+    case /$EXT/ in
+	/bin/)
+		# A file ending in .bin is a kernel
+		if [ -z "$KERNEL" ]; then
+		    KERNEL=$filename
+		else
+		    echo "Error: conflicting KERNEL args [$KERNEL] and [$filename]"
+		    usage
+		fi
+		;;
+	/ext[234]/|/jffs2/|/btrfs/)
+		# A file ending in a supportted fs type is a rootfs image
+		if [ -z "$FSTYPE" -o "$FSTYPE" = "$EXT" ]; then
+		    FSTYPE=$EXT
+		    ROOTFS=$filename
+		else
+		    echo "Error: conflicting FSTYPE types [$FSTYPE] and [$EXT]"
+		    usage
+		fi
+		;;
+	*)
+		echo "Error: unknown file arg [$filename]"
+		usage
+		;;
+    esac
 }
 
 # Parse command line args without requiring specific ordering. It's a