mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-24 19:28:53 +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:
+10
-12
@@ -3511,30 +3511,29 @@ zfs_ioc_log_history(const char *unused, nvlist_t *innvl, nvlist_t *outnvl)
|
||||
/*
|
||||
* This ioctl is used to set the bootenv configuration on the current
|
||||
* pool. This configuration is stored in the second padding area of the label,
|
||||
* and it is used by the GRUB bootloader used on Linux to store the contents
|
||||
* of the grubenv file. The file is stored as raw ASCII, and is protected by
|
||||
* an embedded checksum. By default, GRUB will check if the boot filesystem
|
||||
* supports storing the environment data in a special location, and if so,
|
||||
* will invoke filesystem specific logic to retrieve it. This can be overridden
|
||||
* by a variable, should the user so desire.
|
||||
* and it is used by the bootloader(s) to store the bootloader and/or system
|
||||
* specific data.
|
||||
* The data is stored as nvlist data stream, and is protected by
|
||||
* an embedded checksum.
|
||||
* The version can have two possible values:
|
||||
* VB_RAW: nvlist should have key GRUB_ENVMAP, value DATA_TYPE_STRING.
|
||||
* VB_NVLIST: nvlist with arbitrary <key, value> pairs.
|
||||
*/
|
||||
/* ARGSUSED */
|
||||
static const zfs_ioc_key_t zfs_keys_set_bootenv[] = {
|
||||
{"envmap", DATA_TYPE_STRING, 0},
|
||||
{"version", DATA_TYPE_UINT64, 0},
|
||||
{"<keys>", DATA_TYPE_ANY, ZK_OPTIONAL | ZK_WILDCARDLIST},
|
||||
};
|
||||
|
||||
static int
|
||||
zfs_ioc_set_bootenv(const char *name, nvlist_t *innvl, nvlist_t *outnvl)
|
||||
{
|
||||
char *envmap;
|
||||
int error;
|
||||
spa_t *spa;
|
||||
|
||||
envmap = fnvlist_lookup_string(innvl, "envmap");
|
||||
if ((error = spa_open(name, &spa, FTAG)) != 0)
|
||||
return (error);
|
||||
spa_vdev_state_enter(spa, SCL_ALL);
|
||||
error = vdev_label_write_bootenv(spa->spa_root_vdev, envmap);
|
||||
error = vdev_label_write_bootenv(spa->spa_root_vdev, innvl);
|
||||
(void) spa_vdev_state_exit(spa, NULL, 0);
|
||||
spa_close(spa, FTAG);
|
||||
return (error);
|
||||
@@ -3544,7 +3543,6 @@ static const zfs_ioc_key_t zfs_keys_get_bootenv[] = {
|
||||
/* no nvl keys */
|
||||
};
|
||||
|
||||
/* ARGSUSED */
|
||||
static int
|
||||
zfs_ioc_get_bootenv(const char *name, nvlist_t *innvl, nvlist_t *outnvl)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user