public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Martin Schlemmer [c]" <azarah@nosferatu.za.org>
To: Andrew Morton <akpm@osdl.org>
Cc: Linux Kernel Mailing Lists <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2.6.9-rc2-mm2] Select cpio_list or source directory for initramfs image [u]
Date: Sun, 17 Oct 2004 17:14:09 +0200	[thread overview]
Message-ID: <1098026049.879.8.camel@nosferatu.lan> (raw)
In-Reply-To: <1096238866.11535.40.camel@nosferatu.lan>


[-- Attachment #1.1: Type: text/plain, Size: 7738 bytes --]

On Mon, 2004-09-27 at 00:47 +0200, Martin Schlemmer wrote:

Hi,

> Attached is a patch that adds CONFIG_INITRAMFS_SOURCE, enabling you to
> either specify a file as cpio_list, or a directory to generate a list
> from.  It depreciate the INITRAMFS_LIST environment variable introduced
> not long ago.
> 
> There are some issues (suggestions/patches welcome) that I am not
> sure about:
> 1) I put the menu entry under block devices, but I am not sure if
>    this is the correct location?
> 2) There might be a better (or more correct) way to do this with
>    kbuild?
> 3) Variable names and especially help text needs some love.
> 4) I am not sure if I am duplicating work in progress?
> 
> I did add an inline version of the patch, but the new evo 2.0 is
> brain dead again concerning patches (yes, even with 'preformat'),
> so I attached it as well.  Also, I have not signed it off, as this is
> more for review/comments.
> 
> Comments will be appreciated.
> 

Attached is a patch (also inline, but evo 2.0 seems to not get
'preformat' right anymore) that replaces
select-cpio_list-or-source-directory-for-initramfs-image.patch in
2.6.9-rc4-mm1, including the indentation fix, as well as fix an issue
reported by Esben Nielsen <simlo@phys.au.dk> as proposed by Sam Ravnborg
(Should fix failing to build if $O is set).

I also moved initramfs_list to initramfs_list.shipped, to make sure we
always have an 'fall back' list (say you unset CONFIG_INITRAMFS_SOURCE
and deleted your custom list/directory, then building will not fail).


  Signed-off-by: Martin Schlemmer <azarah@nosferatu.za.org>

diff -urpN linux-2.6.9-rc4-mm1.orig/drivers/block/Kconfig linux-2.6.9-rc4-mm1/drivers/block/Kconfig
--- linux-2.6.9-rc4-mm1.orig/drivers/block/Kconfig	2004-10-17 17:00:13.424934520 +0200
+++ linux-2.6.9-rc4-mm1/drivers/block/Kconfig	2004-10-17 16:58:35.451828696 +0200
@@ -348,6 +348,32 @@ config BLK_DEV_INITRD
 	  "real" root file system, etc. See <file:Documentation/initrd.txt>
 	  for details.
 
+config INITRAMFS_SOURCE
+	string "Source directory of cpio_list"
+	default ""
+	help
+	  This can be set to either a directory containing files, etc to be
+	  included in the initramfs archive, or a file containing newline
+	  separated entries.
+
+	  If it is a file, it should be in the following format:
+	    # a comment
+	    file <name> <location> <mode> <uid> <gid>
+	    dir <name> <mode> <uid> <gid>
+	    nod <name> <mode> <uid> <gid> <dev_type> <maj> <min>
+
+	  Where:
+	    <name>      name of the file/dir/nod in the archive
+	    <location>  location of the file in the current filesystem
+	    <mode>      mode/permissions of the file
+	    <uid>       user id (0=root)
+	    <gid>       group id (0=root)
+	    <dev_type>  device type (b=block, c=character)
+	    <maj>       major number of nod
+	    <min>       minor number of nod
+
+	  If you are not sure, leave it blank.
+
 config LBD
 	bool "Support for Large Block Devices"
 	depends on X86 || MIPS32 || PPC32 || ARCH_S390_31 || SUPERH
diff -urpN linux-2.6.9-rc4-mm1.orig/scripts/gen_initramfs_list.sh linux-2.6.9-rc4-mm1/scripts/gen_initramfs_list.sh
--- linux-2.6.9-rc4-mm1.orig/scripts/gen_initramfs_list.sh	1970-01-01 02:00:00.000000000 +0200
+++ linux-2.6.9-rc4-mm1/scripts/gen_initramfs_list.sh	2004-10-17 16:58:28.939818672 +0200
@@ -0,0 +1,84 @@
+#!/bin/bash
+# Copyright (C) Martin Schlemmer <azarah@nosferatu.za.org>
+# Released under the terms of the GNU GPL
+#
+# A script to generate newline separated entries (to stdout) from a directory's
+# contents suitable for use as a cpio_list for gen_init_cpio.
+#
+# Arguements: $1 -- the source directory
+#
+# TODO:  Add support for symlinks, sockets and pipes when gen_init_cpio
+#        supports them.
+
+usage() {
+	echo "Usage: $0 initramfs-source-dir"
+	exit 1
+}
+
+srcdir=$(echo "$1" | sed -e 's://*:/:g')
+
+if [ "$#" -gt 1 -o ! -d "${srcdir}" ]; then
+	usage
+fi
+
+filetype() {
+	local argv1="$1"
+
+	if [ -f "${argv1}" ]; then
+		echo "file"
+	elif [ -d "${argv1}" ]; then
+		echo "dir"
+	elif [ -b "${argv1}" -o -c "${argv1}" ]; then
+		echo "nod"
+	else
+		echo "invalid"
+	fi
+	return 0
+}
+
+parse() {
+	local location="$1"
+	local name="${location/${srcdir}//}"
+	local mode="$2"
+	local uid="$3"
+	local gid="$4"
+	local ftype=$(filetype "${location}")
+	local str="${mode} ${uid} ${gid}"
+
+	[ "${ftype}" == "invalid" ] && return 0
+	[ "${location}" == "${srcdir}" ] && return 0
+
+	case "${ftype}" in
+		"file")
+			str="${ftype} ${name} ${location} ${str}"
+			;;
+		"nod")
+			local dev_type=
+			local maj=$(LC_ALL=C ls -l "${location}" | \
+					gawk '{sub(/,/, "", $5); print $5}')
+			local min=$(LC_ALL=C ls -l "${location}" | \
+					gawk '{print $6}')
+
+			if [ -b "${location}" ]; then
+				dev_type="b"
+			else
+				dev_type="c"
+			fi
+			str="${ftype} ${name} ${str} ${dev_type} ${maj} ${min}"
+			;;
+		*)
+			str="${ftype} ${name} ${str}"
+			;;
+	esac
+
+	echo "${str}"
+
+	return 0
+}
+
+find "${srcdir}" -printf "%p %m %U %G\n" | \
+while read x; do
+	parse ${x}
+done
+
+exit 0
diff -urpN linux-2.6.9-rc4-mm1.orig/usr/Makefile linux-2.6.9-rc4-mm1/usr/Makefile
--- linux-2.6.9-rc4-mm1.orig/usr/Makefile	2004-10-17 17:00:13.433933152 +0200
+++ linux-2.6.9-rc4-mm1/usr/Makefile	2004-10-17 16:59:56.040577344 +0200
@@ -8,7 +8,7 @@ clean-files := initramfs_data.cpio.gz
 # If you want a different list of files in the initramfs_data.cpio
 # then you can either overwrite the cpio_list in this directory
 # or set INITRAMFS_LIST to another filename.
-INITRAMFS_LIST ?= $(obj)/initramfs_list
+INITRAMFS_LIST := $(obj)/initramfs_list
 
 # initramfs_data.o contains the initramfs_data.cpio.gz image.
 # The image is included using .incbin, a dependency which is not
@@ -23,6 +23,25 @@ $(obj)/initramfs_data.o: $(obj)/initramf
 # Commented out for now
 # initramfs-y := $(obj)/root/hello
 
+quiet_cmd_gen_list = GEN_INITRAMFS_LIST $@
+      cmd_gen_list = $(shell \
+        if test -f $(CONFIG_INITRAMFS_SOURCE); then \
+	  if [ $(CONFIG_INITRAMFS_SOURCE) != $@ ]; then \
+	    echo 'cp -f $(CONFIG_INITRAMFS_SOURCE) $@'; \
+	  else \
+	    echo 'echo Using shipped $@'; \
+	    echo 'cp -f $(srctree)/$(CONFIG_INITRAMFS_SOURCE).shipped $@'; \
+	  fi; \
+	elif test -d $(CONFIG_INITRAMFS_SOURCE); then \
+	  echo 'scripts/gen_initramfs_list.sh $(CONFIG_INITRAMFS_SOURCE) > $@'; \
+	else \
+	  echo 'echo Using shipped $@'; \
+	  echo 'cp -f $(srctree)/$(CONFIG_INITRAMFS_SOURCE).shipped $@'; \
+	fi)
+
+$(INITRAMFS_LIST): FORCE
+	$(call cmd,gen_list)
+
 quiet_cmd_cpio = CPIO    $@
       cmd_cpio = ./$< $(INITRAMFS_LIST) > $@
 
diff -urpN linux-2.6.9-rc4-mm1.orig/usr/initramfs_list linux-2.6.9-rc4-mm1/usr/initramfs_list
--- linux-2.6.9-rc4-mm1.orig/usr/initramfs_list	2004-10-17 16:48:14.262263864 +0200
+++ linux-2.6.9-rc4-mm1/usr/initramfs_list	1970-01-01 02:00:00.000000000 +0200
@@ -1,5 +0,0 @@
-# This is a very simple initramfs - mostly preliminary for future expansion
-
-dir /dev 0755 0 0
-nod /dev/console 0600 0 0 c 5 1
-dir /root 0700 0 0
diff -urpN linux-2.6.9-rc4-mm1.orig/usr/initramfs_list.shipped linux-2.6.9-rc4-mm1/usr/initramfs_list.shipped
--- linux-2.6.9-rc4-mm1.orig/usr/initramfs_list.shipped	1970-01-01 02:00:00.000000000 +0200
+++ linux-2.6.9-rc4-mm1/usr/initramfs_list.shipped	2004-10-17 16:28:57.667093056 +0200
@@ -0,0 +1,5 @@
+# This is a very simple initramfs - mostly preliminary for future expansion
+
+dir /dev 0755 0 0
+nod /dev/console 0600 0 0 c 5 1
+dir /root 0700 0 0




Thanks,

-- 
Martin Schlemmer


[-- Attachment #1.2: select-cpio_list-or-source-directory-for-initramfs-image.patch --]
[-- Type: text/x-patch, Size: 6057 bytes --]

diff -urpN linux-2.6.9-rc4-mm1.orig/drivers/block/Kconfig linux-2.6.9-rc4-mm1/drivers/block/Kconfig
--- linux-2.6.9-rc4-mm1.orig/drivers/block/Kconfig	2004-10-17 17:00:13.424934520 +0200
+++ linux-2.6.9-rc4-mm1/drivers/block/Kconfig	2004-10-17 16:58:35.451828696 +0200
@@ -348,6 +348,32 @@ config BLK_DEV_INITRD
 	  "real" root file system, etc. See <file:Documentation/initrd.txt>
 	  for details.
 
+config INITRAMFS_SOURCE
+	string "Source directory of cpio_list"
+	default ""
+	help
+	  This can be set to either a directory containing files, etc to be
+	  included in the initramfs archive, or a file containing newline
+	  separated entries.
+
+	  If it is a file, it should be in the following format:
+	    # a comment
+	    file <name> <location> <mode> <uid> <gid>
+	    dir <name> <mode> <uid> <gid>
+	    nod <name> <mode> <uid> <gid> <dev_type> <maj> <min>
+
+	  Where:
+	    <name>      name of the file/dir/nod in the archive
+	    <location>  location of the file in the current filesystem
+	    <mode>      mode/permissions of the file
+	    <uid>       user id (0=root)
+	    <gid>       group id (0=root)
+	    <dev_type>  device type (b=block, c=character)
+	    <maj>       major number of nod
+	    <min>       minor number of nod
+
+	  If you are not sure, leave it blank.
+
 config LBD
 	bool "Support for Large Block Devices"
 	depends on X86 || MIPS32 || PPC32 || ARCH_S390_31 || SUPERH
diff -urpN linux-2.6.9-rc4-mm1.orig/scripts/gen_initramfs_list.sh linux-2.6.9-rc4-mm1/scripts/gen_initramfs_list.sh
--- linux-2.6.9-rc4-mm1.orig/scripts/gen_initramfs_list.sh	1970-01-01 02:00:00.000000000 +0200
+++ linux-2.6.9-rc4-mm1/scripts/gen_initramfs_list.sh	2004-10-17 16:58:28.939818672 +0200
@@ -0,0 +1,84 @@
+#!/bin/bash
+# Copyright (C) Martin Schlemmer <azarah@nosferatu.za.org>
+# Released under the terms of the GNU GPL
+#
+# A script to generate newline separated entries (to stdout) from a directory's
+# contents suitable for use as a cpio_list for gen_init_cpio.
+#
+# Arguements: $1 -- the source directory
+#
+# TODO:  Add support for symlinks, sockets and pipes when gen_init_cpio
+#        supports them.
+
+usage() {
+	echo "Usage: $0 initramfs-source-dir"
+	exit 1
+}
+
+srcdir=$(echo "$1" | sed -e 's://*:/:g')
+
+if [ "$#" -gt 1 -o ! -d "${srcdir}" ]; then
+	usage
+fi
+
+filetype() {
+	local argv1="$1"
+
+	if [ -f "${argv1}" ]; then
+		echo "file"
+	elif [ -d "${argv1}" ]; then
+		echo "dir"
+	elif [ -b "${argv1}" -o -c "${argv1}" ]; then
+		echo "nod"
+	else
+		echo "invalid"
+	fi
+	return 0
+}
+
+parse() {
+	local location="$1"
+	local name="${location/${srcdir}//}"
+	local mode="$2"
+	local uid="$3"
+	local gid="$4"
+	local ftype=$(filetype "${location}")
+	local str="${mode} ${uid} ${gid}"
+
+	[ "${ftype}" == "invalid" ] && return 0
+	[ "${location}" == "${srcdir}" ] && return 0
+
+	case "${ftype}" in
+		"file")
+			str="${ftype} ${name} ${location} ${str}"
+			;;
+		"nod")
+			local dev_type=
+			local maj=$(LC_ALL=C ls -l "${location}" | \
+					gawk '{sub(/,/, "", $5); print $5}')
+			local min=$(LC_ALL=C ls -l "${location}" | \
+					gawk '{print $6}')
+
+			if [ -b "${location}" ]; then
+				dev_type="b"
+			else
+				dev_type="c"
+			fi
+			str="${ftype} ${name} ${str} ${dev_type} ${maj} ${min}"
+			;;
+		*)
+			str="${ftype} ${name} ${str}"
+			;;
+	esac
+
+	echo "${str}"
+
+	return 0
+}
+
+find "${srcdir}" -printf "%p %m %U %G\n" | \
+while read x; do
+	parse ${x}
+done
+
+exit 0
diff -urpN linux-2.6.9-rc4-mm1.orig/usr/Makefile linux-2.6.9-rc4-mm1/usr/Makefile
--- linux-2.6.9-rc4-mm1.orig/usr/Makefile	2004-10-17 17:00:13.433933152 +0200
+++ linux-2.6.9-rc4-mm1/usr/Makefile	2004-10-17 16:59:56.040577344 +0200
@@ -8,7 +8,7 @@ clean-files := initramfs_data.cpio.gz
 # If you want a different list of files in the initramfs_data.cpio
 # then you can either overwrite the cpio_list in this directory
 # or set INITRAMFS_LIST to another filename.
-INITRAMFS_LIST ?= $(obj)/initramfs_list
+INITRAMFS_LIST := $(obj)/initramfs_list
 
 # initramfs_data.o contains the initramfs_data.cpio.gz image.
 # The image is included using .incbin, a dependency which is not
@@ -23,6 +23,25 @@ $(obj)/initramfs_data.o: $(obj)/initramf
 # Commented out for now
 # initramfs-y := $(obj)/root/hello
 
+quiet_cmd_gen_list = GEN_INITRAMFS_LIST $@
+      cmd_gen_list = $(shell \
+        if test -f $(CONFIG_INITRAMFS_SOURCE); then \
+	  if [ $(CONFIG_INITRAMFS_SOURCE) != $@ ]; then \
+	    echo 'cp -f $(CONFIG_INITRAMFS_SOURCE) $@'; \
+	  else \
+	    echo 'echo Using shipped $@'; \
+	    echo 'cp -f $(srctree)/$(CONFIG_INITRAMFS_SOURCE).shipped $@'; \
+	  fi; \
+	elif test -d $(CONFIG_INITRAMFS_SOURCE); then \
+	  echo 'scripts/gen_initramfs_list.sh $(CONFIG_INITRAMFS_SOURCE) > $@'; \
+	else \
+	  echo 'echo Using shipped $@'; \
+	  echo 'cp -f $(srctree)/$(CONFIG_INITRAMFS_SOURCE).shipped $@'; \
+	fi)
+
+$(INITRAMFS_LIST): FORCE
+	$(call cmd,gen_list)
+
 quiet_cmd_cpio = CPIO    $@
       cmd_cpio = ./$< $(INITRAMFS_LIST) > $@
 
diff -urpN linux-2.6.9-rc4-mm1.orig/usr/initramfs_list linux-2.6.9-rc4-mm1/usr/initramfs_list
--- linux-2.6.9-rc4-mm1.orig/usr/initramfs_list	2004-10-17 16:48:14.262263864 +0200
+++ linux-2.6.9-rc4-mm1/usr/initramfs_list	1970-01-01 02:00:00.000000000 +0200
@@ -1,5 +0,0 @@
-# This is a very simple initramfs - mostly preliminary for future expansion
-
-dir /dev 0755 0 0
-nod /dev/console 0600 0 0 c 5 1
-dir /root 0700 0 0
diff -urpN linux-2.6.9-rc4-mm1.orig/usr/initramfs_list.shipped linux-2.6.9-rc4-mm1/usr/initramfs_list.shipped
--- linux-2.6.9-rc4-mm1.orig/usr/initramfs_list.shipped	1970-01-01 02:00:00.000000000 +0200
+++ linux-2.6.9-rc4-mm1/usr/initramfs_list.shipped	2004-10-17 16:28:57.667093056 +0200
@@ -0,0 +1,5 @@
+# This is a very simple initramfs - mostly preliminary for future expansion
+
+dir /dev 0755 0 0
+nod /dev/console 0600 0 0 c 5 1
+dir /root 0700 0 0

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

  reply	other threads:[~2004-10-17 15:18 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-09-26 22:47 [PATCH 2.6.9-rc2-mm2] Select cpio_list or source directory for initramfs image [u] Martin Schlemmer [c]
2004-10-17 15:14 ` Martin Schlemmer [c] [this message]
2004-10-17 15:33   ` Martin Schlemmer [c]

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=1098026049.879.8.camel@nosferatu.lan \
    --to=azarah@nosferatu.za.org \
    --cc=akpm@osdl.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