Add a partition table check in FixPartitionTable
authorNikos Skalkotos <skalkoto@grnet.gr>
Tue, 14 Feb 2012 13:53:43 +0000 (15:53 +0200)
committerNikos Skalkotos <skalkoto@grnet.gr>
Tue, 14 Feb 2012 13:53:43 +0000 (15:53 +0200)
snf-image-helper/common.sh
snf-image-helper/tasks/10FixPartitionTable.in

index c420d3a..5bcb2f0 100644 (file)
@@ -94,6 +94,13 @@ get_distro() {
     fi
 }
 
+check_partition_table() {
+    local dev="$1"
+    if ! "$PARTED" -s "$dev" print; then
+        log_error "Unable to read partition table for device \`${dev}'"
+    fi
+}
+
 get_last_partition() {
     local dev="$1"
 
index bf73936..c29f5c4 100644 (file)
@@ -33,6 +33,8 @@ if [ ! -b "$SNF_IMAGE_DEV" ]; then
     log_error "Device file:\`${SNF_IMAGE_DEV}' is not a block device"
 fi
 
+check_partition_table "$SNF_IMAGE_DEV"
+
 if [ $(get_partition_count "$SNF_IMAGE_DEV") -eq 0 ]; then
     log_error "Device: \`${SNF_IMAGE_DEV}' does not contain any partition"
 fi