Skip to content

Commit 9554185

Browse files
Steven Hartlandbehlendorf
authored andcommitted
Illumos #3973
3973 zfs_ioc_rename alters passed in zc->zc_name Reviewed by: Matthew Ahrens <mahrens@delphix.com> Reviewed by: George Wilson <george.wilson@delphix.com> Approved by: Christopher Siden <christopher.siden@delphix.com> References: https://www.illumos.org/issues/3973 illumos/illumos-gate@a0c1127 Ported-by: Richard Yao <ryao@gentoo.org> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Issue #1775
1 parent 6389d42 commit 9554185

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

module/zfs/zfs_ioctl.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3550,18 +3550,25 @@ zfs_ioc_rename(zfs_cmd_t *zc)
35503550
at = strchr(zc->zc_name, '@');
35513551
if (at != NULL) {
35523552
/* snaps must be in same fs */
3553+
int error;
3554+
35533555
if (strncmp(zc->zc_name, zc->zc_value, at - zc->zc_name + 1))
35543556
return (SET_ERROR(EXDEV));
35553557
*at = '\0';
35563558
if (zc->zc_objset_type == DMU_OST_ZFS) {
3557-
int error = dmu_objset_find(zc->zc_name,
3559+
error = dmu_objset_find(zc->zc_name,
35583560
recursive_unmount, at + 1,
35593561
recursive ? DS_FIND_CHILDREN : 0);
3560-
if (error != 0)
3562+
if (error != 0) {
3563+
*at = '@';
35613564
return (error);
3565+
}
35623566
}
3563-
return (dsl_dataset_rename_snapshot(zc->zc_name,
3564-
at + 1, strchr(zc->zc_value, '@') + 1, recursive));
3567+
error = dsl_dataset_rename_snapshot(zc->zc_name,
3568+
at + 1, strchr(zc->zc_value, '@') + 1, recursive);
3569+
*at = '@';
3570+
3571+
return (error);
35653572
} else {
35663573
err = dsl_dir_rename(zc->zc_name, zc->zc_value);
35673574
if (!err && zc->zc_objset_type == DMU_OST_ZVOL) {

0 commit comments

Comments
 (0)