diff options
author | Matthew Ahrens <[email protected]> | 2013-08-14 11:42:31 -0800 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2013-11-05 12:23:11 -0800 |
commit | 46ba1e59d3ae7e374c7a98f15f4bef21ee3fcded (patch) | |
tree | 4088708419ecbaf33afbe3e9bb9e2f0aedebdf6d /lib/libzfs_core | |
parent | 5d1f7fb647e8923d154901ef3e19676e7bf3d345 (diff) |
Illumos #3996
3996 want a libzfs_core API to rollback to latest snapshot
Reviewed by: Christopher Siden <[email protected]>
Reviewed by: Adam Leventhal <[email protected]>
Reviewed by: George Wilson <[email protected]>
Reviewed by: Andy Stormont <[email protected]>
Approved by: Richard Lowe <[email protected]>
References:
https://www.illumos.org/issues/3996
illumos/illumos-gate@a7027df17fad220a20367b9d1eb251bc6300d203
Ported-by: Richard Yao <[email protected]>
Signed-off-by: Brian Behlendorf <[email protected]>
Issue #1775
Diffstat (limited to 'lib/libzfs_core')
-rw-r--r-- | lib/libzfs_core/libzfs_core.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/lib/libzfs_core/libzfs_core.c b/lib/libzfs_core/libzfs_core.c index 53c813d4a..3befa4d84 100644 --- a/lib/libzfs_core/libzfs_core.c +++ b/lib/libzfs_core/libzfs_core.c @@ -20,7 +20,7 @@ */ /* - * Copyright (c) 2012 by Delphix. All rights reserved. + * Copyright (c) 2013 by Delphix. All rights reserved. * Copyright (c) 2013 Steven Hartland. All rights reserved. */ @@ -581,3 +581,27 @@ out: free((void*)(uintptr_t)zc.zc_nvlist_dst); return (error); } + +/* + * Roll back this filesystem or volume to its most recent snapshot. + * If snapnamebuf is not NULL, it will be filled in with the name + * of the most recent snapshot. + * + * Return 0 on success or an errno on failure. + */ +int +lzc_rollback(const char *fsname, char *snapnamebuf, int snapnamelen) +{ + nvlist_t *args; + nvlist_t *result; + int err; + + args = fnvlist_alloc(); + err = lzc_ioctl(ZFS_IOC_ROLLBACK, fsname, args, &result); + nvlist_free(args); + if (err == 0 && snapnamebuf != NULL) { + const char *snapname = fnvlist_lookup_string(result, "target"); + (void) strlcpy(snapnamebuf, snapname, snapnamelen); + } + return (err); +} |