diff options
author | mav <mav@FreeBSD.org> | 2017-07-26 17:47:32 +0000 |
---|---|---|
committer | mav <mav@FreeBSD.org> | 2017-07-26 17:47:32 +0000 |
commit | b79e0da0b87c94d2610b0d01035daec18290ee1a (patch) | |
tree | 37638980841857472fd62ed62a0bd2d589b883de /cddl/contrib/opensolaris/lib/libzfs_core | |
parent | 78f81155586a3c13ffa08a56376a762a179f0005 (diff) | |
download | FreeBSD-src-b79e0da0b87c94d2610b0d01035daec18290ee1a.zip FreeBSD-src-b79e0da0b87c94d2610b0d01035daec18290ee1a.tar.gz |
MFC r319947: MFV r319945,r319946: 8264 want support for promoting datasets in libzfs_core
illumos/illumos-gate@a4b8c9aa65a0a735aba318024a424a90d7b06c37
https://github.com/illumos/illumos-gate/commit/a4b8c9aa65a0a735aba318024a424a90d7b06c37
https://www.illumos.org/issues/8264
Oddly there is a lzc_clone function, but no lzc_promote function.
Reviewed by: Andriy Gapon <avg@FreeBSD.org>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Dan McDonald <danmcd@kebe.com>
Approved by: Dan McDonald <danmcd@kebe.com>
Author: Andrew Stormont <astormont@racktopsystems.com>
Diffstat (limited to 'cddl/contrib/opensolaris/lib/libzfs_core')
-rw-r--r-- | cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core.c | 25 | ||||
-rw-r--r-- | cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core.h | 2 |
2 files changed, 26 insertions, 1 deletions
diff --git a/cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core.c b/cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core.c index 9e4e882..27a4144 100644 --- a/cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core.c +++ b/cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core.c @@ -23,6 +23,7 @@ * 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. */ /* @@ -244,6 +245,28 @@ lzc_clone(const char *fsname, const char *origin, 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) { + int error = errno; + if (error == EEXIST && snapnamebuf != NULL) + (void) strlcpy(snapnamebuf, zc.zc_string, snapnamelen); + return (error); + } + return (0); +} + /* * Creates snapshots. * @@ -371,7 +394,7 @@ 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(). + * own zfs_cmd_t rather than using lzc_ioctl(). */ zfs_cmd_t zc = { 0 }; diff --git a/cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core.h b/cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core.h index 8f19294..fd18d5f 100644 --- a/cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core.h +++ b/cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core.h @@ -22,6 +22,7 @@ /* * Copyright (c) 2012, 2014 by Delphix. All rights reserved. * Copyright (c) 2013 by Martin Matuska <mm@FreeBSD.org>. All rights reserved. + * Copyright 2017 RackTop Systems. */ #ifndef _LIBZFS_CORE_H @@ -49,6 +50,7 @@ enum lzc_dataset_type { int lzc_snapshot(nvlist_t *, nvlist_t *, nvlist_t **); int lzc_create(const char *, enum lzc_dataset_type, nvlist_t *); int lzc_clone(const char *, const char *, nvlist_t *); +int lzc_promote(const char *, char *, int); int lzc_destroy_snaps(nvlist_t *, boolean_t, nvlist_t **); int lzc_bookmark(nvlist_t *, nvlist_t **); int lzc_get_bookmarks(const char *, nvlist_t *, nvlist_t **); |