diff options
author | avg <avg@FreeBSD.org> | 2012-10-06 19:47:24 +0000 |
---|---|---|
committer | avg <avg@FreeBSD.org> | 2012-10-06 19:47:24 +0000 |
commit | ba598b122e294d2b8d300a73ad3f8e40ee6fe0c8 (patch) | |
tree | af95066f7b29983c0067cab81cdde661838fa951 /sys/boot/zfs | |
parent | 9e17baa574362b48400e993efd857fa97880b96a (diff) | |
download | FreeBSD-src-ba598b122e294d2b8d300a73ad3f8e40ee6fe0c8.zip FreeBSD-src-ba598b122e294d2b8d300a73ad3f8e40ee6fe0c8.tar.gz |
zfs boot: export boot/primary pool and vdev guid all the way to kenv
This is work in progress to for znextboot and it also provides
some convenient infrastructure.
MFC after: 20 days
Diffstat (limited to 'sys/boot/zfs')
-rw-r--r-- | sys/boot/zfs/libzfs.h | 2 | ||||
-rw-r--r-- | sys/boot/zfs/zfsimpl.c | 28 |
2 files changed, 30 insertions, 0 deletions
diff --git a/sys/boot/zfs/libzfs.h b/sys/boot/zfs/libzfs.h index 92611db..6834f8b 100644 --- a/sys/boot/zfs/libzfs.h +++ b/sys/boot/zfs/libzfs.h @@ -53,6 +53,8 @@ struct zfs_boot_args uint32_t reserved; uint64_t pool; uint64_t root; + uint64_t primary_pool; + uint64_t primary_vdev; }; int zfs_parsedev(struct zfs_devdesc *dev, const char *devspec, diff --git a/sys/boot/zfs/zfsimpl.c b/sys/boot/zfs/zfsimpl.c index 182bd83..1a82fe6 100644 --- a/sys/boot/zfs/zfsimpl.c +++ b/sys/boot/zfs/zfsimpl.c @@ -706,6 +706,34 @@ spa_find_by_name(const char *name) return (0); } +#ifdef BOOT2 +static spa_t * +spa_get_primary(void) +{ + + return (STAILQ_FIRST(&zfs_pools)); +} + +static vdev_t * +spa_get_primary_vdev(const spa_t *spa) +{ + vdev_t *vdev; + vdev_t *kid; + + if (spa == NULL) + spa = spa_get_primary(); + if (spa == NULL) + return (NULL); + vdev = STAILQ_FIRST(&spa->spa_vdevs); + if (vdev == NULL) + return (NULL); + for (kid = STAILQ_FIRST(&vdev->v_children); kid != NULL; + kid = STAILQ_FIRST(&vdev->v_children)) + vdev = kid; + return (vdev); +} +#endif + static spa_t * spa_create(uint64_t guid) { |