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:
Toomas Soome
2020-09-16 01:42:27 +03:00
committed by Brian Behlendorf
parent c8bbb0c93d
commit 84d9492e52
29 changed files with 886 additions and 68 deletions
+1
View File
@@ -102,6 +102,7 @@ COMMON_H = \
zcp_set.h \
zfeature.h \
zfs_acl.h \
zfs_bootenv.h \
zfs_context.h \
zfs_debug.h \
zfs_delay.h \
+2 -2
View File
@@ -1336,8 +1336,8 @@ typedef enum zfs_ioc {
ZFS_IOC_NEXTBOOT, /* 0x84 (FreeBSD) */
ZFS_IOC_JAIL, /* 0x85 (FreeBSD) */
ZFS_IOC_UNJAIL, /* 0x86 (FreeBSD) */
ZFS_IOC_SET_BOOTENV, /* 0x87 (Linux) */
ZFS_IOC_GET_BOOTENV, /* 0x88 (Linux) */
ZFS_IOC_SET_BOOTENV, /* 0x87 */
ZFS_IOC_GET_BOOTENV, /* 0x88 */
ZFS_IOC_LAST
} zfs_ioc_t;
+1 -1
View File
@@ -181,7 +181,7 @@ extern void vdev_config_generate_stats(vdev_t *vd, nvlist_t *nv);
extern void vdev_label_write(zio_t *zio, vdev_t *vd, int l, abd_t *buf, uint64_t
offset, uint64_t size, zio_done_func_t *done, void *priv, int flags);
extern int vdev_label_read_bootenv(vdev_t *, nvlist_t *);
extern int vdev_label_write_bootenv(vdev_t *, char *);
extern int vdev_label_write_bootenv(vdev_t *, nvlist_t *);
typedef enum {
VDEV_LABEL_CREATE, /* create/add a new device */
+10 -1
View File
@@ -476,7 +476,16 @@ typedef struct vdev_phys {
} vdev_phys_t;
typedef enum vbe_vers {
/* The bootenv file is stored as ascii text in the envblock */
/*
* The bootenv file is stored as ascii text in the envblock.
* 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 overriden by a variable, should
* the user so desire.
*/
VB_RAW = 0,
/*
+53
View File
@@ -0,0 +1,53 @@
/*
* This file and its contents are supplied under the terms of the
* Common Development and Distribution License ("CDDL"), version 1.0.
* You may only use this file in accordance with the terms of version
* 1.0 of the CDDL.
*
* A full copy of the text of the CDDL should have accompanied this
* source. A copy of the CDDL is also available via the Internet at
* http://www.illumos.org/license/CDDL.
*/
/*
* Copyright 2020 Toomas Soome <tsoome@me.com>
*/
#ifndef _ZFS_BOOTENV_H
#define _ZFS_BOOTENV_H
/*
* Define macros for label bootenv nvlist pair keys.
*/
#ifdef __cplusplus
extern "C" {
#endif
#define BOOTENV_VERSION "version"
#define BE_ILLUMOS_VENDOR "illumos"
#define BE_FREEBSD_VENDOR "freebsd"
#define BE_GRUB_VENDOR "grub"
#define BE_LINUX_VENDOR "linux"
#include <sys/zfs_bootenv_os.h>
#define GRUB_ENVMAP BE_GRUB_VENDOR ":" "envmap"
#define FREEBSD_BOOTONCE BE_FREEBSD_VENDOR ":" "bootonce"
#define FREEBSD_BOOTONCE_USED BE_FREEBSD_VENDOR ":" "bootonce-used"
#define FREEBSD_NVSTORE BE_FREEBSD_VENDOR ":" "nvstore"
#define ILLUMOS_BOOTONCE BE_ILLUMOS_VENDOR ":" "bootonce"
#define ILLUMOS_BOOTONCE_USED BE_ILLUMOS_VENDOR ":" "bootonce-used"
#define ILLUMOS_NVSTORE BE_ILLUMOS_VENDOR ":" "nvstore"
#define OS_BOOTONCE BOOTENV_OS ":" "bootonce"
#define OS_BOOTONCE_USED BOOTENV_OS ":" "bootonce-used"
#define OS_NVSTORE BOOTENV_OS ":" "nvstore"
#ifdef __cplusplus
}
#endif
#endif /* _ZFS_BOOTENV_H */