diff options
author | neel <neel@FreeBSD.org> | 2012-11-20 03:57:54 +0000 |
---|---|---|
committer | neel <neel@FreeBSD.org> | 2012-11-20 03:57:54 +0000 |
commit | ca04e024ebcc0a70b6cb252dbc74f8a337aa0850 (patch) | |
tree | 4657069c3f9c018593a483ff215415f78db6ba3f | |
parent | 0e18e1b9de7bacfe2cdccb09738c895dfaf0cbf8 (diff) | |
download | FreeBSD-src-ca04e024ebcc0a70b6cb252dbc74f8a337aa0850.zip FreeBSD-src-ca04e024ebcc0a70b6cb252dbc74f8a337aa0850.tar.gz |
disk_open() is smart enough to detect MBR and GPT partitions. If it is neither
then fall back to accessing the disk as a raw device.
As an example this is useful when booting the guest from an ISO image file.
Discussed with: grehan
Obtained from: NetApp
-rw-r--r-- | sys/boot/userboot/userboot/main.c | 35 |
1 files changed, 6 insertions, 29 deletions
diff --git a/sys/boot/userboot/userboot/main.c b/sys/boot/userboot/userboot/main.c index b5e14fd..a4f1a15 100644 --- a/sys/boot/userboot/userboot/main.c +++ b/sys/boot/userboot/userboot/main.c @@ -143,7 +143,6 @@ static void extract_currdev(void) { struct disk_devdesc dev; - int gpt, rc; //bzero(&dev, sizeof(dev)); @@ -153,37 +152,15 @@ extract_currdev(void) dev.d_unit = 0; dev.d_slice = 0; dev.d_partition = 0; - /* - * 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. + * Figure out if we are using MBR or GPT. + * If neither, then access the disk as a raw device. */ - 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; - } + if ((*dev.d_dev->dv_open)(NULL, &dev)) { + 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; |