From ba598b122e294d2b8d300a73ad3f8e40ee6fe0c8 Mon Sep 17 00:00:00 2001 From: avg Date: Sat, 6 Oct 2012 19:47:24 +0000 Subject: 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 --- sys/boot/zfs/libzfs.h | 2 ++ sys/boot/zfs/zfsimpl.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) (limited to 'sys/boot/zfs') 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) { -- cgit v1.1