diff options
author | Steven Hartland <[email protected]> | 2013-08-06 09:50:40 -0800 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2013-11-05 12:15:50 -0800 |
commit | 9554185d90a9f833c023c1bb8bc35779b8fd1b10 (patch) | |
tree | a624b22cd401b4df7be083fab0e3b34b83f88dc5 | |
parent | 6389d42205f56083b7658b2c67f117a244f13e52 (diff) |
Illumos #3973
3973 zfs_ioc_rename alters passed in zc->zc_name
Reviewed by: Matthew Ahrens <[email protected]>
Reviewed by: George Wilson <[email protected]>
Approved by: Christopher Siden <[email protected]>
References:
https://www.illumos.org/issues/3973
illumos/illumos-gate@a0c1127b147dc6a0372b141deb8c0c2b0195b8ea
Ported-by: Richard Yao <[email protected]>
Signed-off-by: Brian Behlendorf <[email protected]>
Issue #1775
-rw-r--r-- | module/zfs/zfs_ioctl.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/module/zfs/zfs_ioctl.c b/module/zfs/zfs_ioctl.c index 556a0c940..4ad885ac6 100644 --- a/module/zfs/zfs_ioctl.c +++ b/module/zfs/zfs_ioctl.c @@ -3550,18 +3550,25 @@ zfs_ioc_rename(zfs_cmd_t *zc) at = strchr(zc->zc_name, '@'); if (at != NULL) { /* snaps must be in same fs */ + int error; + if (strncmp(zc->zc_name, zc->zc_value, at - zc->zc_name + 1)) return (SET_ERROR(EXDEV)); *at = '\0'; if (zc->zc_objset_type == DMU_OST_ZFS) { - int error = dmu_objset_find(zc->zc_name, + error = dmu_objset_find(zc->zc_name, recursive_unmount, at + 1, recursive ? DS_FIND_CHILDREN : 0); - if (error != 0) + if (error != 0) { + *at = '@'; return (error); + } } - return (dsl_dataset_rename_snapshot(zc->zc_name, - at + 1, strchr(zc->zc_value, '@') + 1, recursive)); + error = dsl_dataset_rename_snapshot(zc->zc_name, + at + 1, strchr(zc->zc_value, '@') + 1, recursive); + *at = '@'; + + return (error); } else { err = dsl_dir_rename(zc->zc_name, zc->zc_value); if (!err && zc->zc_objset_type == DMU_OST_ZVOL) { |