diff options
author | ae <ae@FreeBSD.org> | 2012-08-15 10:11:29 +0000 |
---|---|---|
committer | ae <ae@FreeBSD.org> | 2012-08-15 10:11:29 +0000 |
commit | 3a3516f682aed16fb4e0dde60a18ec33b225ed68 (patch) | |
tree | 743339f2d08ec0760ac3c1b4379649ba3312e3d0 /sys/boot/common | |
parent | e96225dccbcdd2775ef28b26baf1d1f833b2dd97 (diff) | |
download | FreeBSD-src-3a3516f682aed16fb4e0dde60a18ec33b225ed68.zip FreeBSD-src-3a3516f682aed16fb4e0dde60a18ec33b225ed68.tar.gz |
Rework r239232 to unbreak ZFS detection on MBR slices.
Diffstat (limited to 'sys/boot/common')
-rw-r--r-- | sys/boot/common/disk.c | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/sys/boot/common/disk.c b/sys/boot/common/disk.c index 9e4c78f..c7716d3 100644 --- a/sys/boot/common/disk.c +++ b/sys/boot/common/disk.c @@ -187,16 +187,14 @@ disk_open(struct disk_devdesc *dev, off_t mediasize, u_int sectorsize) dev->d_offset = part.start; if (dev->d_partition == 255) goto out; /* Nothing more to do */ - if (dev->d_partition == -1) { - /* - * If we are looking at a BSD slice, and the - * partition is < 0, assume the 'a' partition. - */ - if (part.type == PART_FREEBSD) - dev->d_partition = 0; - else - goto out; - } + /* + * If d_partition < 0 and we are looking at a BSD slice, + * then try to read BSD label, otherwise return the + * whole MBR slice. + */ + if (dev->d_partition == -1 && + part.type != PART_FREEBSD) + goto out; /* Try to read BSD label */ table = ptable_open(dev, part.end - part.start + 1, od->sectorsize, ptblread); @@ -205,6 +203,16 @@ disk_open(struct disk_devdesc *dev, off_t mediasize, u_int sectorsize) rc = ENXIO; goto out; } + /* + * If slice contains BSD label and d_partition < 0, then + * assume the 'a' partition. Otherwise just return the + * whole MBR slice, because it can contain ZFS. + */ + if (dev->d_partition < 0) { + if (ptable_gettype(table) != PTABLE_BSD) + goto out; + dev->d_partition = 0; + } rc = ptable_getpart(table, &part, dev->d_partition); if (rc != 0) goto out; |