mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: P J P <ppandit@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: Andrew Morton <akpm@linux-foundation.org>
Subject: [Patch] Read CONFIG_RD_ variables for initramfs compression
Date: Tue, 15 Oct 2013 20:25:57 +0530 (IST)	[thread overview]
Message-ID: <alpine.LFD.2.03.1310152002200.7552@erqung.pbz> (raw)

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1068 bytes --]

    Hello Andrew,

When expert configuration option(CONFIG_EXPERT) is enabled, menuconfig offers 
choice of compression algorithm, to compress initial ramfs image. This choice 
is stored into CONFIG_RD_<GZIP/BZIP2/...> variables.

But, usr/Makefile reads from earlier INITRAMFS_COMPRESSION_* variables to set 
the ramfs file extension(.gzip/.bz2/...), which is later(in 
scripts/gen_initramfs_list.sh) used to apply actual compression.

Since none of the INITRAMFS_COMPRESSION_* variables are defined, the resulting 
'usr/initramfs_data.cpio' file remains un-compressed.

The patch attached herein, updates the usr/Makefile to read CONFIG_RD_* 
variables, and also adds support for the Lz4 compression algorithm.

Could you please review it?
==
PS:
IIUC, I think INITRAMFS_COMPRESSION_* variables are not used anywhere at all. 
Though I'm not sure about the EMBEDDED configurations. But if they are not 
used, it could be better to remove their description/references from 
usr/Kconfig and other places.


Thank you.
--
Prasad J Pandit / Red Hat Security Response Team

[-- Attachment #2: Type: TEXT/PLAIN, Size: 2876 bytes --]

From 0304fb400c27227106c1f9a57fe3de13ca03cca2 Mon Sep 17 00:00:00 2001
From: P J P <prasad@redhat.com>
Date: Tue, 15 Oct 2013 19:28:40 +0530
Subject: Read CONFIG_RD_ variables for initramfs compression

When expert configuration option(CONFIG_EXPERT) is enabled,
menuconfig offers a choice of compression algorithm to compress
initial ramfs image; This choice is stored into CONFIG_RD_*
variables. But usr/Makefile uses earlier INITRAMFS_COMPRESSION_*
macros to build initial ramfs file. Since none of them is defined,
resulting 'initramfs_data.cpio' file remains un-compressed.

This patch updates the Makefile to use CONFIG_RD_* variables and
adds support for LZ4 compression algorithm.

Signed-off-by: P J P <prasad@redhat.com>

diff --git a/scripts/gen_initramfs_list.sh b/scripts/gen_initramfs_list.sh
index b482f16..5761973 100644
--- a/scripts/gen_initramfs_list.sh
+++ b/scripts/gen_initramfs_list.sh
@@ -246,6 +246,7 @@ case "$arg" in
 		echo "$output_file" | grep -q "\.xz$" && \
 				compr="xz --check=crc32 --lzma2=dict=1MiB"
 		echo "$output_file" | grep -q "\.lzo$" && compr="lzop -9 -f"
+		echo "$output_file" | grep -q "\.lz4$" && compr="lz4 -9 -f"
 		echo "$output_file" | grep -q "\.cpio$" && compr="cat"
 		shift
 		;;
diff --git a/usr/Makefile b/usr/Makefile
index 029ffe6..06ad948 100644
--- a/usr/Makefile
+++ b/usr/Makefile
@@ -7,19 +7,22 @@ PHONY += klibcdirs
 
 
 # Gzip
-suffix_$(CONFIG_INITRAMFS_COMPRESSION_GZIP)   = .gz
+suffix_$(CONFIG_RD_GZIP)   = .gz
 
 # Bzip2
-suffix_$(CONFIG_INITRAMFS_COMPRESSION_BZIP2)  = .bz2
+suffix_$(CONFIG_RD_BZIP2)  = .bz2
 
 # Lzma
-suffix_$(CONFIG_INITRAMFS_COMPRESSION_LZMA)   = .lzma
+suffix_$(CONFIG_RD_LZMA)   = .lzma
 
 # XZ
-suffix_$(CONFIG_INITRAMFS_COMPRESSION_XZ)     = .xz
+suffix_$(CONFIG_RD_XZ)     = .xz
 
 # Lzo
-suffix_$(CONFIG_INITRAMFS_COMPRESSION_LZO)   = .lzo
+suffix_$(CONFIG_RD_LZO)    = .lzo
+
+# Lz4
+suffix_$(CONFIG_RD_LZ4)    = .lz4
 
 AFLAGS_initramfs_data.o += -DINITRAMFS_IMAGE="usr/initramfs_data.cpio$(suffix_y)"
 
@@ -53,7 +56,10 @@ endif
 quiet_cmd_initfs = GEN     $@
       cmd_initfs = $(initramfs) -o $@ $(ramfs-args) $(ramfs-input)
 
-targets := initramfs_data.cpio.gz initramfs_data.cpio.bz2 initramfs_data.cpio.lzma initramfs_data.cpio.xz initramfs_data.cpio.lzo initramfs_data.cpio
+targets := initramfs_data.cpio.gz initramfs_data.cpio.bz2 \
+	initramfs_data.cpio.lzma initramfs_data.cpio.xz \
+	initramfs_data.cpio.lzo initramfs_data.cpio.lz4 \
+	initramfs_data.cpio
 # do not try to update files included in initramfs
 $(deps_initramfs): ;
 
@@ -66,4 +72,3 @@ $(deps_initramfs): klibcdirs
 $(obj)/initramfs_data.cpio$(suffix_y): $(obj)/gen_init_cpio $(deps_initramfs) klibcdirs
 	$(Q)$(initramfs) -l $(ramfs-input) > $(obj)/.initramfs_data.cpio.d
 	$(call if_changed,initfs)
-
-- 
1.8.3.1


             reply	other threads:[~2013-10-15 15:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-15 14:55 P J P [this message]
2013-10-29 22:15 ` Andrew Morton
2013-10-30 10:27   ` P J P
2013-10-30 22:05     ` Andrew Morton
2013-10-31  7:05       ` P J P
2013-12-11 15:46         ` Simon Guinot
2013-12-12  7:21           ` P J P

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LFD.2.03.1310152002200.7552@erqung.pbz \
    --to=ppandit@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®