aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorKyle Evans <kevans@FreeBSD.org>2018-08-05 04:40:13 +0000
committerKyle Evans <kevans@FreeBSD.org>2018-08-05 04:40:13 +0000
commit9b1662e67b54e3a4ae04050beacc38645a003a8c (patch)
treebca5f029a89a2ba2a68ec6931a283dbe452d2556 /lib
parentf97b318f7d23f2ef500a7342fe050ddac9424460 (diff)
downloadsrc-9b1662e67b54e3a4ae04050beacc38645a003a8c.tar.gz
src-9b1662e67b54e3a4ae04050beacc38645a003a8c.zip
bectl: Implement -D ("space if origin datasets were deleted")
This also accomplishes the following: - Proxy through zfs_nicenum as be_nicenum, because it looks better than humanize_number and would presumably be useful to other libbe consumers. - Rename be_get_snapshot_props to be_get_dataset_props, make it more useful
Notes
Notes: svn path=/projects/bectl/; revision=337343
Diffstat (limited to 'lib')
-rw-r--r--lib/libbe/be.c9
-rw-r--r--lib/libbe/be.h3
-rw-r--r--lib/libbe/be_info.c4
-rw-r--r--lib/libbe/libbe.35
4 files changed, 17 insertions, 4 deletions
diff --git a/lib/libbe/be.c b/lib/libbe/be.c
index 48bb36c2beea..4e889abee2e4 100644
--- a/lib/libbe/be.c
+++ b/lib/libbe/be.c
@@ -171,6 +171,15 @@ libbe_close(libbe_handle_t *lbh)
free(lbh);
}
+/*
+ * Proxy through to libzfs for the moment.
+ */
+void
+be_nicenum(uint64_t num, char *buf, size_t buflen)
+{
+
+ zfs_nicenum(num, buf, buflen);
+}
/*
* Destroy the boot environment or snapshot specified by the name
diff --git a/lib/libbe/be.h b/lib/libbe/be.h
index 988baaf16b08..e220626e6af2 100644
--- a/lib/libbe/be.h
+++ b/lib/libbe/be.h
@@ -67,7 +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_get_dataset_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);
@@ -116,5 +116,6 @@ int be_export(libbe_handle_t *, char *, int fd);
int be_import(libbe_handle_t *, char *, int fd);
int be_add_child(libbe_handle_t *, char *, bool);
+void be_nicenum(uint64_t num, char *buf, size_t buflen);
#endif /* _LIBBE_H */
diff --git a/lib/libbe/be_info.c b/lib/libbe/be_info.c
index c4059ea5d598..49f64151d034 100644
--- a/lib/libbe/be_info.c
+++ b/lib/libbe/be_info.c
@@ -99,7 +99,7 @@ be_get_bootenv_props(libbe_handle_t *lbh, nvlist_t *dsnvl)
}
int
-be_get_snapshot_props(libbe_handle_t *lbh, const char *name, nvlist_t *props)
+be_get_dataset_props(libbe_handle_t *lbh, const char *name, nvlist_t *props)
{
zfs_handle_t *snap_hdl;
prop_data_t data;
@@ -109,7 +109,7 @@ be_get_snapshot_props(libbe_handle_t *lbh, const char *name, nvlist_t *props)
data.list = props;
data.single_object = true;
if ((snap_hdl = zfs_open(lbh->lzh, name,
- ZFS_TYPE_SNAPSHOT)) == NULL)
+ ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT)) == NULL)
return (BE_ERR_ZFSOPEN);
ret = prop_list_builder_cb(snap_hdl, &data);
diff --git a/lib/libbe/libbe.3 b/lib/libbe/libbe.3
index 365a1e85dc66..cdd4ab7ae653 100644
--- a/lib/libbe/libbe.3
+++ b/lib/libbe/libbe.3
@@ -88,6 +88,9 @@ of state to be retained, such as errors from previous operations.
.Ft int
.Fn be_destroy "libbe_handle_t *, char *, int" ;
.Pp
+.Ft void
+.Fn be_nicenum "uint64_t, char *, size_t" ;
+.Pp
.\" TODO: Write up of mount options
.\" typedef enum {
.\" BE_MNT_FORCE = 1 << 0,
@@ -139,7 +142,7 @@ of state to be retained, such as errors from previous operations.
.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 *" ;
+.Fn be_get_dataset_props "libbe_handle_t *, const char *, nvlist_t *" ;
.Pp
.Ft void
.Fn be_prop_list_free "nvlist_t *" ;