This patch reserves space for the GRUB environment block inside the Btrfs header. The block is placed at an offset of 256 KiB from the start of the device and occupies one sector. To protect the space, overflow guard sectors are placed before and after the reserved block.
The Btrfs header already defines regions for bootloader use. By adding this entry, GRUB gains a fixed and safe location to store the environment block without conflicting with other structures in the header. Signed-off-by: Michael Chang <[email protected]> Reviewed-by: Neal Gompa <[email protected]> --- grub-core/fs/btrfs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c index 7bf8d922f..ceacc1151 100644 --- a/grub-core/fs/btrfs.c +++ b/grub-core/fs/btrfs.c @@ -2341,7 +2341,7 @@ struct embed_region { static const struct { struct embed_region available; - struct embed_region used[6]; + struct embed_region used[7]; } btrfs_head = { .available = {0, GRUB_DISK_KiB_TO_SECTORS (1024)}, /* The first 1 MiB. */ .used = { @@ -2349,6 +2349,7 @@ static const struct { {GRUB_DISK_KiB_TO_SECTORS (64) - 1, 1}, /* Overflow guard. */ {GRUB_DISK_KiB_TO_SECTORS (64), GRUB_DISK_KiB_TO_SECTORS (4)}, /* 4 KiB superblock. */ {GRUB_DISK_KiB_TO_SECTORS (68), 1}, /* Overflow guard. */ + {GRUB_DISK_KiB_TO_SECTORS (ENV_BTRFS_OFFSET) - 1, 3}, /* Environment Block. */ {GRUB_DISK_KiB_TO_SECTORS (1024) - 1, 1}, /* Overflow guard. */ {0, 0} /* Array terminator. */ } -- 2.50.1 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
