freebsd-dev/lib/libbe
Kyle Evans 51aecc893a libbe(3): rewrite init to support chroot usage
libbe(3) currently uses zfs_be_root and locates which of its children is
currently mounted at "/". This is reasonable, but not correct in the case of
a chroot, for two reasons:

- chroot root may be of a different zpool than zfs_be_root
- chroot root will not show up as mounted at "/"

Fix both of these by rewriting libbe_init to work from the rootfs down.
zfs_path_to_zhandle on / will resolve to the dataset mounted at the new
root, rather than the real root. From there, we can derive the BE root/pool
and grab the bootfs off of the new pool. This does no harm in the average
case, and opens up bectl to operating on different pools for scenarios where
one may be, for instance, updating a pool that generally gets re-rooted into
from a separate UFS root or zfs bootpool.

While here, I've also:
- Eliminated the check for /boot and / to be on the same partition. This
  leaves one open to a setup where /boot (and consequently, kernel/modules)
  are not included in the boot environment. This may very well be an
  intentional setup done by someone that knows what they're doing, we should
  not kill BE usage because of it.

- Eliminated the validation bits of BEs and snapshots that enforced
  'mountpoint' to be "/" -- this broke when trying to operate on an imported
  pool with an altroot, but we need not be this picky.

Reported by:	philip
Reviewed by:	philip, allanjude (previous version)
Tested by:	philip
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D18012
2018-11-17 19:15:29 +00:00
..
be_access.c libbe(3): Fix error handling with respect to be_exists 2018-09-01 02:22:26 +00:00
be_error.c libbe(3): Fix error handling with respect to be_exists 2018-09-01 02:22:26 +00:00
be_impl.h libbe(3)/bectl(8): Hit rewind on a bunch of off-by-ones 2018-08-16 17:56:03 +00:00
be_info.c libbe(3): rewrite init to support chroot usage 2018-11-17 19:15:29 +00:00
be.c libbe(3): rewrite init to support chroot usage 2018-11-17 19:15:29 +00:00
be.h libbe(3): Fix error handling with respect to be_exists 2018-09-01 02:22:26 +00:00
libbe.3 libbe(3): Fix error handling with respect to be_exists 2018-09-01 02:22:26 +00:00
Makefile libbe(3)/bectl(8): Make consistent with beadm 2018-08-24 20:44:58 +00:00