Print this page
8264 want support for promoting datasets in libzfs_core
*** 21,30 ****
--- 21,31 ----
/*
* Copyright (c) 2012, 2014 by Delphix. All rights reserved.
* Copyright (c) 2013 Steven Hartland. All rights reserved.
* Copyright (c) 2014 Integros [integros.com]
+ * Copyright 2017 RackTop Systems.
*/
/*
* LibZFS_Core (lzc) is intended to replace most functionality in libzfs.
* It has the following characteristics:
*** 201,210 ****
--- 202,232 ----
error = lzc_ioctl(ZFS_IOC_CLONE, fsname, args, NULL);
nvlist_free(args);
return (error);
}
+ int
+ lzc_promote(const char *fsname, char *snapnamebuf, int snapnamelen)
+ {
+ /*
+ * The promote ioctl is still legacy, so we need to construct our
+ * own zfs_cmd_t rather than using lzc_ioctl().
+ */
+ zfs_cmd_t zc = { 0 };
+
+ ASSERT3S(g_refcount, >, 0);
+ VERIFY3S(g_fd, !=, -1);
+
+ (void) strlcpy(zc.zc_name, fsname, sizeof (zc.zc_name));
+ if (ioctl(g_fd, ZFS_IOC_PROMOTE, &zc) != 0) {
+ if (errno == EEXIST && snapnamebuf != NULL)
+ (void) strlcpy(snapnamebuf, zc.zc_string, snapnamelen);
+ return (errno);
+ }
+ return (0);
+ }
+
/*
* Creates snapshots.
*
* The keys in the snaps nvlist are the snapshots to be created.
* They must all be in the same pool.
*** 328,338 ****
boolean_t
lzc_exists(const char *dataset)
{
/*
* The objset_stats ioctl is still legacy, so we need to construct our
! * own zfs_cmd_t rather than using zfsc_ioctl().
*/
zfs_cmd_t zc = { 0 };
ASSERT3S(g_refcount, >, 0);
VERIFY3S(g_fd, !=, -1);
--- 350,360 ----
boolean_t
lzc_exists(const char *dataset)
{
/*
* The objset_stats ioctl is still legacy, so we need to construct our
! * own zfs_cmd_t rather than using lzc_ioctl().
*/
zfs_cmd_t zc = { 0 };
ASSERT3S(g_refcount, >, 0);
VERIFY3S(g_fd, !=, -1);