Print this page
5515 dataset user hold doesn't reject empty tags


  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  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  * Portions Copyright 2011 Martin Matuska
  25  * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
  26  * Copyright (c) 2014, Joyent, Inc. All rights reserved.
  27  * Copyright (c) 2011, 2014 by Delphix. All rights reserved.
  28  * Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
  29  * Copyright (c) 2013 Steven Hartland. All rights reserved.
  30  * Copyright (c) 2014, Nexenta Systems, Inc. All rights reserved.
  31  */
  32 
  33 /*
  34  * ZFS ioctls.
  35  *
  36  * This file handles the ioctls to /dev/zfs, used for configuring ZFS storage
  37  * pools and filesystems, e.g. with /sbin/zfs and /sbin/zpool.
  38  *
  39  * There are two ways that we handle ioctls: the legacy way where almost
  40  * all of the logic is in the ioctl callback, and the new way where most
  41  * of the marshalling is handled in the common entry point, zfsdev_ioctl().
  42  *
  43  * Non-legacy ioctls should be registered by calling
  44  * zfs_ioctl_register() from zfs_ioctl_init().  The ioctl is invoked
  45  * from userland by lzc_ioctl().
  46  *
  47  * The registration arguments are as follows:
  48  *
  49  * const char *name
  50  *   The name of the ioctl.  This is used for history logging.  If the


5093         ZFS_EXIT(zfsvfs);
5094 
5095         return (error);
5096 }
5097 
5098 /*
5099  * innvl: {
5100  *     "holds" -> { snapname -> holdname (string), ... }
5101  *     (optional) "cleanup_fd" -> fd (int32)
5102  * }
5103  *
5104  * outnvl: {
5105  *     snapname -> error value (int32)
5106  *     ...
5107  * }
5108  */
5109 /* ARGSUSED */
5110 static int
5111 zfs_ioc_hold(const char *pool, nvlist_t *args, nvlist_t *errlist)
5112 {

5113         nvlist_t *holds;
5114         int cleanup_fd = -1;
5115         int error;
5116         minor_t minor = 0;
5117 
5118         error = nvlist_lookup_nvlist(args, "holds", &holds);
5119         if (error != 0)
5120                 return (SET_ERROR(EINVAL));













5121 
5122         if (nvlist_lookup_int32(args, "cleanup_fd", &cleanup_fd) == 0) {
5123                 error = zfs_onexit_fd_hold(cleanup_fd, &minor);
5124                 if (error != 0)
5125                         return (error);
5126         }
5127 
5128         error = dsl_dataset_user_hold(holds, minor, errlist);
5129         if (minor != 0)
5130                 zfs_onexit_fd_rele(cleanup_fd);
5131         return (error);
5132 }
5133 
5134 /*
5135  * innvl is not used.
5136  *
5137  * outnvl: {
5138  *    holdname -> time added (uint64 seconds since epoch)
5139  *    ...
5140  * }




  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  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  * Portions Copyright 2011 Martin Matuska
  25  * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
  26  * Copyright (c) 2014, Joyent, Inc. All rights reserved.
  27  * Copyright (c) 2011, 2014 by Delphix. All rights reserved.
  28  * Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
  29  * Copyright (c) 2013 Steven Hartland. All rights reserved.
  30  * Copyright (c) 2015, Nexenta Systems, Inc. All rights reserved.
  31  */
  32 
  33 /*
  34  * ZFS ioctls.
  35  *
  36  * This file handles the ioctls to /dev/zfs, used for configuring ZFS storage
  37  * pools and filesystems, e.g. with /sbin/zfs and /sbin/zpool.
  38  *
  39  * There are two ways that we handle ioctls: the legacy way where almost
  40  * all of the logic is in the ioctl callback, and the new way where most
  41  * of the marshalling is handled in the common entry point, zfsdev_ioctl().
  42  *
  43  * Non-legacy ioctls should be registered by calling
  44  * zfs_ioctl_register() from zfs_ioctl_init().  The ioctl is invoked
  45  * from userland by lzc_ioctl().
  46  *
  47  * The registration arguments are as follows:
  48  *
  49  * const char *name
  50  *   The name of the ioctl.  This is used for history logging.  If the


5093         ZFS_EXIT(zfsvfs);
5094 
5095         return (error);
5096 }
5097 
5098 /*
5099  * innvl: {
5100  *     "holds" -> { snapname -> holdname (string), ... }
5101  *     (optional) "cleanup_fd" -> fd (int32)
5102  * }
5103  *
5104  * outnvl: {
5105  *     snapname -> error value (int32)
5106  *     ...
5107  * }
5108  */
5109 /* ARGSUSED */
5110 static int
5111 zfs_ioc_hold(const char *pool, nvlist_t *args, nvlist_t *errlist)
5112 {
5113         nvpair_t *pair;
5114         nvlist_t *holds;
5115         int cleanup_fd = -1;
5116         int error;
5117         minor_t minor = 0;
5118 
5119         error = nvlist_lookup_nvlist(args, "holds", &holds);
5120         if (error != 0)
5121                 return (SET_ERROR(EINVAL));
5122 
5123         /* make sure the user didn't pass us any invalid (empty) tags */
5124         for (pair = nvlist_next_nvpair(holds, NULL); pair != NULL;
5125             pair = nvlist_next_nvpair(holds, pair)) {
5126                 char *htag;
5127 
5128                 error = nvpair_value_string(pair, &htag);
5129                 if (error != 0)
5130                         return (SET_ERROR(error));
5131 
5132                 if (strlen(htag) == 0)
5133                         return (SET_ERROR(EINVAL));
5134         }
5135 
5136         if (nvlist_lookup_int32(args, "cleanup_fd", &cleanup_fd) == 0) {
5137                 error = zfs_onexit_fd_hold(cleanup_fd, &minor);
5138                 if (error != 0)
5139                         return (error);
5140         }
5141 
5142         error = dsl_dataset_user_hold(holds, minor, errlist);
5143         if (minor != 0)
5144                 zfs_onexit_fd_rele(cleanup_fd);
5145         return (error);
5146 }
5147 
5148 /*
5149  * innvl is not used.
5150  *
5151  * outnvl: {
5152  *    holdname -> time added (uint64 seconds since epoch)
5153  *    ...
5154  * }