Deleted Added
full compact
libzfs_dataset.c (251646) libzfs_dataset.c (252219)
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

--- 7 unchanged lines hidden (view full) ---

16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22/*
23 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

--- 7 unchanged lines hidden (view full) ---

16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22/*
23 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Copyright 2012 Nexenta Systems, Inc. All rights reserved.
25 * Copyright (c) 2011 by Delphix. All rights reserved.
24 * Copyright (c) 2013 by Delphix. All rights reserved.
26 * Copyright (c) 2012 DEY Storage Systems, Inc. All rights reserved.
25 * Copyright (c) 2012 DEY Storage Systems, Inc. All rights reserved.
26 * Copyright 2012 Nexenta Systems, Inc. All rights reserved.
27 * Copyright (c) 2011-2012 Pawel Jakub Dawidek <pawel@dawidek.net>.
28 * All rights reserved.
29 * Copyright (c) 2012 Martin Matuska <mm@FreeBSD.org>. All rights reserved.
30 * Copyright (c) 2013 Steven Hartland. All rights reserved.
31 */
32
33#include <ctype.h>
34#include <errno.h>

--- 4119 unchanged lines hidden (view full) ---

4154 return (0);
4155}
4156
4157struct holdarg {
4158 nvlist_t *nvl;
4159 const char *snapname;
4160 const char *tag;
4161 boolean_t recursive;
27 * Copyright (c) 2011-2012 Pawel Jakub Dawidek <pawel@dawidek.net>.
28 * All rights reserved.
29 * Copyright (c) 2012 Martin Matuska <mm@FreeBSD.org>. All rights reserved.
30 * Copyright (c) 2013 Steven Hartland. All rights reserved.
31 */
32
33#include <ctype.h>
34#include <errno.h>

--- 4119 unchanged lines hidden (view full) ---

4154 return (0);
4155}
4156
4157struct holdarg {
4158 nvlist_t *nvl;
4159 const char *snapname;
4160 const char *tag;
4161 boolean_t recursive;
4162 int error;
4162};
4163
4164static int
4165zfs_hold_one(zfs_handle_t *zhp, void *arg)
4166{
4167 struct holdarg *ha = arg;
4168 char name[ZFS_MAXNAMELEN];
4169 int rv = 0;

--- 111 unchanged lines hidden (view full) ---

4281}
4282
4283static int
4284zfs_release_one(zfs_handle_t *zhp, void *arg)
4285{
4286 struct holdarg *ha = arg;
4287 char name[ZFS_MAXNAMELEN];
4288 int rv = 0;
4163};
4164
4165static int
4166zfs_hold_one(zfs_handle_t *zhp, void *arg)
4167{
4168 struct holdarg *ha = arg;
4169 char name[ZFS_MAXNAMELEN];
4170 int rv = 0;

--- 111 unchanged lines hidden (view full) ---

4282}
4283
4284static int
4285zfs_release_one(zfs_handle_t *zhp, void *arg)
4286{
4287 struct holdarg *ha = arg;
4288 char name[ZFS_MAXNAMELEN];
4289 int rv = 0;
4290 nvlist_t *existing_holds;
4289
4290 (void) snprintf(name, sizeof (name),
4291 "%s@%s", zhp->zfs_name, ha->snapname);
4292
4291
4292 (void) snprintf(name, sizeof (name),
4293 "%s@%s", zhp->zfs_name, ha->snapname);
4294
4293 if (lzc_exists(name)) {
4294 nvlist_t *holds = fnvlist_alloc();
4295 fnvlist_add_boolean(holds, ha->tag);
4296 fnvlist_add_nvlist(ha->nvl, name, holds);
4297 fnvlist_free(holds);
4295 if (lzc_get_holds(name, &existing_holds) != 0) {
4296 ha->error = ENOENT;
4297 } else if (!nvlist_exists(existing_holds, ha->tag)) {
4298 ha->error = ESRCH;
4299 } else {
4300 nvlist_t *torelease = fnvlist_alloc();
4301 fnvlist_add_boolean(torelease, ha->tag);
4302 fnvlist_add_nvlist(ha->nvl, name, torelease);
4303 fnvlist_free(torelease);
4298 }
4299
4300 if (ha->recursive)
4301 rv = zfs_iter_filesystems(zhp, zfs_release_one, ha);
4302 zfs_close(zhp);
4303 return (rv);
4304}
4305

--- 7 unchanged lines hidden (view full) ---

4313 nvpair_t *elem;
4314 libzfs_handle_t *hdl = zhp->zfs_hdl;
4315 char errbuf[1024];
4316
4317 ha.nvl = fnvlist_alloc();
4318 ha.snapname = snapname;
4319 ha.tag = tag;
4320 ha.recursive = recursive;
4304 }
4305
4306 if (ha->recursive)
4307 rv = zfs_iter_filesystems(zhp, zfs_release_one, ha);
4308 zfs_close(zhp);
4309 return (rv);
4310}
4311

--- 7 unchanged lines hidden (view full) ---

4319 nvpair_t *elem;
4320 libzfs_handle_t *hdl = zhp->zfs_hdl;
4321 char errbuf[1024];
4322
4323 ha.nvl = fnvlist_alloc();
4324 ha.snapname = snapname;
4325 ha.tag = tag;
4326 ha.recursive = recursive;
4327 ha.error = 0;
4321 (void) zfs_release_one(zfs_handle_dup(zhp), &ha);
4322
4323 if (nvlist_empty(ha.nvl)) {
4324 fnvlist_free(ha.nvl);
4328 (void) zfs_release_one(zfs_handle_dup(zhp), &ha);
4329
4330 if (nvlist_empty(ha.nvl)) {
4331 fnvlist_free(ha.nvl);
4325 ret = ENOENT;
4332 ret = ha.error;
4326 (void) snprintf(errbuf, sizeof (errbuf),
4327 dgettext(TEXT_DOMAIN,
4328 "cannot release hold from snapshot '%s@%s'"),
4329 zhp->zfs_name, snapname);
4333 (void) snprintf(errbuf, sizeof (errbuf),
4334 dgettext(TEXT_DOMAIN,
4335 "cannot release hold from snapshot '%s@%s'"),
4336 zhp->zfs_name, snapname);
4330 (void) zfs_standard_error(hdl, ret, errbuf);
4337 if (ret == ESRCH) {
4338 (void) zfs_error(hdl, EZFS_REFTAG_RELE, errbuf);
4339 } else {
4340 (void) zfs_standard_error(hdl, ret, errbuf);
4341 }
4331 return (ret);
4332 }
4333
4334 ret = lzc_release(ha.nvl, &errors);
4335 fnvlist_free(ha.nvl);
4336
4337 if (ret == 0) {
4338 /* There may be errors even in the success case. */

--- 284 unchanged lines hidden ---
4342 return (ret);
4343 }
4344
4345 ret = lzc_release(ha.nvl, &errors);
4346 fnvlist_free(ha.nvl);
4347
4348 if (ret == 0) {
4349 /* There may be errors even in the success case. */

--- 284 unchanged lines hidden ---