libbe(3): Add nextboot flag to returned BE information

This commit is contained in:
Kyle Evans 2018-07-25 14:45:00 +00:00
parent 3682d5e902
commit ff8676cc4e
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/projects/bectl/; revision=336709
3 changed files with 28 additions and 1 deletions

View File

@ -138,6 +138,9 @@ libbe_init(void)
zfs_iter_filesystems(rootds, be_locate_rootfs, lbh);
zfs_close(rootds);
rootds = NULL;
if (lbh->rootfs == NULL)
goto err;
return (lbh);
err:

View File

@ -62,6 +62,8 @@ void libbe_close(libbe_handle_t *);
/* Bootenv information functions: be_info.c */
const char *be_active_name(libbe_handle_t *);
const char *be_active_path(libbe_handle_t *);
const char *be_nextboot_name(libbe_handle_t *);
const char *be_nextboot_path(libbe_handle_t *);
const char *be_root_path(libbe_handle_t *);
int be_get_bootenv_props(libbe_handle_t *, nvlist_t *);

View File

@ -58,6 +58,27 @@ be_active_path(libbe_handle_t *lbh)
return (lbh->rootfs);
}
/*
* Returns the name of the next active boot environment
*/
const char *
be_nextboot_name(libbe_handle_t *lbh)
{
return (strrchr(lbh->bootfs, '/') + sizeof(char));
}
/*
* Returns full path of the active boot environment
*/
const char *
be_nextboot_path(libbe_handle_t *lbh)
{
return (lbh->bootfs);
}
/*
* Returns the path of the boot environment root dataset
@ -157,7 +178,8 @@ prop_list_builder_cb(zfs_handle_t *zfs_hdl, void *data_p)
NULL, NULL, 0, 1))
nvlist_add_string(props, "referenced", buf);
/* XXX TODO: Add bootfs info */
nvlist_add_boolean_value(props, "nextboot",
(strcmp(be_nextboot_path(lbh), dataset) == 0));
nvlist_add_nvlist(data->list, name, props);