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.
This commit is contained in:
parent
b4e1235d02
commit
9927174fb2
@ -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);
|
||||
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
|
||||
@ -177,10 +176,6 @@ 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)
|
||||
return (BE_ERR_ZFSOPEN);
|
||||
|
@ -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>
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user