Project

General

Profile

Bug #3699 » 3699.patch

Martin Matuška, 2013-04-25 06:43 AM

View differences:

usr/src/lib/libzfs/common/libzfs_dataset.c Tue Apr 23 09:31:42 2013 -0800 → usr/src/lib/libzfs/common/libzfs_dataset.c Thu Apr 25 08:41:39 2013 +0200
24 24
 * Copyright (c) 2012 by Delphix. All rights reserved.
25 25
 * Copyright (c) 2012 DEY Storage Systems, Inc.  All rights reserved.
26 26
 * Copyright 2012 Nexenta Systems, Inc. All rights reserved.
27
 * Copyright (c) 2013 Martin Matuska. All rights reserved.
27 28
 */
28 29

  
29 30
#include <ctype.h>
......
4116 4117
	ha.tag = tag;
4117 4118
	ha.recursive = recursive;
4118 4119
	(void) zfs_hold_one(zfs_handle_dup(zhp), &ha);
4120

  
4121
	if (nvlist_next_nvpair(ha.nvl, NULL) == NULL) {
4122
		fnvlist_free(ha.nvl);
4123
		ret = ENOENT;
4124
		if (!enoent_ok) {
4125
			(void) snprintf(errbuf, sizeof (errbuf),
4126
			    dgettext(TEXT_DOMAIN,
4127
			    "cannot hold snapshot '%s@%s'"),
4128
			    zhp->zfs_name, snapname);
4129
			(void) zfs_standard_error(hdl, ret, errbuf);
4130
		}
4131
		return (ret);
4132
	}
4133

  
4119 4134
	ret = lzc_hold(ha.nvl, cleanup_fd, &errors);
4120 4135
	fnvlist_free(ha.nvl);
4121 4136

  
......
4217 4232
	nvlist_t *errors;
4218 4233
	nvpair_t *elem;
4219 4234
	libzfs_handle_t *hdl = zhp->zfs_hdl;
4235
	char errbuf[1024];
4220 4236

  
4221 4237
	ha.nvl = fnvlist_alloc();
4222 4238
	ha.snapname = snapname;
4223 4239
	ha.tag = tag;
4224 4240
	ha.recursive = recursive;
4225 4241
	(void) zfs_release_one(zfs_handle_dup(zhp), &ha);
4242

  
4243
	if (nvlist_next_nvpair(ha.nvl, NULL) == NULL) {
4244
		fnvlist_free(ha.nvl);
4245
		ret = ENOENT;
4246
		(void) snprintf(errbuf, sizeof (errbuf),
4247
		    dgettext(TEXT_DOMAIN,
4248
		    "cannot release hold from snapshot '%s@%s'"),
4249
		    zhp->zfs_name, snapname);
4250
		(void) zfs_standard_error(hdl, ret, errbuf);
4251
		return (ret);
4252
	}
4253

  
4226 4254
	ret = lzc_release(ha.nvl, &errors);
4227 4255
	fnvlist_free(ha.nvl);
4228 4256

  
......
4231 4259

  
4232 4260
	if (nvlist_next_nvpair(errors, NULL) == NULL) {
4233 4261
		/* no hold-specific errors */
4234
		char errbuf[1024];
4235

  
4236 4262
		(void) snprintf(errbuf, sizeof (errbuf), dgettext(TEXT_DOMAIN,
4237 4263
		    "cannot release"));
4238 4264
		switch (errno) {
......
4249 4275
	for (elem = nvlist_next_nvpair(errors, NULL);
4250 4276
	    elem != NULL;
4251 4277
	    elem = nvlist_next_nvpair(errors, elem)) {
4252
		char errbuf[1024];
4253

  
4254 4278
		(void) snprintf(errbuf, sizeof (errbuf),
4255 4279
		    dgettext(TEXT_DOMAIN,
4256 4280
		    "cannot release hold from snapshot '%s'"),
(2-2/2)