Print this page
3973 zfs_ioc_rename alters passed in zc->zc_name
Reviewed by: Matthew Ahrens <mahrens@delphix.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/fs/zfs/zfs_ioctl.c
          +++ new/usr/src/uts/common/fs/zfs/zfs_ioctl.c
↓ open down ↓ 3544 lines elided ↑ open up ↑
3545 3545          char *at;
3546 3546  
3547 3547          zc->zc_value[sizeof (zc->zc_value) - 1] = '\0';
3548 3548          if (dataset_namecheck(zc->zc_value, NULL, NULL) != 0 ||
3549 3549              strchr(zc->zc_value, '%'))
3550 3550                  return (SET_ERROR(EINVAL));
3551 3551  
3552 3552          at = strchr(zc->zc_name, '@');
3553 3553          if (at != NULL) {
3554 3554                  /* snaps must be in same fs */
     3555 +                int error;
     3556 +
3555 3557                  if (strncmp(zc->zc_name, zc->zc_value, at - zc->zc_name + 1))
3556 3558                          return (SET_ERROR(EXDEV));
3557 3559                  *at = '\0';
3558 3560                  if (zc->zc_objset_type == DMU_OST_ZFS) {
3559      -                        int error = dmu_objset_find(zc->zc_name,
     3561 +                        error = dmu_objset_find(zc->zc_name,
3560 3562                              recursive_unmount, at + 1,
3561 3563                              recursive ? DS_FIND_CHILDREN : 0);
3562      -                        if (error != 0)
     3564 +                        if (error != 0) {
     3565 +                                *at = '@';
3563 3566                                  return (error);
     3567 +                        }
3564 3568                  }
3565      -                return (dsl_dataset_rename_snapshot(zc->zc_name,
3566      -                    at + 1, strchr(zc->zc_value, '@') + 1, recursive));
     3569 +                error = dsl_dataset_rename_snapshot(zc->zc_name,
     3570 +                    at + 1, strchr(zc->zc_value, '@') + 1, recursive);
     3571 +                *at = '@';
     3572 +
     3573 +                return (error);
3567 3574          } else {
3568 3575                  if (zc->zc_objset_type == DMU_OST_ZVOL)
3569 3576                          (void) zvol_remove_minor(zc->zc_name);
3570 3577                  return (dsl_dir_rename(zc->zc_name, zc->zc_value));
3571 3578          }
3572 3579  }
3573 3580  
3574 3581  static int
3575 3582  zfs_check_settable(const char *dsname, nvpair_t *pair, cred_t *cr)
3576 3583  {
↓ open down ↓ 2337 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX