Print this page
8264 want support for promoting datasets in libzfs_core

@@ -28,10 +28,11 @@
  * Copyright (c) 2013 Martin Matuska. All rights reserved.
  * Copyright (c) 2013 Steven Hartland. All rights reserved.
  * Copyright (c) 2014 Integros [integros.com]
  * Copyright 2016 Nexenta Systems, Inc.
  * Copyright 2016 Igor Kozhukhov <ikozhukhov@gmail.com>
+ * Copyright 2017 RackTop Systems.
  */
 
 #include <ctype.h>
 #include <errno.h>
 #include <libintl.h>

@@ -3626,12 +3627,11 @@
  */
 int
 zfs_promote(zfs_handle_t *zhp)
 {
         libzfs_handle_t *hdl = zhp->zfs_hdl;
-        zfs_cmd_t zc = { 0 };
-        char parent[MAXPATHLEN];
+        char snapname[MAXPATHLEN];
         int ret;
         char errbuf[1024];
 
         (void) snprintf(errbuf, sizeof (errbuf), dgettext(TEXT_DOMAIN,
             "cannot promote '%s'"), zhp->zfs_name);

@@ -3640,31 +3640,27 @@
                 zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
                     "snapshots can not be promoted"));
                 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) {
                 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));
                 }