summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys/boot/userboot/userboot/main.c34
1 files changed, 30 insertions, 4 deletions
diff --git a/sys/boot/userboot/userboot/main.c b/sys/boot/userboot/userboot/main.c
index d3f2fa7..8a8a7d6 100644
--- a/sys/boot/userboot/userboot/main.c
+++ b/sys/boot/userboot/userboot/main.c
@@ -129,6 +129,7 @@ static void
extract_currdev(void)
{
struct disk_devdesc dev;
+ int gpt, rc;
//bzero(&dev, sizeof(dev));
@@ -138,12 +139,37 @@ extract_currdev(void)
dev.d_unit = 0;
dev.d_slice = 0;
dev.d_partition = 0;
+
/*
- * Figure out if we are using MBR or GPT - for GPT we
- * set the partition to 0 since everything is a GPT slice.
+ * The priority is GPT, MBR and raw disk. Unfortunately,
+ * disk_open() doesn't really get this right so first
+ * probe for MBR, and then GPT. If GPT fails, re-probe
+ * MBR if it succeeded, else assume raw.
*/
- if (dev.d_dev->dv_open(NULL, &dev))
- dev.d_partition = 255;
+ rc = (*dev.d_dev->dv_open)(NULL, &dev);
+
+ dev.d_unit = 0;
+ dev.d_slice = 0;
+ dev.d_partition = 255;
+ gpt = (*dev.d_dev->dv_open)(NULL, &dev);
+
+ if (gpt) {
+ dev.d_unit = 0;
+ dev.d_slice = 0;
+ dev.d_partition = 0;
+
+ if (!rc) {
+ (void) (*dev.d_dev->dv_open)(NULL, &dev);
+ } else {
+ /*
+ * Force raw disk access
+ */
+ dev.d_slice = -1;
+ dev.d_partition = -1;
+ dev.d_offset = 0;
+ }
+ }
+
} else {
dev.d_dev = &host_dev;
dev.d_type = dev.d_dev->dv_type;
OpenPOWER on IntegriCloud