mirror of
https://github.com/freebsd/freebsd-src
synced 2024-09-06 17:18:32 +00:00
libbe(3)/bectl(8): Provide and use proper alloc/free for property lists
This commit is contained in:
parent
4831c931dd
commit
734e362fa1
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/projects/bectl/; revision=336715
|
@ -67,6 +67,7 @@ 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 *);
|
||||
int be_prop_list_alloc(nvlist_t **be_list);
|
||||
void be_prop_list_free(nvlist_t *be_list);
|
||||
|
||||
int be_activate(libbe_handle_t *, char *, bool);
|
||||
|
|
|
@ -207,6 +207,13 @@ prop_list_builder(prop_data_t *data)
|
|||
}
|
||||
|
||||
|
||||
int
|
||||
be_prop_list_alloc(nvlist_t **be_list)
|
||||
{
|
||||
|
||||
return (nvlist_alloc(be_list, NV_UNIQUE_NAME, KM_SLEEP));
|
||||
}
|
||||
|
||||
/*
|
||||
* frees property list and its children
|
||||
*/
|
||||
|
|
|
@ -129,6 +129,14 @@ of state to be retained, such as errors from previous operations.
|
|||
.Ft int
|
||||
.Fn be_add_child "libbe_handle_t *, char *, bool" ;
|
||||
.Pp
|
||||
.Ft int
|
||||
.Fn be_prop_list_alloc "nvlist_t **" ;
|
||||
.Pp
|
||||
.Ft int
|
||||
.Fn be_get_bootenv_props "libbe_handle_t *, nvlist_t *" ;
|
||||
.Pp
|
||||
.Ft void
|
||||
.Fn be_prop_list_free "nvlist_t *" ;
|
||||
.\" .Ft void
|
||||
.\" .Fn mp_mfree "MINT *mp" ;
|
||||
.\" .Bd -ragged -offset indent
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
|
||||
#include <sys/param.h>
|
||||
#include <sys/jail.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/mount.h>
|
||||
#include <errno.h>
|
||||
#include <stdbool.h>
|
||||
|
@ -418,6 +417,7 @@ bectl_cmd_list(int argc, char *argv[])
|
|||
int opt;
|
||||
bool show_all_datasets, show_space, hide_headers, show_snaps;
|
||||
|
||||
props = NULL;
|
||||
show_all_datasets = show_space = hide_headers = show_snaps = false;
|
||||
while ((opt = getopt(argc, argv, "aDHs")) != -1) {
|
||||
switch (opt) {
|
||||
|
@ -448,7 +448,7 @@ bectl_cmd_list(int argc, char *argv[])
|
|||
}
|
||||
|
||||
|
||||
if (nvlist_alloc(&props, NV_UNIQUE_NAME, M_WAITOK) != 0) {
|
||||
if (be_prop_list_alloc(&props) != 0) {
|
||||
fprintf(stderr, "bectl list: failed to allocate prop nvlist\n");
|
||||
return (1);
|
||||
}
|
||||
|
@ -459,7 +459,7 @@ bectl_cmd_list(int argc, char *argv[])
|
|||
}
|
||||
|
||||
dump_nvlist(props, 0);
|
||||
nvlist_free(props);
|
||||
be_prop_list_free(props);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue