]> git.proxmox.com Git - mirror_zfs-debian.git/blobdiff - lib/libzfs/libzfs_dataset.c
Imported Upstream version 0.6.5.8
[mirror_zfs-debian.git] / lib / libzfs / libzfs_dataset.c
index 088ee35c4f6b2a14ce7fd83e7313a3c85d994444..dde1a9a0fca6cef50b7f99023f3d13d85c7f4825 100644 (file)
@@ -3889,7 +3889,6 @@ zfs_rename(zfs_handle_t *zhp, const char *target, boolean_t recursive,
        }
 
        if (recursive) {
-
                parentname = zfs_strdup(zhp->zfs_hdl, zhp->zfs_name);
                if (parentname == NULL) {
                        ret = -1;
@@ -3902,8 +3901,7 @@ zfs_rename(zfs_handle_t *zhp, const char *target, boolean_t recursive,
                        ret = -1;
                        goto error;
                }
-
-       } else {
+       } else if (zhp->zfs_type != ZFS_TYPE_SNAPSHOT) {
                if ((cl = changelist_gather(zhp, ZFS_PROP_NAME, 0,
                    force_unmount ? MS_FORCE : 0)) == NULL)
                        return (-1);
@@ -3952,23 +3950,23 @@ zfs_rename(zfs_handle_t *zhp, const char *target, boolean_t recursive,
                 * On failure, we still want to remount any filesystems that
                 * were previously mounted, so we don't alter the system state.
                 */
-               if (!recursive)
+               if (cl != NULL)
                        (void) changelist_postfix(cl);
        } else {
-               if (!recursive) {
+               if (cl != NULL) {
                        changelist_rename(cl, zfs_get_name(zhp), target);
                        ret = changelist_postfix(cl);
                }
        }
 
 error:
-       if (parentname) {
+       if (parentname != NULL) {
                free(parentname);
        }
-       if (zhrp) {
+       if (zhrp != NULL) {
                zfs_close(zhrp);
        }
-       if (cl) {
+       if (cl != NULL) {
                changelist_free(cl);
        }
        return (ret);