On Mon, Oct 13, 2025 at 02:32:18PM +0200, Daniel Kiper wrote:
> On Mon, Oct 13, 2025 at 01:39:37PM +0200, Daniel Kiper wrote:
> > On Thu, Oct 09, 2025 at 03:18:37PM +0800, Michael Chang via Grub-devel 
> > wrote:
> > > This patch prepares for using an environment block stored in a reserved
> > > area of the filesystem. It uses constant GRUB_ENV_BTRFS_OFFSET at 256
> > > KiB in the Btrfs header. It also introduces the fs_envblk_spec and
> > > fs_envblk structures together with the probe_fs_envblk function to
> > > identify the root filesystem and to avoid configurations that involve
> > > diskfilter or cryptodisk.
> > >
> > > The probe is only invoked when grub-editenv is working on the default
> > > environment file path. This restriction ensures that probing and
> > > possible raw device access are not triggered for arbitrary user supplied
> > > paths, but only for the standard grubenv file. In that case the code
> > > checks if the filename equals DEFAULT_ENVBLK_PATH and then calls
> > > probe_fs_envblk with fs_envblk_spec. The result is stored in the global
> > > fs_envblk handle. At this stage the external environment block is only
> > > detected and recorded, and the behavior of grub-editenv is unchanged.
> > >
> > > Signed-off-by: Michael Chang <[email protected]>
> > > Reviewed-by: Neal Gompa <[email protected]>
> > > Reviewed-by: Avnish Chouhan <[email protected]>
> > > ---
> > >  util/grub-editenv.c | 164 +++++++++++++++++++++++++++++++++++++++++++-
> > >  1 file changed, 163 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/util/grub-editenv.c b/util/grub-editenv.c
> > > index db6f187cc..e650cbcd0 100644
> > > --- a/util/grub-editenv.c
> > > +++ b/util/grub-editenv.c
> > > @@ -23,8 +23,11 @@
> > >  #include <grub/util/misc.h>
> > >  #include <grub/lib/envblk.h>
> > >  #include <grub/i18n.h>
> > > -#include <grub/emu/hostfile.h>
> > > +#include <grub/emu/hostdisk.h>
> > >  #include <grub/util/install.h>
> > > +#include <grub/emu/getroot.h>
> > > +#include <grub/fs.h>
> > > +#include <grub/crypto.h>
> > >
> > >  #include <stdio.h>
> > >  #include <unistd.h>
> > > @@ -120,6 +123,36 @@ block, use `rm %s'."),
> > >    NULL, help_filter, NULL
> > >  };
> > >
> > > +struct fs_envblk_spec {
> > > +  const char *fs_name;
> > > +  off_t offset;
> > > +  size_t size;
> > > +};
> > > +typedef struct fs_envblk_spec fs_envblk_spec_t;
> > > +
> > > +struct fs_envblk {
> > > +  fs_envblk_spec_t *spec;
> > > +  const char *dev;
> > > +};
> > > +typedef struct fs_envblk *fs_envblk_t;
> > > +
> > > +/*
> > > + * fs_envblk_spec describes the file-system specific layout of reserved 
> > > raw
> > > + * blocks used as environment blocks. At present only Btrfs is 
> > > supported. Other
> > > + * file-systems may be added if they provide a similar facility and 
> > > avoid the
> > > + * limitation of writing to COW.
> > > + *
> > > + * Note: If this table is modified, also update
> > > + * grub-core/fs/btrfs.c::btrfs_head, which defines the layout in the 
> > > Btrfs
> > > + * header and exports GRUB_ENV_BTRFS_OFFSET, so that both stay 
> > > consistent.
> > > + */
> > > +static fs_envblk_spec_t fs_envblk_spec[] = {
> > > +  { "btrfs", GRUB_ENV_BTRFS_OFFSET, GRUB_DISK_SECTOR_SIZE },
> >
> > Again, this change does not belong to this patch. It should be merged
> > with patch #3. Then then patch #3 should be moved behind patch #9.
> >
> > Otherwise patch LGTM...
> 
> You can add my RB to all patches except #3 and this one...

OK. Will do in next version.

Thanks,
Michael

> 
> Daniel

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to