|
|
27a4da |
From d0bf58c1c71a1e192fa955e9786432bcdcb31bf1 Mon Sep 17 00:00:00 2001
|
|
|
23d2ea |
From: Andrei Borzenkov <arvidjaar@gmail.com>
|
|
|
23d2ea |
Date: Thu, 7 May 2015 20:24:24 +0300
|
|
|
27a4da |
Subject: [PATCH 197/260] loader/linux: do not pad initrd with zeroes at the
|
|
|
23d2ea |
end
|
|
|
23d2ea |
|
|
|
23d2ea |
Syslinux memdisk is using initrd image and needs to know uncompressed
|
|
|
23d2ea |
size in advance. For gzip uncompressed size is at the end of compressed
|
|
|
23d2ea |
stream. Grub padded each input file to 4 bytes at the end, which means
|
|
|
23d2ea |
syslinux got wrong size.
|
|
|
23d2ea |
|
|
|
23d2ea |
Linux initramfs loader apparently does not care about trailing alignment.
|
|
|
23d2ea |
So change code to align beginning of each file instead which atomatically
|
|
|
23d2ea |
gives us the correct size for single file.
|
|
|
23d2ea |
|
|
|
23d2ea |
Reported-By: David Shaw <dshaw@jabberwocky.com>
|
|
|
23d2ea |
|
|
|
23d2ea |
(cherry picked from commit a8c473288d3f0a5e17a903a5121dea1a695dda3b)
|
|
|
23d2ea |
|
|
|
23d2ea |
Resolves: rhbz#1219864
|
|
|
23d2ea |
---
|
|
|
23d2ea |
grub-core/loader/linux.c | 11 +++++++----
|
|
|
23d2ea |
1 file changed, 7 insertions(+), 4 deletions(-)
|
|
|
23d2ea |
|
|
|
23d2ea |
diff --git a/grub-core/loader/linux.c b/grub-core/loader/linux.c
|
|
|
27a4da |
index 117232f0c..d2cd591f6 100644
|
|
|
23d2ea |
--- a/grub-core/loader/linux.c
|
|
|
23d2ea |
+++ b/grub-core/loader/linux.c
|
|
|
23d2ea |
@@ -161,6 +161,9 @@ grub_initrd_init (int argc, char *argv[],
|
|
|
23d2ea |
for (i = 0; i < argc; i++)
|
|
|
23d2ea |
{
|
|
|
23d2ea |
const char *fname = argv[i];
|
|
|
23d2ea |
+
|
|
|
23d2ea |
+ initrd_ctx->size = ALIGN_UP (initrd_ctx->size, 4);
|
|
|
23d2ea |
+
|
|
|
23d2ea |
if (grub_memcmp (argv[i], "newc:", 5) == 0)
|
|
|
23d2ea |
{
|
|
|
23d2ea |
const char *ptr, *eptr;
|
|
|
23d2ea |
@@ -205,7 +208,7 @@ grub_initrd_init (int argc, char *argv[],
|
|
|
23d2ea |
initrd_ctx->nfiles++;
|
|
|
23d2ea |
initrd_ctx->components[i].size
|
|
|
23d2ea |
= grub_file_size (initrd_ctx->components[i].file);
|
|
|
23d2ea |
- initrd_ctx->size += ALIGN_UP (initrd_ctx->components[i].size, 4);
|
|
|
23d2ea |
+ initrd_ctx->size += initrd_ctx->components[i].size;
|
|
|
23d2ea |
}
|
|
|
23d2ea |
|
|
|
23d2ea |
if (newc)
|
|
|
23d2ea |
@@ -248,10 +251,12 @@ grub_initrd_load (struct grub_linux_initrd_context *initrd_ctx,
|
|
|
23d2ea |
int i;
|
|
|
23d2ea |
int newc = 0;
|
|
|
23d2ea |
struct dir *root = 0;
|
|
|
23d2ea |
+ grub_ssize_t cursize = 0;
|
|
|
23d2ea |
|
|
|
23d2ea |
for (i = 0; i < initrd_ctx->nfiles; i++)
|
|
|
23d2ea |
{
|
|
|
23d2ea |
- grub_ssize_t cursize;
|
|
|
23d2ea |
+ grub_memset (ptr, 0, ALIGN_UP_OVERHEAD (cursize, 4));
|
|
|
23d2ea |
+ ptr += ALIGN_UP_OVERHEAD (cursize, 4);
|
|
|
23d2ea |
|
|
|
23d2ea |
if (initrd_ctx->components[i].newc_name)
|
|
|
23d2ea |
{
|
|
|
23d2ea |
@@ -283,8 +288,6 @@ grub_initrd_load (struct grub_linux_initrd_context *initrd_ctx,
|
|
|
23d2ea |
return grub_errno;
|
|
|
23d2ea |
}
|
|
|
23d2ea |
ptr += cursize;
|
|
|
23d2ea |
- grub_memset (ptr, 0, ALIGN_UP_OVERHEAD (cursize, 4));
|
|
|
23d2ea |
- ptr += ALIGN_UP_OVERHEAD (cursize, 4);
|
|
|
23d2ea |
}
|
|
|
23d2ea |
if (newc)
|
|
|
23d2ea |
ptr = make_header (ptr, "TRAILER!!!", sizeof ("TRAILER!!!") - 1, 0, 0);
|
|
|
23d2ea |
--
|
|
|
27a4da |
2.13.0
|
|
|
23d2ea |
|