Cure found for kernel updates
Matthew Garrett
mjg59 at srcf.ucam.org
Fri May 16 19:55:24 UTC 2014
Something like this (completely untested) patch ought to do roughly the
right thing.
diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c
index 4274aca..c9c8fc0 100644
--- a/grub-core/commands/blscfg.c
+++ b/grub-core/commands/blscfg.c
@@ -54,8 +54,9 @@ static int parse_entry (
char *p;
grub_file_t f = NULL;
grub_off_t sz;
- char *title = NULL, *options = NULL, *clinux = NULL, *initrd = NULL, *src = NULL;
+ char *title = NULL, *options = NULL, *clinux = NULL, *initrd = NULL, *src = NULL, *target = NULL;
const char *args[2] = { NULL, NULL };
+ int drive = -1, partition;
if (filename[0] == '.')
return 0;
@@ -113,25 +114,51 @@ static int parse_entry (
if (!initrd)
goto finish;
}
+ else if (grub_strncmp (buf, "chainload-disk ", 15) == 0)
+ {
+ drive = (int) grub_strtoul (buf + 15, 0, 10);
+ if (grub_errno != GRUB_ERR_NONE)
+ goto fail;
+ }
+ else if (grub_strncmp (buf, "chainload-partition ", 20) == 0)
+ {
+ partition = (int) grub_strtoul (buf + 20, 0, 10);
+ if (grub_errno != GRUB_ERR_NONE)
+ goto fail;
+ }
grub_free(buf);
}
- if (!linux)
+ if (!linux && drive < 0)
{
- grub_printf ("Skipping file %s with no 'linux' key.", p);
+ grub_printf ("Skipping file %s with no 'linux' or 'chainload-disk' key.",
+ p);
goto finish;
}
args[0] = title ? title : filename;
- src = grub_xasprintf ("load_video\n"
- "set gfx_payload=keep\n"
- "insmod gzio\n"
- GRUB_LINUX_CMD " %s%s%s%s\n"
- "%s%s%s%s",
- GRUB_BOOT_DEVICE, clinux, options ? " " : "", options ? options : "",
- initrd ? GRUB_INITRD_CMD " " : "", initrd ? GRUB_BOOT_DEVICE : "", initrd ? initrd : "", initrd ? "\n" : "");
+ if (drive) {
+ if (partition) {
+ target = grub_xasprintf("chainloader (hd%d,%d)+1", drive, partition);
+ } else {
+ target = grub_xasprintf("chainloader (hd%d)+1", drive);
+ }
+ src = grub_xasprintf ("insmod part_msdos\n"
+ "insmod chain\n"
+ "%s\n",
+ target
+ );
+ } else {
+ src = grub_xasprintf ("load_video\n"
+ "set gfx_payload=keep\n"
+ "insmod gzio\n"
+ GRUB_LINUX_CMD " %s%s%s%s\n"
+ "%s%s%s%s",
+ GRUB_BOOT_DEVICE, clinux, options ? " " : "", options ? options : "",
+ initrd ? GRUB_INITRD_CMD " " : "", initrd ? GRUB_BOOT_DEVICE : "", initrd ? initrd : "", initrd ? "\n" : "");
+ }
grub_normal_add_menu_entry (1, args, NULL, NULL, "bls", NULL, NULL, src, 0);
@@ -142,6 +169,7 @@ finish:
grub_free (clinux);
grub_free (initrd);
grub_free (src);
+ grub_free (target);
if (f)
grub_file_close (f);
--
Matthew Garrett | mjg59 at srcf.ucam.org
More information about the desktop
mailing list