mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 02:27:36 +03:00
zfs label bootenv should store data as nvlist
nvlist does allow us to support different data types and systems. To encapsulate user data to/from nvlist, the libzfsbootenv library is provided. Reviewed-by: Arvind Sankar <nivedita@alum.mit.edu> Reviewed-by: Allan Jude <allan@klarasystems.com> Reviewed-by: Paul Dagnelie <pcd@delphix.com> Reviewed-by: Igor Kozhukhov <igor@dilos.org> Signed-off-by: Toomas Soome <tsoome@me.com> Closes #10774
This commit is contained in:
committed by
Brian Behlendorf
parent
c8bbb0c93d
commit
84d9492e52
+10
-14
@@ -4495,7 +4495,7 @@ zpool_wait_status(zpool_handle_t *zhp, zpool_wait_activity_t activity,
|
||||
}
|
||||
|
||||
int
|
||||
zpool_set_bootenv(zpool_handle_t *zhp, const char *envmap)
|
||||
zpool_set_bootenv(zpool_handle_t *zhp, const nvlist_t *envmap)
|
||||
{
|
||||
int error = lzc_set_bootenv(zhp->zpool_name, envmap);
|
||||
if (error != 0) {
|
||||
@@ -4508,24 +4508,20 @@ zpool_set_bootenv(zpool_handle_t *zhp, const char *envmap)
|
||||
}
|
||||
|
||||
int
|
||||
zpool_get_bootenv(zpool_handle_t *zhp, char *outbuf, size_t size, off_t offset)
|
||||
zpool_get_bootenv(zpool_handle_t *zhp, nvlist_t **nvlp)
|
||||
{
|
||||
nvlist_t *nvl = NULL;
|
||||
int error = lzc_get_bootenv(zhp->zpool_name, &nvl);
|
||||
nvlist_t *nvl;
|
||||
int error;
|
||||
|
||||
nvl = NULL;
|
||||
error = lzc_get_bootenv(zhp->zpool_name, &nvl);
|
||||
if (error != 0) {
|
||||
(void) zpool_standard_error_fmt(zhp->zpool_hdl, error,
|
||||
dgettext(TEXT_DOMAIN,
|
||||
"error getting bootenv in pool '%s'"), zhp->zpool_name);
|
||||
return (-1);
|
||||
}
|
||||
char *envmap = fnvlist_lookup_string(nvl, "envmap");
|
||||
if (offset >= strlen(envmap)) {
|
||||
fnvlist_free(nvl);
|
||||
return (0);
|
||||
} else {
|
||||
*nvlp = nvl;
|
||||
}
|
||||
|
||||
strncpy(outbuf, envmap + offset, size);
|
||||
int bytes = MIN(strlen(envmap + offset), size);
|
||||
fnvlist_free(nvl);
|
||||
return (bytes);
|
||||
return (error);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user