diff --git a/lib/libbe/be.h b/lib/libbe/be.h index 1b3218c206a4..f532718b81d6 100644 --- a/lib/libbe/be.h +++ b/lib/libbe/be.h @@ -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); diff --git a/lib/libbe/be_info.c b/lib/libbe/be_info.c index 3f638163a783..7cb014086db0 100644 --- a/lib/libbe/be_info.c +++ b/lib/libbe/be_info.c @@ -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 */ diff --git a/lib/libbe/libbe.3 b/lib/libbe/libbe.3 index 2ddb2b0a0c58..db94dca78467 100644 --- a/lib/libbe/libbe.3 +++ b/lib/libbe/libbe.3 @@ -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 diff --git a/sbin/bectl/bectl.c b/sbin/bectl/bectl.c index 98a9121a2cf3..74f7130e33c8 100644 --- a/sbin/bectl/bectl.c +++ b/sbin/bectl/bectl.c @@ -28,7 +28,6 @@ #include #include -#include #include #include #include @@ -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); }