Index: mount_gpt_image.sh |
diff --git a/mount_gpt_image.sh b/mount_gpt_image.sh |
index 87324cbbbe617b8bf986162add7b167d8268fb35..dc0491a5d176f35a57d11c876ea40326a60b3f22 100755 |
--- a/mount_gpt_image.sh |
+++ b/mount_gpt_image.sh |
@@ -51,7 +51,7 @@ DEFINE_boolean safe $FLAGS_FALSE \ |
DEFINE_boolean unmount $FLAGS_FALSE \ |
"Unmount previously mounted dir." u |
DEFINE_string from "/dev/sdc" \ |
- "Directory containing image or device with image on it" f |
+ "Directory, image, or device with image on it" f |
DEFINE_string image "chromiumos_image.bin"\ |
"Name of the bin file if a directory is specified in the from flag" i |
DEFINE_string "rootfs_mountpt" "/tmp/m" "Mount point for rootfs" "r" |
@@ -68,6 +68,26 @@ eval set -- "${FLAGS_ARGV}" |
# Die on error |
set -e |
+# Check for conflicting args. |
+# If --from is a block device, --image can't also be specified. |
+if [ -b "${FLAGS_from}" ]; then |
+ if [ "${FLAGS_image}" != "chromiumos_image.bin" ]; then |
+ die "-i ${FLAGS_image} can't be used with block device ${FLAGS_from}" |
+ fi |
+fi |
+ |
+# Allow --from /foo/file.bin |
+if [ -f "${FLAGS_from}" ]; then |
+ # If --from is specified as a file, --image cannot be also specified. |
+ if [ "${FLAGS_image}" != "chromiumos_image.bin" ]; then |
+ die "-i ${FLAGS_image} can't be used with --from file ${FLAGS_from}" |
+ fi |
+ pathname=$(dirname "${FLAGS_from}") |
+ filename=$(basename "${FLAGS_from}") |
+ FLAGS_image="${filename}" |
+ FLAGS_from="${pathname}" |
+fi |
+ |
# Common unmounts for either a device or directory |
function unmount_image() { |
echo "Unmounting image from ${FLAGS_stateful_mountpt}" \ |