On Fri, Sep 05, 2025 at 10:24:58PM +0200, Daniel Kiper wrote: > On Tue, Sep 02, 2025 at 02:46:00PM +0800, Michael Chang via Grub-devel wrote: > > 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. > > Sorry, I do not understand that. Why do you use two environment blocks > instead of one? I think only one should be used. When env block is moved > to Brtfs bootloader block then environment file should be immediately > deleted from the filesystem.
The grubenv file is still used as it is the destination for grub-set-default, grub-reboot, and other commands that set and list environment variables via grub-editenv. The idea is that by introducing the env_block variable in the grubenv file, it can point to a writable device block via blocklist syntax that a patched grub.cfg may use to read and write settings in addition to the read-only grubenv file at grub runtime. It is not intended to replace the grubenv file, but rather to extend it to provide a static RW block for filesystems like btrfs, in order to workaround cases such as grub-reboot and savedefault that requires a writable envblk to work. > > > Signed-off-by: Michael Chang <[email protected]> > > Reviewed-by: Neal Gompa <[email protected]> > > --- > > util/grub-editenv.c | 55 +++++++++++++++++++++++++++++++++++++++++++-- > > 1 file changed, 53 insertions(+), 2 deletions(-) > > > > diff --git a/util/grub-editenv.c b/util/grub-editenv.c > > index a319d01b7..ca3787c98 100644 > > --- a/util/grub-editenv.c > > +++ b/util/grub-editenv.c > > @@ -391,12 +391,33 @@ fs_envblk_write (grub_envblk_t envblk) > > fclose (fp); > > } > > > > +struct var_lookup_ctx { > > + const char *varname; > > + int found; > > bool please... OK. Thanks, Michael > > Daniel _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
