aboutsummaryrefslogtreecommitdiff
path: root/lib/libbe
diff options
context:
space:
mode:
authorKyle Evans <kevans@FreeBSD.org>2018-08-03 02:04:57 +0000
committerKyle Evans <kevans@FreeBSD.org>2018-08-03 02:04:57 +0000
commit4146029bb31648f465c87a46dc0bc79e913816ad (patch)
treea73425d41eec2249029ad1783d8a9a873a560cff /lib/libbe
parent74c55b3d388e99eefebf99bf3776e87eefd476d9 (diff)
Notes
Diffstat (limited to 'lib/libbe')
-rw-r--r--lib/libbe/be.h1
-rw-r--r--lib/libbe/be_access.c1
-rw-r--r--lib/libbe/be_impl.h1
-rw-r--r--lib/libbe/be_info.c27
-rw-r--r--lib/libbe/libbe.33
5 files changed, 31 insertions, 2 deletions
diff --git a/lib/libbe/be.h b/lib/libbe/be.h
index 94d7bb353afd..988baaf16b08 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_get_snapshot_props(libbe_handle_t *, const char *, nvlist_t *);
int be_prop_list_alloc(nvlist_t **be_list);
void be_prop_list_free(nvlist_t *be_list);
diff --git a/lib/libbe/be_access.c b/lib/libbe/be_access.c
index 917bc3d0463d..55481e04e14b 100644
--- a/lib/libbe/be_access.c
+++ b/lib/libbe/be_access.c
@@ -83,6 +83,7 @@ be_mounted_at(libbe_handle_t *lbh, const char *path, nvlist_t *details)
propinfo.lbh = lbh;
propinfo.list = details;
+ propinfo.single_object = false;
prop_list_builder_cb(root_hdl, &propinfo);
zfs_close(root_hdl);
}
diff --git a/lib/libbe/be_impl.h b/lib/libbe/be_impl.h
index b8f61e99591b..89894f4ac026 100644
--- a/lib/libbe/be_impl.h
+++ b/lib/libbe/be_impl.h
@@ -58,6 +58,7 @@ struct libbe_dccb {
typedef struct prop_data {
nvlist_t *list;
libbe_handle_t *lbh;
+ bool single_object; /* list will contain props directly */
} prop_data_t;
int prop_list_builder_cb(zfs_handle_t *, void *);
diff --git a/lib/libbe/be_info.c b/lib/libbe/be_info.c
index 6e8db75db416..c4059ea5d598 100644
--- a/lib/libbe/be_info.c
+++ b/lib/libbe/be_info.c
@@ -94,9 +94,28 @@ be_get_bootenv_props(libbe_handle_t *lbh, nvlist_t *dsnvl)
data.lbh = lbh;
data.list = dsnvl;
+ data.single_object = false;
return (prop_list_builder(&data));
}
+int
+be_get_snapshot_props(libbe_handle_t *lbh, const char *name, nvlist_t *props)
+{
+ zfs_handle_t *snap_hdl;
+ prop_data_t data;
+ int ret;
+
+ data.lbh = lbh;
+ data.list = props;
+ data.single_object = true;
+ if ((snap_hdl = zfs_open(lbh->lzh, name,
+ ZFS_TYPE_SNAPSHOT)) == NULL)
+ return (BE_ERR_ZFSOPEN);
+
+ ret = prop_list_builder_cb(snap_hdl, &data);
+ zfs_close(snap_hdl);
+ return (ret);
+}
/*
* Internal callback function used by zfs_iter_filesystems. For each dataset in
@@ -121,7 +140,10 @@ prop_list_builder_cb(zfs_handle_t *zfs_hdl, void *data_p)
data = (prop_data_t *)data_p;
lbh = data->lbh;
- nvlist_alloc(&props, NV_UNIQUE_NAME, KM_SLEEP);
+ if (data->single_object)
+ props = data->list;
+ else
+ nvlist_alloc(&props, NV_UNIQUE_NAME, KM_SLEEP);
dataset = zfs_get_name(zfs_hdl);
nvlist_add_string(props, "dataset", dataset);
@@ -169,7 +191,8 @@ prop_list_builder_cb(zfs_handle_t *zfs_hdl, void *data_p)
nvlist_add_boolean_value(props, "nextboot",
(strcmp(be_nextboot_path(lbh), dataset) == 0));
- nvlist_add_nvlist(data->list, name, props);
+ if (!data->single_object)
+ nvlist_add_nvlist(data->list, name, props);
return (0);
}
diff --git a/lib/libbe/libbe.3 b/lib/libbe/libbe.3
index 9689ffc00a21..365a1e85dc66 100644
--- a/lib/libbe/libbe.3
+++ b/lib/libbe/libbe.3
@@ -138,6 +138,9 @@ of state to be retained, such as errors from previous operations.
.Ft int
.Fn be_get_bootenv_props "libbe_handle_t *, nvlist_t *" ;
.Pp
+.Ft int
+.Fn be_get_snapshot_props "libbe_handle_t *, const char *, nvlist_t *" ;
+.Pp
.Ft void
.Fn be_prop_list_free "nvlist_t *" ;
.\" .Ft void