aboutsummaryrefslogtreecommitdiffstats
path: root/lib/libzfs/libzfs_dataset.c
diff options
context:
space:
mode:
authorGiuseppe Di Natale <[email protected]>2017-06-26 16:56:09 -0700
committerBrian Behlendorf <[email protected]>2017-06-26 16:56:09 -0700
commitd12f91fde3c6a7d1aa71967b3480faac6c853051 (patch)
treeeb04ad4ac4f5cbf2d7e45a20f1047da24a41b16a /lib/libzfs/libzfs_dataset.c
parent7517376f939d788a2622c84fe1f502799a74a0ae (diff)
OpenZFS 8264 - want support for promoting datasets in libzfs_core
Authored by: Andrew Stormont <[email protected]> Reviewed by: Andriy Gapon <[email protected]> Reviewed by: Matthew Ahrens <[email protected]> Reviewed by: Dan McDonald <[email protected]> Approved by: Dan McDonald <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Ported-by: Giuseppe Di Natale <[email protected]> OpenZFS-issue: https://www.illumos.org/issues/8264 OpenZFS-commit: https://github.com/openzfs/openzfs/commit/a4b8c9a Closes #6254
Diffstat (limited to 'lib/libzfs/libzfs_dataset.c')
-rw-r--r--lib/libzfs/libzfs_dataset.c20
1 files changed, 7 insertions, 13 deletions
diff --git a/lib/libzfs/libzfs_dataset.c b/lib/libzfs/libzfs_dataset.c
index f1346b69c..bc630919a 100644
--- a/lib/libzfs/libzfs_dataset.c
+++ b/lib/libzfs/libzfs_dataset.c
@@ -29,6 +29,7 @@
* Copyright (c) 2013 Steven Hartland. All rights reserved.
* Copyright 2016 Nexenta Systems, Inc.
* Copyright 2016 Igor Kozhukhov <[email protected]>
+ * Copyright 2017 RackTop Systems.
*/
#include <ctype.h>
@@ -3731,8 +3732,7 @@ int
zfs_promote(zfs_handle_t *zhp)
{
libzfs_handle_t *hdl = zhp->zfs_hdl;
- zfs_cmd_t zc = {"\0"};
- char parent[MAXPATHLEN];
+ char snapname[ZFS_MAX_DATASET_NAME_LEN];
int ret;
char errbuf[1024];
@@ -3745,31 +3745,25 @@ zfs_promote(zfs_handle_t *zhp)
return (zfs_error(hdl, EZFS_BADTYPE, errbuf));
}
- (void) strlcpy(parent, zhp->zfs_dmustats.dds_origin, sizeof (parent));
- if (parent[0] == '\0') {
+ if (zhp->zfs_dmustats.dds_origin[0] == '\0') {
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"not a cloned filesystem"));
return (zfs_error(hdl, EZFS_BADTYPE, errbuf));
}
- (void) strlcpy(zc.zc_value, zhp->zfs_dmustats.dds_origin,
- sizeof (zc.zc_value));
- (void) strlcpy(zc.zc_name, zhp->zfs_name, sizeof (zc.zc_name));
- ret = zfs_ioctl(hdl, ZFS_IOC_PROMOTE, &zc);
+ ret = lzc_promote(zhp->zfs_name, snapname, sizeof (snapname));
if (ret != 0) {
- int save_errno = errno;
-
- switch (save_errno) {
+ switch (ret) {
case EEXIST:
/* There is a conflicting snapshot name. */
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"conflicting snapshot '%s' from parent '%s'"),
- zc.zc_string, parent);
+ snapname, zhp->zfs_dmustats.dds_origin);
return (zfs_error(hdl, EZFS_EXISTS, errbuf));
default:
- return (zfs_standard_error(hdl, save_errno, errbuf));
+ return (zfs_standard_error(hdl, ret, errbuf));
}
}
return (ret);