From c4ecba8aa5f13f00c2439c06af2aa1198771ee66 Mon Sep 17 00:00:00 2001 From: Paul Dagnelie Date: Fri, 7 Aug 2020 19:50:55 +0300 Subject: 13025 Port OpenZFS: Add support for boot environment data to be stored in the label Reviewed-by: Pavel Zakharov Reviewed-by: Matthew Ahrens Reviewed-by: Brian Behlendorf Reviewed-by: Toomas Soome Reviewed by: C Fraire Reviewed by: Andy Fiddaman Approved by: Dan McDonald --- usr/src/lib/libzfs_core/common/libzfs_core.c | 24 +++++++++++++++++++++++- usr/src/lib/libzfs_core/common/libzfs_core.h | 4 +++- usr/src/lib/libzfs_core/common/mapfile-vers | 7 +++++++ 3 files changed, 33 insertions(+), 2 deletions(-) (limited to 'usr/src/lib/libzfs_core') diff --git a/usr/src/lib/libzfs_core/common/libzfs_core.c b/usr/src/lib/libzfs_core/common/libzfs_core.c index 82d992f469..8b094fbd6a 100644 --- a/usr/src/lib/libzfs_core/common/libzfs_core.c +++ b/usr/src/lib/libzfs_core/common/libzfs_core.c @@ -20,7 +20,7 @@ */ /* - * Copyright (c) 2012, 2018 by Delphix. All rights reserved. + * Copyright (c) 2012, 2020 by Delphix. All rights reserved. * Copyright (c) 2013 Steven Hartland. All rights reserved. * Copyright (c) 2014 Integros [integros.com] * Copyright 2017 RackTop Systems. @@ -1354,3 +1354,25 @@ lzc_change_key(const char *fsname, uint64_t crypt_cmd, nvlist_t *props, nvlist_free(ioc_args); return (error); } + +/* + * Set the bootenv contents for the given pool. + */ +int +lzc_set_bootenv(const char *pool, const char *env) +{ + nvlist_t *args = fnvlist_alloc(); + fnvlist_add_string(args, "envmap", env); + int error = lzc_ioctl(ZFS_IOC_SET_BOOTENV, pool, args, NULL); + fnvlist_free(args); + return (error); +} + +/* + * Get the contents of the bootenv of the given pool. + */ +int +lzc_get_bootenv(const char *pool, nvlist_t **outnvl) +{ + return (lzc_ioctl(ZFS_IOC_GET_BOOTENV, pool, NULL, outnvl)); +} diff --git a/usr/src/lib/libzfs_core/common/libzfs_core.h b/usr/src/lib/libzfs_core/common/libzfs_core.h index 9b7721e7eb..f5a04b0762 100644 --- a/usr/src/lib/libzfs_core/common/libzfs_core.h +++ b/usr/src/lib/libzfs_core/common/libzfs_core.h @@ -20,7 +20,7 @@ */ /* - * Copyright (c) 2012, 2016 by Delphix. All rights reserved. + * Copyright (c) 2012, 2020 by Delphix. All rights reserved. * Copyright (c) 2014 Integros [integros.com] * Copyright 2017 RackTop Systems. * Copyright (c) 2017 Datto Inc. @@ -118,6 +118,8 @@ int lzc_channel_program_nosync(const char *, const char *, uint64_t, int lzc_pool_checkpoint(const char *); int lzc_pool_checkpoint_discard(const char *); +int lzc_set_bootenv(const char *, const char *); +int lzc_get_bootenv(const char *, nvlist_t **); #ifdef __cplusplus } #endif diff --git a/usr/src/lib/libzfs_core/common/mapfile-vers b/usr/src/lib/libzfs_core/common/mapfile-vers index 98516b66cc..bc4bc3631d 100644 --- a/usr/src/lib/libzfs_core/common/mapfile-vers +++ b/usr/src/lib/libzfs_core/common/mapfile-vers @@ -38,6 +38,13 @@ $mapfile_version 2 +SYMBOL_VERSION ILLUMOS_0.8 { + global: + + lzc_get_bootenv; + lzc_set_bootenv; +} ILLUMOS_0.7; + SYMBOL_VERSION ILLUMOS_0.7 { global: -- cgit v1.2.3