svn commit: r336708 - in projects/bectl: lib/libbe sbin/bectl
Kyle Evans
kevans at FreeBSD.org
Wed Jul 25 14:30:49 UTC 2018
Author: kevans
Date: Wed Jul 25 14:30:47 2018
New Revision: 336708
URL: https://svnweb.freebsd.org/changeset/base/336708
Log:
bectl(8): Start dumping out BE information with `bectl list`
For the moment, this is a primitive nvlist dump of what we get back from
be_get_bootenv_props as a proof-of-concept and to make sure that we're
getting back the kind of information we want to see from list.
Modified:
projects/bectl/lib/libbe/be.h
projects/bectl/lib/libbe/be_info.c
projects/bectl/sbin/bectl/Makefile
projects/bectl/sbin/bectl/bectl.c
Modified: projects/bectl/lib/libbe/be.h
==============================================================================
--- projects/bectl/lib/libbe/be.h Wed Jul 25 14:05:17 2018 (r336707)
+++ projects/bectl/lib/libbe/be.h Wed Jul 25 14:30:47 2018 (r336708)
@@ -29,6 +29,7 @@
#ifndef _LIBBE_H
#define _LIBBE_H
+#include <libnvpair.h>
#include <stdbool.h>
#define BE_MAXPATHLEN 512
@@ -63,7 +64,7 @@ const char *be_active_name(libbe_handle_t *);
const char *be_active_path(libbe_handle_t *);
const char *be_root_path(libbe_handle_t *);
-/* nvlist_t *be_get_bootenv_props(libbe_handle_t *); */
+int be_get_bootenv_props(libbe_handle_t *, nvlist_t *);
int be_activate(libbe_handle_t *, char *, bool);
Modified: projects/bectl/lib/libbe/be_info.c
==============================================================================
--- projects/bectl/lib/libbe/be_info.c Wed Jul 25 14:05:17 2018 (r336707)
+++ projects/bectl/lib/libbe/be_info.c Wed Jul 25 14:30:47 2018 (r336708)
@@ -71,18 +71,17 @@ be_root_path(libbe_handle_t *lbh)
/*
- * Returns an nvlist of the bootenv's properties
- * TODO: the nvlist should be passed as a param and ints should return status
+ * Populates dsnvl with one nvlist per bootenv dataset describing the properties
+ * of that dataset that we've declared ourselves to care about.
*/
-nvlist_t *
-be_get_bootenv_props(libbe_handle_t *lbh)
+int
+be_get_bootenv_props(libbe_handle_t *lbh, nvlist_t *dsnvl)
{
prop_data_t data;
data.lbh = lbh;
- prop_list_builder(&data);
-
- return (data.list);
+ data.list = dsnvl;
+ return (prop_list_builder(&data));
}
@@ -176,10 +175,6 @@ static int
prop_list_builder(prop_data_t *data)
{
zfs_handle_t *root_hdl;
-
- if (nvlist_alloc(&(data->list), NV_UNIQUE_NAME, KM_SLEEP) != 0)
- /* XXX TODO: actually handle error */
- return (1);
if ((root_hdl = zfs_open(data->lbh->lzh, data->lbh->root,
ZFS_TYPE_FILESYSTEM)) == NULL)
Modified: projects/bectl/sbin/bectl/Makefile
==============================================================================
--- projects/bectl/sbin/bectl/Makefile Wed Jul 25 14:05:17 2018 (r336707)
+++ projects/bectl/sbin/bectl/Makefile Wed Jul 25 14:30:47 2018 (r336708)
@@ -7,4 +7,10 @@ MAN= bectl.8
LIBADD+= be
LIBADD+= nvpair
+CFLAGS+= -I${SRCTOP}/cddl/contrib/opensolaris/lib/libzfs/common
+CFLAGS+= -I${SRCTOP}/sys/cddl/compat/opensolaris
+CFLAGS+= -I${SRCTOP}/sys/cddl/contrib/opensolaris/uts/common
+
+CFLAGS+= -DNEED_SOLARIS_BOOLEAN
+
.include <bsd.prog.mk>
Modified: projects/bectl/sbin/bectl/bectl.c
==============================================================================
--- projects/bectl/sbin/bectl/bectl.c Wed Jul 25 14:05:17 2018 (r336707)
+++ projects/bectl/sbin/bectl/bectl.c Wed Jul 25 14:30:47 2018 (r336708)
@@ -28,6 +28,7 @@
#include <sys/param.h>
#include <sys/jail.h>
+#include <sys/malloc.h>
#include <sys/mount.h>
#include <errno.h>
#include <stdbool.h>
@@ -38,7 +39,6 @@
#include <sysexits.h>
#include <unistd.h>
-#include <sys/nv.h>
#include <be.h>
static int bectl_cmd_activate(int argc, char *argv[]);
@@ -417,8 +417,8 @@ bectl_cmd_jail(int argc, char *argv[])
static int
bectl_cmd_list(int argc, char *argv[])
{
- char *bootenv;
nvlist_t *props;
+ char *bootenv;
int opt;
bool show_all_datasets, show_space, hide_headers, show_snaps;
@@ -451,7 +451,20 @@ bectl_cmd_list(int argc, char *argv[])
return (usage(false));
}
- /* props = be_get_bootenv_props(be); */
+
+ if (nvlist_alloc(&props, NV_UNIQUE_NAME, M_WAITOK) != 0) {
+ fprintf(stderr, "bectl list: failed to allocate prop nvlist\n");
+ return (1);
+ }
+ if (be_get_bootenv_props(be, props) != 0) {
+ /* XXX TODO: Real errors */
+ fprintf(stderr, "bectl list: failed to fetch boot environments\n");
+ return (1);
+ }
+
+ dump_nvlist(props, 0);
+ nvlist_free(props);
+
return (0);
}
More information about the svn-src-projects
mailing list