svn commit: r336715 - in projects/bectl: lib/libbe sbin/bectl
Kyle Evans
kevans at FreeBSD.org
Wed Jul 25 16:00:50 UTC 2018
Author: kevans
Date: Wed Jul 25 16:00:48 2018
New Revision: 336715
URL: https://svnweb.freebsd.org/changeset/base/336715
Log:
libbe(3)/bectl(8): Provide and use proper alloc/free for property lists
Modified:
projects/bectl/lib/libbe/be.h
projects/bectl/lib/libbe/be_info.c
projects/bectl/lib/libbe/libbe.3
projects/bectl/sbin/bectl/bectl.c
Modified: projects/bectl/lib/libbe/be.h
==============================================================================
--- projects/bectl/lib/libbe/be.h Wed Jul 25 15:58:14 2018 (r336714)
+++ projects/bectl/lib/libbe/be.h Wed Jul 25 16:00:48 2018 (r336715)
@@ -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);
Modified: projects/bectl/lib/libbe/be_info.c
==============================================================================
--- projects/bectl/lib/libbe/be_info.c Wed Jul 25 15:58:14 2018 (r336714)
+++ projects/bectl/lib/libbe/be_info.c Wed Jul 25 16:00:48 2018 (r336715)
@@ -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
*/
Modified: projects/bectl/lib/libbe/libbe.3
==============================================================================
--- projects/bectl/lib/libbe/libbe.3 Wed Jul 25 15:58:14 2018 (r336714)
+++ projects/bectl/lib/libbe/libbe.3 Wed Jul 25 16:00:48 2018 (r336715)
@@ -129,6 +129,14 @@ of state to be retained, such as errors from previous
.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
Modified: projects/bectl/sbin/bectl/bectl.c
==============================================================================
--- projects/bectl/sbin/bectl/bectl.c Wed Jul 25 15:58:14 2018 (r336714)
+++ projects/bectl/sbin/bectl/bectl.c Wed Jul 25 16:00:48 2018 (r336715)
@@ -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);
}
More information about the svn-src-projects
mailing list