aboutsummaryrefslogtreecommitdiff
path: root/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c
diff options
context:
space:
mode:
authorMartin Matuska <mm@FreeBSD.org>2013-04-11 07:49:16 +0000
committerMartin Matuska <mm@FreeBSD.org>2013-04-11 07:49:16 +0000
commit12eef24d20c37d9473b9adb5f508b71d4755b080 (patch)
treeb0655f8617687ad08079c9e4e61413190c28f57c /cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c
parent2cb0c5e42411ad6df56967c763117c817b9679cd (diff)
downloadsrc-12eef24d20c37d9473b9adb5f508b71d4755b080.tar.gz
src-12eef24d20c37d9473b9adb5f508b71d4755b080.zip
Fix libzfs to report error instead of returning zero if trying to hold or
release a non-existing snapshot of a existing dataset. In recursive case error is reported if no snapshots with the requested name have been found. Problem and proposed solution reported to illumos: 3699 zfs hold or release of a non-existent snapshot does not output error MFC after: 8 days
Notes
Notes: svn path=/head/; revision=249357
Diffstat (limited to 'cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c')
-rw-r--r--cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c
index c64d1c359f13..e78bb82c61fb 100644
--- a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c
+++ b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c
@@ -4203,6 +4203,17 @@ zfs_hold(zfs_handle_t *zhp, const char *snapname, const char *tag,
ha.tag = tag;
ha.recursive = recursive;
(void) zfs_hold_one(zfs_handle_dup(zhp), &ha);
+
+ if (nvlist_next_nvpair(ha.nvl, NULL) == NULL) {
+ fnvlist_free(ha.nvl);
+ ret = ENOENT;
+ (void) snprintf(errbuf, sizeof (errbuf),
+ dgettext(TEXT_DOMAIN, "cannot hold snapshot '%s@%s'"),
+ zhp->zfs_name, snapname);
+ (void) zfs_standard_error(hdl, ret, errbuf);
+ return (ret);
+ }
+
ret = lzc_hold(ha.nvl, cleanup_fd, &errors);
fnvlist_free(ha.nvl);
@@ -4304,12 +4315,25 @@ zfs_release(zfs_handle_t *zhp, const char *snapname, const char *tag,
nvlist_t *errors;
nvpair_t *elem;
libzfs_handle_t *hdl = zhp->zfs_hdl;
+ char errbuf[1024];
ha.nvl = fnvlist_alloc();
ha.snapname = snapname;
ha.tag = tag;
ha.recursive = recursive;
(void) zfs_release_one(zfs_handle_dup(zhp), &ha);
+
+ if (nvlist_next_nvpair(ha.nvl, NULL) == NULL) {
+ fnvlist_free(ha.nvl);
+ ret = ENOENT;
+ (void) snprintf(errbuf, sizeof (errbuf),
+ dgettext(TEXT_DOMAIN,
+ "cannot release hold from snapshot '%s@%s'"),
+ zhp->zfs_name, snapname);
+ (void) zfs_standard_error(hdl, ret, errbuf);
+ return (ret);
+ }
+
ret = lzc_release(ha.nvl, &errors);
fnvlist_free(ha.nvl);
@@ -4318,8 +4342,6 @@ zfs_release(zfs_handle_t *zhp, const char *snapname, const char *tag,
if (nvlist_next_nvpair(errors, NULL) == NULL) {
/* no hold-specific errors */
- char errbuf[1024];
-
(void) snprintf(errbuf, sizeof (errbuf), dgettext(TEXT_DOMAIN,
"cannot release"));
switch (errno) {
@@ -4336,8 +4358,6 @@ zfs_release(zfs_handle_t *zhp, const char *snapname, const char *tag,
for (elem = nvlist_next_nvpair(errors, NULL);
elem != NULL;
elem = nvlist_next_nvpair(errors, elem)) {
- char errbuf[1024];
-
(void) snprintf(errbuf, sizeof (errbuf),
dgettext(TEXT_DOMAIN,
"cannot release hold from snapshot '%s'"),