mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 02:27:36 +03:00
OpenZFS 8264 - want support for promoting datasets in libzfs_core
Authored by: Andrew Stormont <astormont@racktopsystems.com> 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> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Ported-by: Giuseppe Di Natale <dinatale2@llnl.gov> OpenZFS-issue: https://www.illumos.org/issues/8264 OpenZFS-commit: https://github.com/openzfs/openzfs/commit/a4b8c9a Closes #6254
This commit is contained in:
committed by
Brian Behlendorf
parent
7517376f93
commit
d12f91fde3
@@ -23,6 +23,7 @@
|
||||
* Copyright (c) 2012, 2014 by Delphix. All rights reserved.
|
||||
* Copyright (c) 2013 Steven Hartland. All rights reserved.
|
||||
* Copyright (c) 2017 Datto Inc.
|
||||
* Copyright 2017 RackTop Systems.
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -206,6 +207,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.
|
||||
*
|
||||
@@ -333,7 +356,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"};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user