forked from pool/grub2
67 lines
2.4 KiB
Diff
67 lines
2.4 KiB
Diff
|
From f01314a822dbe9ad39b2f7d0f3717ef6e4c24f4a Mon Sep 17 00:00:00 2001
|
||
|
From: Michael Chang <mchang@suse.com>
|
||
|
Date: Fri, 15 Apr 2022 21:45:04 +0800
|
||
|
Subject: [PATCH 2/2] Mark environmet blocks as used for image embedding.
|
||
|
|
||
|
Now that grub will attempt to use full btrfs bootloader area, the
|
||
|
embedded image could have overlapped with environment blocks if it's
|
||
|
size grows too much. Let's define a dedicated area for environment
|
||
|
blocks to the used block mappings for the embedding process so it can be
|
||
|
skipped.
|
||
|
|
||
|
Signed-off-by: Michael Chang <mchang@suse.com>
|
||
|
---
|
||
|
grub-core/fs/btrfs.c | 3 ++-
|
||
|
include/grub/fs.h | 2 ++
|
||
|
util/grub-editenv.c | 2 +-
|
||
|
3 files changed, 5 insertions(+), 2 deletions(-)
|
||
|
|
||
|
diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c
|
||
|
index 979ba1b28..7017248d1 100644
|
||
|
--- a/grub-core/fs/btrfs.c
|
||
|
+++ b/grub-core/fs/btrfs.c
|
||
|
@@ -2551,7 +2551,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 = {
|
||
|
@@ -2559,6 +2559,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. */
|
||
|
}
|
||
|
diff --git a/include/grub/fs.h b/include/grub/fs.h
|
||
|
index 026bc3bb8..4c380e334 100644
|
||
|
--- a/include/grub/fs.h
|
||
|
+++ b/include/grub/fs.h
|
||
|
@@ -128,4 +128,6 @@ grub_fs_unregister (grub_fs_t fs)
|
||
|
|
||
|
grub_fs_t EXPORT_FUNC(grub_fs_probe) (grub_device_t device);
|
||
|
|
||
|
+#define ENV_BTRFS_OFFSET (256)
|
||
|
+
|
||
|
#endif /* ! GRUB_FS_HEADER */
|
||
|
diff --git a/util/grub-editenv.c b/util/grub-editenv.c
|
||
|
index a02d3f2a6..af30aabe7 100644
|
||
|
--- a/util/grub-editenv.c
|
||
|
+++ b/util/grub-editenv.c
|
||
|
@@ -128,7 +128,7 @@ struct fs_envblk_spec {
|
||
|
int offset;
|
||
|
int size;
|
||
|
} fs_envblk_spec[] = {
|
||
|
- { "btrfs", 256 * 1024, GRUB_DISK_SECTOR_SIZE },
|
||
|
+ { "btrfs", ENV_BTRFS_OFFSET * 1024, GRUB_DISK_SECTOR_SIZE },
|
||
|
{ NULL, 0, 0 }
|
||
|
};
|
||
|
|
||
|
--
|
||
|
2.35.3
|
||
|
|