<div dir="ltr">Hi Sam,<div><br></div><div>Thanks for the quick response!  I'll start work on a patch now.</div><div><br></div><div>GRUB2's manual discusses how to specify files here: <a href="http://www.gnu.org/software/grub/manual/grub.html#File-name-syntax">http://www.gnu.org/software/grub/manual/grub.html#File-name-syntax</a></div><div><br></div><div>The documentation for load_env ( <a href="http://www.gnu.org/software/grub/manual/grub.html#load_005fenv">http://www.gnu.org/software/grub/manual/grub.html#load_005fenv</a> ) does not specifically cite that discussion of how to specify files, but the code for load_env is here: <a href="http://git.savannah.gnu.org/cgit/grub.git/tree/grub-core/commands/loadenv.c#n163">http://git.savannah.gnu.org/cgit/grub.git/tree/grub-core/commands/loadenv.c#n163</a></div><div><br></div><div>If you trace open_envblk_file, you'll see that when there is a filename it just calls grub_file_open on filename, and grub_file_open has behavior as described in the manual: It looks for a device name in parentheses via grub_file_get_device_name ( <a href="http://git.savannah.gnu.org/cgit/grub.git/tree/grub-core/kern/file.c#n70">http://git.savannah.gnu.org/cgit/grub.git/tree/grub-core/kern/file.c#n70</a> ), selecting the device specified by root if there isn't one (in grub_device_open, <a href="http://git.savannah.gnu.org/cgit/grub.git/tree/grub-core/kern/device.c#n33">http://git.savannah.gnu.org/cgit/grub.git/tree/grub-core/kern/device.c#n33</a> ).  For the filename part outside of parentheses it uses file->fs->open, which, e.g., for ext2 comes down to grub_fshelp_find_file, which looks for an absolute path and iteratively looks up path pieces (in grub_fshelp_find_file_real, <a href="http://git.savannah.gnu.org/cgit/grub.git/tree/grub-core/fs/fshelp.c#n262">http://git.savannah.gnu.org/cgit/grub.git/tree/grub-core/fs/fshelp.c#n262</a> ).</div><div><br></div><div>Thanks,</div><div>- Alan</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jan 11, 2016 at 6:13 PM, Sam Mendoza-Jonas <span dir="ltr"><<a href="mailto:sam@mendozajonas.com" target="_blank">sam@mendozajonas.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Alan,<br>
<br>
Patches are always welcome! I'm happy to test such a change on my end.<br>
Do you have a link to the GRUB2 source/docs that mentions this behaviour?<br>
<br>
Thanks,<br>
Sam<br>
<div><div class="h5"><br>
On Mon, Jan 11, 2016 at 06:02:18PM -0800, Alan Dunn wrote:<br>
> Hi,<br>
><br>
> From my reading of the code (in particular,<br>
> <a href="http://git.kernel.org/cgit/linux/kernel/git/geoff/petitboot.git/tree/discover/grub2/env.c?id=106276d3d1bfae163828e111d6a8596104fba400#n81" rel="noreferrer" target="_blank">http://git.kernel.org/cgit/linux/kernel/git/geoff/petitboot.git/tree/discover/grub2/env.c?id=106276d3d1bfae163828e111d6a8596104fba400#n81</a><br>
> ) and experimentation, it looks like the current behavior of Petitboot's<br>
> GRUB2 config parser for "load_env -f <path>" is to always try and load an<br>
> environment file at "$prefix/<path>", with $prefix="" if unset.  However,<br>
> it seems like this is not the current behavior of GRUB2 (at least as of<br>
> GRUB2 2.02-beta2), which adds nothing to the path (from my reading of the<br>
> source and experimentation).<br>
><br>
> It looks like GRUB2 accepts only absolute paths, which can be<br>
> filesystem-prefixed (e.g. "(hd0,gpt1)/boot/grub/grub.cfg"), falling back to<br>
> the device specified by $root for the filesystem if none is specified, with<br>
> $root normally being set based on the value of $prefix.  It looks like<br>
> Petitboot by default doesn't set root, but it seems like we could at least<br>
> accommodate the important case where the configuration doesn't manually set<br>
> the value of root (by pretending that it points to the filesystem where the<br>
> configuration file is) pretty easily.<br>
><br>
> Would you folks be open to accepting a patch (that I will write) to put<br>
> Petitboot's behavior more in line with GRUB2 by eliminating the addition of<br>
> "$prefix/" in "load_env -f" and loading paths on the current filesystem<br>
> (and ensuring that this behavior is properly tested)?<br>
><br>
> Thanks,<br>
> - Alan<br>
<br>
</div></div>> _______________________________________________<br>
> Petitboot mailing list<br>
> <a href="mailto:Petitboot@lists.ozlabs.org">Petitboot@lists.ozlabs.org</a><br>
> <a href="https://lists.ozlabs.org/listinfo/petitboot" rel="noreferrer" target="_blank">https://lists.ozlabs.org/listinfo/petitboot</a><br>
<br>
</blockquote></div><br></div>