aboutsummaryrefslogtreecommitdiff
path: root/lib/libbe
diff options
context:
space:
mode:
authorKyle Evans <kevans@FreeBSD.org>2018-07-25 14:45:00 +0000
committerKyle Evans <kevans@FreeBSD.org>2018-07-25 14:45:00 +0000
commitff8676cc4e02c6e138f2f3b68a6903dc418e5cc4 (patch)
tree36f0131b6dd3024307697f628b51cd08aee0110e /lib/libbe
parent3682d5e902c1b159611c14dc3ef16c436b18b8a8 (diff)
downloadsrc-ff8676cc4e02c6e138f2f3b68a6903dc418e5cc4.tar.gz
src-ff8676cc4e02c6e138f2f3b68a6903dc418e5cc4.zip
libbe(3): Add nextboot flag to returned BE information
Notes
Notes: svn path=/projects/bectl/; revision=336709
Diffstat (limited to 'lib/libbe')
-rw-r--r--lib/libbe/be.c3
-rw-r--r--lib/libbe/be.h2
-rw-r--r--lib/libbe/be_info.c24
3 files changed, 28 insertions, 1 deletions
diff --git a/lib/libbe/be.c b/lib/libbe/be.c
index c4e31b3b9a3e..934cdaf21f9f 100644
--- a/lib/libbe/be.c
+++ b/lib/libbe/be.c
@@ -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:
diff --git a/lib/libbe/be.h b/lib/libbe/be.h
index 66ac8c104714..2727c1cdfeee 100644
--- a/lib/libbe/be.h
+++ b/lib/libbe/be.h
@@ -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 *);
diff --git a/lib/libbe/be_info.c b/lib/libbe/be_info.c
index 9219d7a75f98..6a7e445a5d56 100644
--- a/lib/libbe/be_info.c
+++ b/lib/libbe/be_info.c
@@ -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);