This is needed to boot Solaris/Illumos on some boot paths that need quotes.
Signed-off-by: Vladimir Serbinenko <phco...@gmail.com> --- grub-core/loader/i386/multiboot_mbi.c | 13 ++++---- grub-core/loader/multiboot.c | 46 ++++++++++++++++++++------- grub-core/loader/multiboot_mbi2.c | 12 +++---- include/grub/multiboot.h | 4 +-- include/grub/multiboot2.h | 4 +-- 5 files changed, 51 insertions(+), 28 deletions(-) diff --git a/grub-core/loader/i386/multiboot_mbi.c b/grub-core/loader/i386/multiboot_mbi.c index 326827089..8541afc1d 100644 --- a/grub-core/loader/i386/multiboot_mbi.c +++ b/grub-core/loader/i386/multiboot_mbi.c @@ -662,13 +662,13 @@ grub_multiboot_free_mbi (void) } grub_err_t -grub_multiboot_init_mbi (int argc, char *argv[]) +grub_multiboot_init_mbi (int argc, char *argv[], int no_escape) { grub_ssize_t len = 0; grub_multiboot_free_mbi (); - len = grub_loader_cmdline_size (argc, argv, 0); + len = grub_loader_cmdline_size (argc, argv, no_escape); cmdline = grub_malloc (len); if (! cmdline) @@ -676,12 +676,12 @@ grub_multiboot_init_mbi (int argc, char *argv[]) cmdline_size = len; return grub_create_loader_cmdline (argc, argv, cmdline, - cmdline_size, GRUB_VERIFY_KERNEL_CMDLINE, 0); + cmdline_size, GRUB_VERIFY_KERNEL_CMDLINE, no_escape); } grub_err_t grub_multiboot_add_module (grub_addr_t start, grub_size_t size, - int argc, char *argv[]) + int argc, char *argv[], int no_escape) { struct module *newmod; grub_size_t len = 0; @@ -694,7 +694,7 @@ grub_multiboot_add_module (grub_addr_t start, grub_size_t size, newmod->size = size; newmod->next = 0; - len = grub_loader_cmdline_size (argc, argv, 0); + len = grub_loader_cmdline_size (argc, argv, no_escape); newmod->cmdline = grub_malloc (len); if (! newmod->cmdline) @@ -706,7 +706,8 @@ grub_multiboot_add_module (grub_addr_t start, grub_size_t size, total_modcmd += ALIGN_UP (len, 4); err = grub_create_loader_cmdline (argc, argv, newmod->cmdline, - newmod->cmdline_size, GRUB_VERIFY_MODULE_CMDLINE, 0); + newmod->cmdline_size, GRUB_VERIFY_MODULE_CMDLINE, no_escape); + if (err) { grub_free (newmod); diff --git a/grub-core/loader/multiboot.c b/grub-core/loader/multiboot.c index 94be512c4..851f75334 100644 --- a/grub-core/loader/multiboot.c +++ b/grub-core/loader/multiboot.c @@ -295,11 +295,14 @@ grub_cmd_multiboot (grub_command_t cmd __attribute__ ((unused)), #ifndef GRUB_USE_MULTIBOOT2 grub_multiboot_quirks = GRUB_MULTIBOOT_QUIRKS_NONE; +#endif int option_found = 0; + int no_escape = 0; do { option_found = 0; +#ifndef GRUB_USE_MULTIBOOT2 if (argc != 0 && grub_strcmp (argv[0], "--quirk-bad-kludge") == 0) { argc--; @@ -315,9 +318,17 @@ grub_cmd_multiboot (grub_command_t cmd __attribute__ ((unused)), option_found = 1; grub_multiboot_quirks |= GRUB_MULTIBOOT_QUIRK_MODULES_AFTER_KERNEL; } - } while (option_found); #endif + if (argc != 0 && grub_strcmp (argv[0], "--noescape") == 0) + { + argc--; + argv++; + option_found = 1; + no_escape = 1; + } + } while (option_found); + if (argc == 0) return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected")); @@ -328,7 +339,7 @@ grub_cmd_multiboot (grub_command_t cmd __attribute__ ((unused)), grub_dl_ref (my_mod); /* Skip filename. */ - GRUB_MULTIBOOT (init_mbi) (argc - 1, argv + 1); + GRUB_MULTIBOOT (init_mbi) (argc - 1, argv + 1, no_escape); grub_relocator_unload (GRUB_MULTIBOOT (relocator)); GRUB_MULTIBOOT (relocator) = grub_relocator_new (); @@ -367,18 +378,29 @@ grub_cmd_module (grub_command_t cmd __attribute__ ((unused)), void *module = NULL; grub_addr_t target; grub_err_t err; - int nounzip = 0; + int nounzip = 0, noescape = 0, option_found = 0; grub_uint64_t lowest_addr = 0; - if (argc == 0) - return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected")); - - if (grub_strcmp (argv[0], "--nounzip") == 0) + do { - argv++; - argc--; - nounzip = 1; - } + option_found = 0; + + if (argc != 0 && grub_strcmp (argv[0], "--nounzip") == 0) + { + argc--; + argv++; + option_found = 1; + nounzip = 1; + } + + if (argc != 0 && grub_strcmp (argv[0], "--noescape") == 0) + { + argc--; + argv++; + option_found = 1; + noescape = 1; + } + } while (option_found); if (argc == 0) return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected")); @@ -420,7 +442,7 @@ grub_cmd_module (grub_command_t cmd __attribute__ ((unused)), target = 0; } - err = GRUB_MULTIBOOT (add_module) (target, size, argc - 1, argv + 1); + err = GRUB_MULTIBOOT (add_module) (target, size, argc - 1, argv + 1, noescape); if (err) { grub_file_close (file); diff --git a/grub-core/loader/multiboot_mbi2.c b/grub-core/loader/multiboot_mbi2.c index 8a81a0359..fcaf3ba56 100644 --- a/grub-core/loader/multiboot_mbi2.c +++ b/grub-core/loader/multiboot_mbi2.c @@ -1031,13 +1031,13 @@ grub_multiboot2_free_mbi (void) } grub_err_t -grub_multiboot2_init_mbi (int argc, char *argv[]) +grub_multiboot2_init_mbi (int argc, char *argv[], int no_escape) { grub_ssize_t len = 0; grub_multiboot2_free_mbi (); - len = grub_loader_cmdline_size (argc, argv, 0); + len = grub_loader_cmdline_size (argc, argv, no_escape); cmdline = grub_malloc (len); if (! cmdline) @@ -1045,12 +1045,12 @@ grub_multiboot2_init_mbi (int argc, char *argv[]) cmdline_size = len; return grub_create_loader_cmdline (argc, argv, cmdline, cmdline_size, - GRUB_VERIFY_KERNEL_CMDLINE, 0); + GRUB_VERIFY_KERNEL_CMDLINE, no_escape); } grub_err_t grub_multiboot2_add_module (grub_addr_t start, grub_size_t size, - int argc, char *argv[]) + int argc, char *argv[], int no_escape) { struct module *newmod; grub_size_t len = 0; @@ -1062,7 +1062,7 @@ grub_multiboot2_add_module (grub_addr_t start, grub_size_t size, newmod->start = start; newmod->size = size; - len = grub_loader_cmdline_size (argc, argv, 0); + len = grub_loader_cmdline_size (argc, argv, no_escape); newmod->cmdline = grub_malloc (len); if (! newmod->cmdline) @@ -1074,7 +1074,7 @@ grub_multiboot2_add_module (grub_addr_t start, grub_size_t size, total_modcmd += ALIGN_UP (len, MULTIBOOT_TAG_ALIGN); err = grub_create_loader_cmdline (argc, argv, newmod->cmdline, - newmod->cmdline_size, GRUB_VERIFY_MODULE_CMDLINE, 0); + newmod->cmdline_size, GRUB_VERIFY_MODULE_CMDLINE, no_escape); if (err) { grub_free (newmod->cmdline); diff --git a/include/grub/multiboot.h b/include/grub/multiboot.h index d8847f753..c8f4b1304 100644 --- a/include/grub/multiboot.h +++ b/include/grub/multiboot.h @@ -43,9 +43,9 @@ void grub_module (int argc, char *argv[]); void grub_multiboot_set_accepts_video (int val); grub_err_t grub_multiboot_make_mbi (grub_uint32_t *target); void grub_multiboot_free_mbi (void); -grub_err_t grub_multiboot_init_mbi (int argc, char *argv[]); +grub_err_t grub_multiboot_init_mbi (int argc, char *argv[], int noescape); grub_err_t grub_multiboot_add_module (grub_addr_t start, grub_size_t size, - int argc, char *argv[]); + int argc, char *argv[], int noescape); void grub_multiboot_set_bootdev (void); void grub_multiboot_add_elfsyms (grub_size_t num, grub_size_t entsize, diff --git a/include/grub/multiboot2.h b/include/grub/multiboot2.h index b90aa6989..fa8006b4d 100644 --- a/include/grub/multiboot2.h +++ b/include/grub/multiboot2.h @@ -35,9 +35,9 @@ void grub_module2 (int argc, char *argv[]); void grub_multiboot2_set_accepts_video (int val); grub_err_t grub_multiboot2_make_mbi (grub_uint32_t *target); void grub_multiboot2_free_mbi (void); -grub_err_t grub_multiboot2_init_mbi (int argc, char *argv[]); +grub_err_t grub_multiboot2_init_mbi (int argc, char *argv[], int noescape); grub_err_t grub_multiboot2_add_module (grub_addr_t start, grub_size_t size, - int argc, char *argv[]); + int argc, char *argv[], int noescape); void grub_multiboot2_set_bootdev (void); void grub_multiboot2_add_elfsyms (grub_size_t num, grub_size_t entsize, -- 2.39.2 _______________________________________________ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel