Check the partition scheme before blowing away disks, instead of after.

The effects of this patch would only be noticeable if you were purposefully
setting a bad value and trying to see what happens; and leaving the disks
intact if a bad value has been set seems fair.
This commit is contained in:
dteske 2013-11-11 02:13:47 +00:00
parent 34ec6f44ca
commit ff748f24da

View File

@ -645,6 +645,18 @@ zfs_create_diskpart()
fi
f_dprintf "$funcname: disk=[%s] index=[%s]" "$disk" "$index"
# Check for unknown partition scheme before proceeding further
case "$ZFSBOOT_PARTITION_SCHEME" in
""|MBR|GPT) : known good ;;
*)
f_dprintf "$funcname: %s is an unsupported partition scheme" \
"$ZFSBOOT_PARTITION_SCHEME"
msg_error="$msg_error: $funcname" f_show_err \
"$msg_unsupported_partition_scheme" \
"$ZFSBOOT_PARTITION_SCHEME"
return $FAILURE
esac
#
# Destroy whatever partition layout is currently on disk.
# NOTE: `-F' required to destroy if partitions still exist.
@ -824,14 +836,6 @@ zfs_create_diskpart()
fi
;;
*)
f_dprintf "$funcname: %s is an unsupported partition scheme" \
"$ZFSBOOT_PARTITION_SCHEME"
msg_error="$msg_error: $funcname" f_show_err \
"$msg_unsupported_partition_scheme" \
"$ZFSBOOT_PARTITION_SCHEME"
return $FAILURE
esac # $ZFSBOOT_PARTITION_SCHEME
return $SUCCESS