[klibc] [PATCH] klibc: default initramfs content stored in usr/initramfs.default

Sam Ravnborg sam at ravnborg.org
Mon Apr 17 12:00:38 PDT 2006


Harcoding default content of initramfs in the gen_initramfs_list.sh
script seems ackward. Move it to a file named:
usr/initramfs.default

This also fixes a small bug when no arguments was passed to
CONFIG_INITRAMFS_SOURCE (-d was passed twice to the script)

Idea and bug report from: "H. Peter Anvin" <hpa at zytor.com>

Signed-off-by: Sam Ravnborg <sam at ravnborg.org>
---

 scripts/gen_initramfs_list.sh |   25 ++-----------------------
 usr/Kbuild                    |    8 ++++----
 usr/initramfs.default         |    9 +++++++++
 3 files changed, 15 insertions(+), 27 deletions(-)

diff --git a/scripts/gen_initramfs_list.sh b/scripts/gen_initramfs_list.sh
index a609970..b1ebd64 100644
--- a/scripts/gen_initramfs_list.sh
+++ b/scripts/gen_initramfs_list.sh
@@ -15,7 +15,7 @@ set -e
 usage() {
 cat << EOF
 Usage:
-$0 [-o <file>] [-u <uid>] [-g <gid>] {-d | <cpio_source>} ...
+$0 [-o <file>] [-u <uid>] [-g <gid>] <cpio_source> ...
 	-o <file>      Create gzipped initramfs file named <file> using
 	               gen_init_cpio and gzip
 	-u <uid>       User ID to map to user ID 0 (root).
@@ -27,7 +27,6 @@ Usage:
 	<cpio_source>  File list or directory for cpio archive.
 	               If <cpio_source> is a .cpio file it will be used
 		       as direct input to initramfs.
-	-d             Output the default cpio list.
 
 All options except -o and -l may be repeated and are interpreted
 sequentially and immediately.  -u and -g states are preserved across
@@ -36,22 +35,6 @@ to reset the root/group mapping.
 EOF
 }
 
-list_default_initramfs() {
-	echo usr/kinit/kinit \\
-}
-
-default_initramfs() {
-	cat <<-EOF >> ${output}
-		# This is a very simple, default initramfs
-
-		dir dev 0755 0 0
-		nod dev/console 0600 0 0 c 5 1
-		dir root 0700 0 0
-		file kinit usr/kinit/kinit 0755 0 0
-		slink init kinit 0755 0 0
-	EOF
-}
-
 filetype() {
 	local argv1="$1"
 
@@ -184,9 +167,7 @@ # if only one file is specified and it i
 # if a directory is specified then add all files in given direcotry to fs
 # if a regular file is specified assume it is in gen_initramfs format
 input_file() {
-	if [ "$1" == "-d" ]; then
-		${dep_list}default_initramfs
-	elif [ -f "$1" ]; then
+	if [ -f "$1" ]; then
 		is_cpio="$(echo "$1" | sed 's/^.*\.cpio/cpio/')"
 		if [ $2 -eq 0 -a ${is_cpio} == "cpio" ]; then
 			cpio_file=$1
@@ -257,8 +238,6 @@ while [ $# -gt 0 ]; do
 			;;
 		*)
 			case "$arg" in
-				"-d")	process_file "$arg" "$#"
-					;;
 				"-"*)	unknown_option
 					;;
 				*)	process_file "$arg" "$#"
diff --git a/usr/Kbuild b/usr/Kbuild
index e338cf9..bc50c48 100644
--- a/usr/Kbuild
+++ b/usr/Kbuild
@@ -53,14 +53,14 @@ #####
 # Generate the initramfs cpio archive
 
 hostprogs-y := gen_init_cpio
-ginitramfs   := $(CONFIG_SHELL) $(srctree)/scripts/gen_initramfs_list.sh
+ginitramfs  := $(CONFIG_SHELL) $(srctree)/scripts/gen_initramfs_list.sh
+ramfs-def   := $(srctree)/$(src)/initramfs.default
 ramfs-input := $(shell echo $(CONFIG_INITRAMFS_SOURCE))
-ramfs-input := $(if $(ramfs-input), $(ramfs-input), -d)
+ramfs-input := $(if $(ramfs-input), $(ramfs-input), $(ramfs-def))
 
 ramfs-args  := \
         $(if $(CONFIG_INITRAMFS_ROOT_UID), -u $(CONFIG_INITRAMFS_ROOT_UID)) \
-        $(if $(CONFIG_INITRAMFS_ROOT_GID), -g $(CONFIG_INITRAMFS_ROOT_GID)) \
-        $(ramfs-input)
+        $(if $(CONFIG_INITRAMFS_ROOT_GID), -g $(CONFIG_INITRAMFS_ROOT_GID))
 
 quiet_cmd_initfs = GEN     $@
       cmd_initfs = $(ginitramfs) -o $@ $(ramfs-args) $(ramfs-input)
diff --git a/usr/initramfs.default b/usr/initramfs.default
new file mode 100644
index 0000000..d23437a
--- /dev/null
+++ b/usr/initramfs.default
@@ -0,0 +1,9 @@
+#####################
+# This is a very simple, default initramfs
+# See gen_init_cpio for syntax
+
+dir dev 0755 0 0
+nod dev/console 0600 0 0 c 5 1
+dir root 0700 0 0
+file kinit usr/kinit/kinit 0755 0 0
+slink init kinit 0755 0 0



More information about the klibc mailing list