From 2f35781fde88a99dec22407057b1a46343bc00cc Mon Sep 17 00:00:00 2001 From: Junxiao Bi Date: Wed, 14 May 2014 16:44:21 +0800 Subject: [PATCH 3/9] grubby: fix initrd updating when multiboot exist When using the following command to add an initrd for the kernel. grubby --update-kernel=/boot/vmlinuz-2.6.32-431.17.1.el6.x86_64.debug --initrd /boot/initramfs-2.6.32-431.17.1.el6.x86_64.debug.img --add-multiboot=/boot/tboot.gz The multiboot image /boot/tboot.gz is used as the key to search the configure entry in grub.conf, this is wrong. There may be other kernels also configure multiboot with the same name tboot.gz, if there index are smaller than the target one, then that will make the initrd added to the wrong kernel. Fix it to use kernel name as the search key. Signed-off-by: Junxiao Bi Reviewed-by: John Haxby --- grubby.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grubby.c b/grubby.c index db91364..118cb84 100644 --- a/grubby.c +++ b/grubby.c @@ -3311,7 +3311,7 @@ int addMBInitrd(struct grubConfig * cfg, const char *newMBKernel, if (!image) return 0; - for (; (entry = findEntryByPath(cfg, newMBKernel, prefix, &index)); index++) { + for (; (entry = findEntryByPath(cfg, image, prefix, &index)); index++) { kernelLine = getLineByType(LT_MBMODULE, entry->lines); if (!kernelLine) continue; -- 1.9.3