Le mar. 15 oct. 2024, 08:24, Michael Chang via Grub-devel < grub-devel@gnu.org> a écrit :
> On Thu, Oct 10, 2024 at 03:43:26PM GMT, Leo Sandoval wrote: > > From: Paulo Flabiano Smorigo <pfsmor...@br.ibm.com> > > > > This patch makes grub look for its config file on efi where the app was > > found. It was originally written by Matthew Garrett, and adapted to fix > the > > "No modules are loaded on grub2 network boot" issue: > > > > https://bugzilla.redhat.com/show_bug.cgi?id=857936 > > > > Signed-off-by: Paulo Flabiano Smorigo <pfsmor...@br.ibm.com> > > Signed-off-by: Robbie Harwood <rharw...@redhat.com> > > --- > > grub-core/kern/main.c | 13 ++++++------- > > grub-core/normal/main.c | 25 ++++++++++++++++++++++++- > > 2 files changed, 30 insertions(+), 8 deletions(-) > > > > diff --git a/grub-core/kern/main.c b/grub-core/kern/main.c > > index 731c07c29..463dafdba 100644 > > --- a/grub-core/kern/main.c > > +++ b/grub-core/kern/main.c > > @@ -128,16 +128,15 @@ grub_set_prefix_and_root (void) > > > > grub_machine_get_bootlocation (&fwdevice, &fwpath); > > > > - if (fwdevice) > > + if (fwdevice && fwpath) > > { > > - char *cmdpath; > > + char *fw_path; > > > > - cmdpath = grub_xasprintf ("(%s)%s", fwdevice, fwpath ? : ""); > > - if (cmdpath) > > + fw_path = grub_xasprintf ("(%s)/%s", fwdevice, fwpath); > > + if (fw_path) > > { > > - grub_env_set ("cmdpath", cmdpath); > > - grub_env_export ("cmdpath"); > > - grub_free (cmdpath); > > + grub_env_set ("fw_path", fw_path); > > + grub_free (fw_path); > > > I believe $cmdpath is an important and well-known public variable. It is > officially documented [1], and therefore, it shouldn't be removed or > renamed without formal notice. > > A quick google search [2] shows many references to $cmdpath, and many > custom grub scripts would rely on it to function properly. > My thoughts exactly. I totally agree. > > IMHO removing or renaming it would introduce a breaking change. Adding > $fw_path would be fine, but it's unclear to me why that would be > necessary either. > > [1] > https://www.gnu.org/software/grub/manual/grub/html_node/cmdpath.html > > [2] > https://wiki.archlinux.org/title/GRUB/Tips_and_tricks > > https://superuser.com/questions/1757526/get-device-part-of-a-file-path-within-grub-cfg > > https://github.com/opencomputeproject/onie/blob/master/build-config/scripts/mk-grub-efi-image > > https://stackoverflow.com/questions/35269943/how-does-the-grub-2-uefi-loader-know-where-to-look-for-the-configuration-file-o > > Thanks, > Michael > > > } > > } > > > > diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c > > index d3f53d93d..08f48c71d 100644 > > --- a/grub-core/normal/main.c > > +++ b/grub-core/normal/main.c > > @@ -339,7 +339,30 @@ grub_cmd_normal (struct grub_command *cmd > __attribute__ ((unused)), > > /* Guess the config filename. It is necessary to make CONFIG > static, > > so that it won't get broken by longjmp. */ > > char *config; > > - const char *prefix; > > + const char *prefix, *fw_path; > > + > > + fw_path = grub_env_get ("fw_path"); > > + if (fw_path) > > + { > > + config = grub_xasprintf ("%s/grub.cfg", fw_path); > > + if (config) > > + { > > + grub_file_t file; > > + > > + file = grub_file_open (config, GRUB_FILE_TYPE_CONFIG); > > + if (file) > > + { > > + grub_file_close (file); > > + grub_enter_normal_mode (config); > > + } > > + else > > + { > > + /* Ignore all errors. */ > > + grub_errno = 0; > > + } > > + grub_free (config); > > + } > > + } > > > > prefix = grub_env_get ("prefix"); > > if (prefix) > > -- > > 2.46.2 > > > > > > _______________________________________________ > > Grub-devel mailing list > > Grub-devel@gnu.org > > https://lists.gnu.org/mailman/listinfo/grub-devel > > _______________________________________________ > Grub-devel mailing list > Grub-devel@gnu.org > https://lists.gnu.org/mailman/listinfo/grub-devel >
_______________________________________________ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel