Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion include/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ COMMON_H = \
sys/zcp_set.h \
sys/zfeature.h \
sys/zfs_acl.h \
sys/zfs_bootenv.h \
sys/zfs_chksum.h \
sys/zfs_context.h \
sys/zfs_debug.h \
Expand Down
3 changes: 3 additions & 0 deletions include/libzfsbootenv.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

/*
* Copyright 2020 Toomas Soome <tsoome@me.com>
* Copyright (c) 2025, Rob Norris <robn@despairlabs.com>
*/

#ifndef _LIBZFSBOOTENV_H
Expand All @@ -36,6 +37,8 @@ _LIBZFSBOOTENV_H int lzbe_set_boot_device(const char *, lzbe_flags_t,
const char *);
_LIBZFSBOOTENV_H int lzbe_get_boot_device(const char *, char **);
_LIBZFSBOOTENV_H int lzbe_bootenv_print(const char *, const char *, FILE *);
_LIBZFSBOOTENV_H const char *lzbe_loader_get(void);
_LIBZFSBOOTENV_H int lzbe_loader_set(const char *, size_t);

#ifdef __cplusplus
}
Expand Down
1 change: 0 additions & 1 deletion include/os/freebsd/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ noinst_HEADERS = \
%D%/zfs/sys/freebsd_event.h \
%D%/zfs/sys/trace_zfs.h \
%D%/zfs/sys/vdev_os.h \
%D%/zfs/sys/zfs_bootenv_os.h \
%D%/zfs/sys/zfs_context_os.h \
%D%/zfs/sys/zfs_ctldir.h \
%D%/zfs/sys/zfs_debug_os.h \
Expand Down
30 changes: 0 additions & 30 deletions include/os/freebsd/zfs/sys/zfs_bootenv_os.h

This file was deleted.

1 change: 0 additions & 1 deletion include/os/linux/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ kernel_sys_HEADERS = \
%D%/zfs/sys/trace_zil.h \
%D%/zfs/sys/trace_zio.h \
%D%/zfs/sys/trace_zrlock.h \
%D%/zfs/sys/zfs_bootenv_os.h \
%D%/zfs/sys/zfs_context_os.h \
%D%/zfs/sys/zfs_ctldir.h \
%D%/zfs/sys/zfs_debug_os.h \
Expand Down
30 changes: 0 additions & 30 deletions include/os/linux/zfs/sys/zfs_bootenv_os.h

This file was deleted.

36 changes: 36 additions & 0 deletions include/sys/fs/zfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
* Copyright (c) 2021, Colm Buckley <colm@tuatha.org>
* Copyright (c) 2022 Hewlett Packard Enterprise Development LP.
* Copyright (c) 2024, Klara, Inc.
* Copyright (c) 2025, Rob Norris <robn@despairlabs.com>
*/

#ifndef _SYS_FS_ZFS_H
Expand Down Expand Up @@ -2003,6 +2004,41 @@ enum zio_encrypt {
ZFS_XA_NS_PREFIX_MATCH(LINUX_TRUSTED, name) || \
ZFS_XA_NS_PREFIX_MATCH(LINUX_USER, name))


/*
* Boot environment support. The vdev environment block is accessed with the
* ZFS_IOC_GET_BOOTENV and ZFS_IOC_SET_BOOTENV calls. libzfsbootenv uses these
* internally, and is the preferred way to work with boot environments, but
* these defines are provided here to assist bootloaders and tools that want to
* do their own thing.
*/

#define ZFS_BE_VERSION "version"
enum zfs_bootenv_version {
ZFS_BE_VERSION_GRUBENV = 0, /* GRUB "grubenv" file */
ZFS_BE_VERSION_NVLIST = 1, /* arbitrary packed nvlist */
};

/* nvlist key for GRUB "grubenv" string */
#define ZFS_BE_GRUB_ENVMAP "grub:envmap"

/*
* Keys in NVLIST bootenvs should be prefixed with a loader-specific string,
* allowing the envblock to support multiple loaders.
*
* This is the list of known loader prefixes.
*/
#define ZFS_BE_LOADER_FREEBSD "freebsd"
#define ZFS_BE_LOADER_ILLUMOS "illumos"

/*
* Common bootenv keys, to be combined with the loader prefix. New loaders are
* encouraged to use these where appropriate to assist cross-platform interop.
*/
#define ZFS_BE_BOOTONCE "bootonce"
#define ZFS_BE_BOOTONCE_USED "bootonce-used"
#define ZFS_BE_NVSTORE "nvstore"

#ifdef __cplusplus
}
#endif
Expand Down
20 changes: 0 additions & 20 deletions include/sys/vdev_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -503,26 +503,6 @@ typedef struct vdev_phys {
zio_eck_t vp_zbt;
} vdev_phys_t;

typedef enum vbe_vers {
/*
* 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 overridden by a variable, should
* the user so desire.
*/
VB_RAW = 0,

/*
* The bootenv file is converted to an nvlist and then packed into the
* envblock.
*/
VB_NVLIST = 1
} vbe_vers_t;

typedef struct vdev_boot_envblock {
uint64_t vbe_version;
char vbe_bootenv[VDEV_PAD_SIZE - sizeof (uint64_t) -
Expand Down
55 changes: 0 additions & 55 deletions include/sys/zfs_bootenv.h

This file was deleted.

4 changes: 2 additions & 2 deletions lib/libzfsbootenv/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ lib_LTLIBRARIES += libzfsbootenv.la
CPPCHECKTARGETS += libzfsbootenv.la

libzfsbootenv_la_CPPFLAGS = $(AM_CPPFLAGS)
libzfsbootenv_la_CPPFLAGS += -I$(srcdir)/include/os/@ac_system_l@/zfs

dist_libzfsbootenv_la_SOURCES = \
%D%/lzbe_device.c \
%D%/lzbe_loader.c \
%D%/lzbe_pair.c \
%D%/lzbe_util.c

Expand All @@ -22,7 +22,7 @@ if !ASAN_ENABLED
libzfsbootenv_la_LDFLAGS += -Wl,-z,defs
endif

libzfsbootenv_la_LDFLAGS += -version-info 1:0:0
libzfsbootenv_la_LDFLAGS += -version-info 2:0:1

pkgconfig_DATA += %D%/libzfsbootenv.pc

Expand Down
12 changes: 12 additions & 0 deletions lib/libzfsbootenv/libzfsbootenv.abi
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
<elf-symbol name='lzbe_add_pair' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
<elf-symbol name='lzbe_bootenv_print' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
<elf-symbol name='lzbe_get_boot_device' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
<elf-symbol name='lzbe_loader_get' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
<elf-symbol name='lzbe_loader_set' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
<elf-symbol name='lzbe_nvlist_free' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
<elf-symbol name='lzbe_nvlist_get' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
<elf-symbol name='lzbe_nvlist_set' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
Expand Down Expand Up @@ -225,6 +227,9 @@
<parameter type-id='857bb57e'/>
<return type-id='95e97e5e'/>
</function-decl>
<function-decl name='lzbe_loader_get' mangled-name='lzbe_loader_get' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='lzbe_loader_get'>
<return type-id='80f4b756'/>
</function-decl>
<function-decl name='nvlist_free' visibility='default' binding='global' size-in-bits='64'>
<parameter type-id='5ce45b60'/>
<return type-id='48b5725f'/>
Expand Down Expand Up @@ -314,6 +319,13 @@
<return type-id='95e97e5e'/>
</function-decl>
</abi-instr>
<abi-instr address-size='64' path='lib/libzfsbootenv/lzbe_loader.c' language='LANG_C99'>
<function-decl name='lzbe_loader_set' mangled-name='lzbe_loader_set' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='lzbe_loader_set'>
<parameter type-id='80f4b756' name='loader'/>
<parameter type-id='b59d7dce' name='len'/>
<return type-id='95e97e5e'/>
</function-decl>
</abi-instr>
<abi-instr address-size='64' path='lib/libzfsbootenv/lzbe_pair.c' language='LANG_C99'>
<type-decl name='short int' size-in-bits='16' id='a2185560'/>
<type-decl name='unsigned char' size-in-bits='8' id='002ac4a6'/>
Expand Down
Loading
Loading