Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 25 Jul 2018 14:45:01 +0000 (UTC)
From:      Kyle Evans <kevans@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r336709 - projects/bectl/lib/libbe
Message-ID:  <201807251445.w6PEj1Md022024@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kevans
Date: Wed Jul 25 14:45:00 2018
New Revision: 336709
URL: https://svnweb.freebsd.org/changeset/base/336709

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

Modified:
  projects/bectl/lib/libbe/be.c
  projects/bectl/lib/libbe/be.h
  projects/bectl/lib/libbe/be_info.c

Modified: projects/bectl/lib/libbe/be.c
==============================================================================
--- projects/bectl/lib/libbe/be.c	Wed Jul 25 14:30:47 2018	(r336708)
+++ projects/bectl/lib/libbe/be.c	Wed Jul 25 14:45:00 2018	(r336709)
@@ -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:

Modified: projects/bectl/lib/libbe/be.h
==============================================================================
--- projects/bectl/lib/libbe/be.h	Wed Jul 25 14:30:47 2018	(r336708)
+++ projects/bectl/lib/libbe/be.h	Wed Jul 25 14:45:00 2018	(r336709)
@@ -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 *);

Modified: projects/bectl/lib/libbe/be_info.c
==============================================================================
--- projects/bectl/lib/libbe/be_info.c	Wed Jul 25 14:30:47 2018	(r336708)
+++ projects/bectl/lib/libbe/be_info.c	Wed Jul 25 14:45:00 2018	(r336709)
@@ -58,8 +58,29 @@ 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
  */
 const char *
@@ -157,7 +178,8 @@ prop_list_builder_cb(zfs_handle_t *zfs_hdl, void *data
 	    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);
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201807251445.w6PEj1Md022024>