Print this page
2882 implement libzfs_core
2883 changing "canmount" property to "on" should not always remount dataset
2900 "zfs snapshot" should be able to create multiple, arbitrary snapshots at once
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Chris Siden <christopher.siden@delphix.com>
Reviewed by: Garrett D'Amore <garrett@damore.org>
Reviewed by: Bill Pijewski <wdp@joyent.com>
Reviewed by: Dan Kruchinin <dan.kruchinin@gmail.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libzfs/common/libzfs_iter.c
          +++ new/usr/src/lib/libzfs/common/libzfs_iter.c
↓ open down ↓ 14 lines elided ↑ open up ↑
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22   22  /*
  23   23   * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  24   24   * Copyright 2010 Nexenta Systems, Inc. All rights reserved.
  25      - * Copyright (c) 2011 by Delphix. All rights reserved.
       25 + * Copyright (c) 2012 by Delphix. All rights reserved.
  26   26   */
  27   27  
  28   28  #include <stdio.h>
  29   29  #include <stdlib.h>
  30   30  #include <strings.h>
  31   31  #include <unistd.h>
  32   32  #include <stddef.h>
  33   33  #include <libintl.h>
  34   34  #include <libzfs.h>
  35   35  
↓ open down ↓ 258 lines elided ↑ open up ↑
 294  294   *      %               (all snapshots)
 295  295   *      <snaps>[,...]   (comma separated list of the above)
 296  296   *
 297  297   * If a snapshot can not be opened, continue trying to open the others, but
 298  298   * return ENOENT at the end.
 299  299   */
 300  300  int
 301  301  zfs_iter_snapspec(zfs_handle_t *fs_zhp, const char *spec_orig,
 302  302      zfs_iter_f func, void *arg)
 303  303  {
 304      -        char buf[ZFS_MAXNAMELEN];
 305      -        char *comma_separated, *cp;
      304 +        char *buf, *comma_separated, *cp;
 306  305          int err = 0;
 307  306          int ret = 0;
 308  307  
 309      -        (void) strlcpy(buf, spec_orig, sizeof (buf));
      308 +        buf = zfs_strdup(fs_zhp->zfs_hdl, spec_orig);
 310  309          cp = buf;
 311  310  
 312  311          while ((comma_separated = strsep(&cp, ",")) != NULL) {
 313  312                  char *pct = strchr(comma_separated, '%');
 314  313                  if (pct != NULL) {
 315  314                          snapspec_arg_t ssa = { 0 };
 316  315                          ssa.ssa_func = func;
 317  316                          ssa.ssa_arg = arg;
 318  317  
 319  318                          if (pct == comma_separated)
↓ open down ↓ 37 lines elided ↑ open up ↑
 357  356                          if (snap_zhp == NULL) {
 358  357                                  ret = ENOENT;
 359  358                                  continue;
 360  359                          }
 361  360                          err = func(snap_zhp, arg);
 362  361                          if (ret == 0)
 363  362                                  ret = err;
 364  363                  }
 365  364          }
 366  365  
      366 +        free(buf);
 367  367          return (ret);
 368  368  }
 369  369  
 370  370  /*
 371  371   * Iterate over all children, snapshots and filesystems
 372  372   */
 373  373  int
 374  374  zfs_iter_children(zfs_handle_t *zhp, zfs_iter_f func, void *data)
 375  375  {
 376  376          int ret;
↓ open down ↓ 86 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX