summaryrefslogtreecommitdiffstats
path: root/sys/boot/i386/zfsboot
diff options
context:
space:
mode:
authordfr <dfr@FreeBSD.org>2009-05-16 10:48:20 +0000
committerdfr <dfr@FreeBSD.org>2009-05-16 10:48:20 +0000
commit0db82eb221e9574622750dca324185ba332817e7 (patch)
tree665b606a01d251f40ccea34ac4fb9b2951d292bc /sys/boot/i386/zfsboot
parentcefe1bb18749d1b1c2254d934bdd56d96d96364d (diff)
downloadFreeBSD-src-0db82eb221e9574622750dca324185ba332817e7.zip
FreeBSD-src-0db82eb221e9574622750dca324185ba332817e7.tar.gz
Add support for booting from raidz1 and raidz2 pools.
Diffstat (limited to 'sys/boot/i386/zfsboot')
-rw-r--r--sys/boot/i386/zfsboot/zfsboot.c36
1 files changed, 22 insertions, 14 deletions
diff --git a/sys/boot/i386/zfsboot/zfsboot.c b/sys/boot/i386/zfsboot/zfsboot.c
index 43434ac..ca03568 100644
--- a/sys/boot/i386/zfsboot/zfsboot.c
+++ b/sys/boot/i386/zfsboot/zfsboot.c
@@ -413,6 +413,20 @@ int13probe(int drive)
return(0);
}
+/*
+ * We call this when we find a ZFS vdev - ZFS consumes the dsk
+ * structure so we must make a new one.
+ */
+static struct dsk *
+copy_dsk(struct dsk *dsk)
+{
+ struct dsk *newdsk;
+
+ newdsk = malloc(sizeof(struct dsk));
+ *newdsk = *dsk;
+ return (newdsk);
+}
+
static void
probe_drive(struct dsk *dsk, spa_t **spap)
{
@@ -426,9 +440,6 @@ probe_drive(struct dsk *dsk, spa_t **spap)
char *sec;
unsigned i;
- if (!int13probe(dsk->drive))
- return;
-
/*
* If we find a vdev on the whole disk, stop here. Otherwise dig
* out the MBR and probe each slice in turn for a vdev.
@@ -473,7 +484,7 @@ probe_drive(struct dsk *dsk, spa_t **spap)
if (vdev_probe(vdev_read, dsk, spap) == 0) {
/*
* We record the first pool we find (we will try
- * to boot from that one.
+ * to boot from that one).
*/
spap = 0;
@@ -481,10 +492,7 @@ probe_drive(struct dsk *dsk, spa_t **spap)
* This slice had a vdev. We need a new dsk
* structure now since the vdev now owns this one.
*/
- struct dsk *newdsk;
- newdsk = malloc(sizeof(struct dsk));
- *newdsk = *dsk;
- dsk = newdsk;
+ dsk = copy_dsk(dsk);
}
break;
}
@@ -514,10 +522,7 @@ trymbr:
* This slice had a vdev. We need a new dsk structure now
* since the vdev now owns this one.
*/
- struct dsk *newdsk;
- newdsk = malloc(sizeof(struct dsk));
- *newdsk = *dsk;
- dsk = newdsk;
+ dsk = copy_dsk(dsk);
}
}
}
@@ -569,10 +574,13 @@ main(void)
* will find any other available pools and it may fill in missing
* vdevs for the boot pool.
*/
- for (i = 0; i < 4; i++) {
+ for (i = 0; i < 128; i++) {
if ((i | DRV_HARD) == *(uint8_t *)PTOV(ARGS))
continue;
+ if (!int13probe(i | DRV_HARD))
+ break;
+
dsk = malloc(sizeof(struct dsk));
dsk->drive = i | DRV_HARD;
dsk->type = dsk->drive & TYPE_AD;
@@ -944,7 +952,7 @@ static int
drvread(struct dsk *dsk, void *buf, unsigned lba, unsigned nblk)
{
#ifdef GPT
- static unsigned c = 0x2d5c7c2f;
+ static unsigned c = 0x2d5c7c2f;
if (!OPT_CHECK(RBX_QUIET))
printf("%c\b", c = c << 8 | c >> 24);
OpenPOWER on IntegriCloud