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