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:
@@ -15,6 +15,7 @@ USER_H = \
|
||||
libuutil.h \
|
||||
libuutil_impl.h \
|
||||
libzfs.h \
|
||||
libzfsbootenv.h \
|
||||
libzfs_core.h \
|
||||
libzfs_impl.h \
|
||||
libzutil.h \
|
||||
|
||||
+2
-2
@@ -892,8 +892,8 @@ extern int zpool_in_use(libzfs_handle_t *, int, pool_state_t *, char **,
|
||||
* Label manipulation.
|
||||
*/
|
||||
extern int zpool_clear_label(int);
|
||||
extern int zpool_set_bootenv(zpool_handle_t *, const char *);
|
||||
extern int zpool_get_bootenv(zpool_handle_t *, char *, size_t, off_t);
|
||||
extern int zpool_set_bootenv(zpool_handle_t *, const nvlist_t *);
|
||||
extern int zpool_get_bootenv(zpool_handle_t *, nvlist_t **);
|
||||
|
||||
/*
|
||||
* Management interfaces for SMB ACL files
|
||||
|
||||
@@ -135,7 +135,7 @@ int lzc_wait(const char *, zpool_wait_activity_t, boolean_t *);
|
||||
int lzc_wait_tag(const char *, zpool_wait_activity_t, uint64_t, boolean_t *);
|
||||
int lzc_wait_fs(const char *, zfs_wait_activity_t, boolean_t *);
|
||||
|
||||
int lzc_set_bootenv(const char *, const char *);
|
||||
int lzc_set_bootenv(const char *, const nvlist_t *);
|
||||
int lzc_get_bootenv(const char *, nvlist_t **);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* 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 _LIBZFSBOOTENV_H
|
||||
#define _LIBZFSBOOTENV_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum lzbe_flags {
|
||||
lzbe_add, /* add data to existing nvlist */
|
||||
lzbe_replace /* replace current nvlist */
|
||||
} lzbe_flags_t;
|
||||
|
||||
extern int lzbe_nvlist_get(const char *, const char *, void **);
|
||||
extern int lzbe_nvlist_set(const char *, const char *, void *);
|
||||
extern void lzbe_nvlist_free(void *);
|
||||
extern int lzbe_add_pair(void *, const char *, const char *, void *, size_t);
|
||||
extern int lzbe_remove_pair(void *, const char *);
|
||||
extern int lzbe_set_boot_device(const char *, lzbe_flags_t, const char *);
|
||||
extern int lzbe_get_boot_device(const char *, char **);
|
||||
extern int lzbe_bootenv_print(const char *, const char *, FILE *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _LIBZFSBOOTENV_H */
|
||||
@@ -2,6 +2,7 @@ KERNEL_H = \
|
||||
freebsd_crypto.h \
|
||||
sha2.h \
|
||||
vdev_os.h \
|
||||
zfs_bootenv_os.h \
|
||||
zfs_context_os.h \
|
||||
zfs_ctldir.h \
|
||||
zfs_dir.h \
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* 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_OS_H
|
||||
#define _ZFS_BOOTENV_OS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define BOOTENV_OS BE_FREEBSD_VENDOR
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _ZFS_BOOTENV_OS_H */
|
||||
@@ -16,6 +16,7 @@ KERNEL_H = \
|
||||
trace_zil.h \
|
||||
trace_zio.h \
|
||||
trace_zrlock.h \
|
||||
zfs_bootenv_os.h \
|
||||
zfs_context_os.h \
|
||||
zfs_ctldir.h \
|
||||
zfs_dir.h \
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* 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_OS_H
|
||||
#define _ZFS_BOOTENV_OS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define BOOTENV_OS BE_LINUX_VENDOR
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _ZFS_BOOTENV_OS_H */
|
||||
@@ -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 \
|
||||
|
||||
@@ -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
@@ -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
@@ -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,
|
||||
|
||||
/*
|
||||
|
||||
@@ -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 */
|
||||
Reference in New Issue
Block a user