]> git.ipfire.org Git - thirdparty/grub.git/commit
util/grub-editenv: Wire set_variables() to optional fs_envblk
authorMichael Chang <mchang@suse.com>
Fri, 17 Oct 2025 09:01:36 +0000 (17:01 +0800)
committerDaniel Kiper <daniel.kiper@oracle.com>
Thu, 23 Oct 2025 17:15:01 +0000 (19:15 +0200)
commitc7c901916564d4288a1b4e763705e80a164bf02a
tree48aa7cfa9584a348d31f69a55516a1bbd916c5a8
parent2abdd8cd21c93de45d0ee4a3f6d68910fa6b2cb3
util/grub-editenv: Wire set_variables() to optional fs_envblk

This patch changes set_variables() so that it can use an external
environment block when one is present. The variable next_entry is
written into the external block, env_block is treated as read only, and
all other variables are written into the normal file based envblk.

A cleanup step is added to handle cases where GRUB at runtime writes
variables into the external block because file based updates are not
safe on a copy on write filesystem such as Btrfs. For example, the
savedefault command can update saved_entry, and on Btrfs GRUB will place
that update in the external block instead of the file envblk. If an
older copy remains in the external block, it would override the newer
value from the file envblk when GRUB first loads the file and then
applies the external block on top of it. To avoid this, whenever
a variable is updated in the file envblk, any same named key in
the external block is deleted.

Signed-off-by: Michael Chang <mchang@suse.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Avnish Chouhan <avnish@linux.ibm.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
util/grub-editenv.c