Provides a framework and initial modules for initramfs
cover Provides a framework and initial modules for initramfs
This patchset adds a very flexible and powerful initramfs framework together with a small set of modules using it. Please refer to each commit for the respective documentation.
The following changes since commit fb642d21111691b9302e16e984aff9d8fb18c431:
buildhistory bbclass: avoid absolute paths for files-in-image.txt to avoid diff churn when relocating TMPDIR (2011-12-06 14:40:00 +0000)
are available in the git repository at:
git://github.com/OSSystems/oe-core master
https://github.com/OSSystems/oe-core/tree/HEAD
Otavio Salvador (5):
initramfs-base: provides the base for a modular initramfs
initramfs-module-debug: add
initramfs-module-mdev: add
initramfs-module-e2fs: add
initramfs-module-udev: add
.../initrdscripts/initramfs-base/finish | 42 ++++++ .../recipes-core/initrdscripts/initramfs-base/init | 136 ++++++++++++++++++++ .../initrdscripts/initramfs-base_1.0.bb | 17 +++ .../initrdscripts/initramfs-module-debug/debug | 82 ++++++++++++ .../initrdscripts/initramfs-module-debug_1.0.bb | 15 ++ .../initrdscripts/initramfs-module-e2fs/e2fs | 28 ++++ .../initrdscripts/initramfs-module-e2fs_1.0.bb | 15 ++ .../initrdscripts/initramfs-module-mdev/mdev | 30 +++++ .../initrdscripts/initramfs-module-mdev_1.0.bb | 16 +++ .../initrdscripts/initramfs-module-udev/udev | 22 +++ .../initrdscripts/initramfs-module-udev_1.0.bb | 16 +++ 11 files changed, 419 insertions(+), 0 deletions(-) create mode 100755 meta/recipes-core/initrdscripts/initramfs-base/finish create mode 100755 meta/recipes-core/initrdscripts/initramfs-base/init create mode 100644 meta/recipes-core/initrdscripts/initramfs-base_1.0.bb create mode 100644 meta/recipes-core/initrdscripts/initramfs-module-debug/debug create mode 100644 meta/recipes-core/initrdscripts/initramfs-module-debug_1.0.bb create mode 100755 meta/recipes-core/initrdscripts/initramfs-module-e2fs/e2fs create mode 100644 meta/recipes-core/initrdscripts/initramfs-module-e2fs_1.0.bb create mode 100644 meta/recipes-core/initrdscripts/initramfs-module-mdev/mdev create mode 100644 meta/recipes-core/initrdscripts/initramfs-module-mdev_1.0.bb create mode 100644 meta/recipes-core/initrdscripts/initramfs-module-udev/udev create mode 100644 meta/recipes-core/initrdscripts/initramfs-module-udev_1.0.bb
Signature · 1 line
1.7.2.5
PATCH 1/5 initramfs-base: provides the base for a modular initramfs
Provides the API to be used by the initramfs module. The modules need to provide the following functions:
<module>_enabled : check if the module ought to run (return 1 to skip)
<module>_run : do what is need
Boot parameters are available on environment in the as:
'foo=value' as 'bootparam_foo=value'
'foo' as 'bootparam_foo=true'
Another possibility is to add hooks to be run before and/or after a module to be run, allowing for fancy features as dynamic debug shells and like.
--- .../initrdscripts/initramfs-base/finish | 42 ++++++ .../recipes-core/initrdscripts/initramfs-base/init | 136 ++++++++++++++++++++ .../initrdscripts/initramfs-base_1.0.bb | 17 +++ 3 files changed, 195 insertions(+), 0 deletions(-) create mode 100755 meta/recipes-core/initrdscripts/initramfs-base/finish create mode 100755 meta/recipes-core/initrdscripts/initramfs-base/init create mode 100644 meta/recipes-core/initrdscripts/initramfs-base_1.0.bb
meta/recipes-core/initrdscripts/initramfs-base/finish new file +42 -0
@@ -0,0 +1,42 @@ +#!/bin/sh +# Copyright (C) 2011 O.S. Systems Software LTDA. +# Licensed on MIT + +finish_enabled() { + return 0 +} + +finish_run() { + if [ -n "$ROOTFS_DIR" ]; then + if [ -n "$bootparam_rootdelay" ]; then + debug "Sleeping for $rootdelay second(s) to wait root to settle..." + sleep $bootparam_rootdelay + fi + + if [ -n "$bootparam_root" ]; then + debug "No e2fs compatible filesystem has been mounted, mounting $bootparam_root..." + + if [ -e "$bootparam_root" ]; then + mount $bootparam_root $ROOTFS_DIR + else + debug "root '$bootparam_root' doesn't exist." + fi + fi + + if [ ! -d $ROOTFS_DIR/dev ]; then + fatal "ERROR: There's no '/dev' on rootfs." + fi + + info "Switching root to '$ROOTFS_DIR'..." + + debug "Moving /dev, /proc and /sys onto rootfs..." + mount --move /dev $ROOTFS_DIR/dev + mount --move /proc $ROOTFS_DIR/proc + mount --move /sys $ROOTFS_DIR/sys + + cd $ROOTFS_DIR + exec switch_root -c /dev/console $ROOTFS_DIR /sbin/init + else + debug "No rootfs has been set" + fi +}
meta/recipes-core/initrdscripts/initramfs-base/init new file +136 -0
136 lines not on this page · raw message
meta/recipes-core/initrdscripts/initramfs-base_1.0.bb new file +17 -0
@@ -0,0 +1,17 @@ +DESCRIPTION = "initramfs modular system base" +LICENSE = "MIT" +LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420" +RDEPENDS = "busybox" + +inherit allarch + +SRC_URI = "file://init \ + file://finish" + +do_install() { + install -d ${D}/init.d + install -m 0755 ${WORKDIR}/init ${D}/init + install -m 0755 ${WORKDIR}/finish ${D}/init.d/99-finish +} + +FILES_${PN} = "/init /init.d/*"
Signature · 1 line
1.7.2.5
PATCH 2/5 initramfs-module-debug: add
In reply to Otavio SalvadorAdds support to dynamic debugging of initramfs using bootparam in following format:
- shell : starts a shell before and after each module
- shell=before:<module> : starts a shell before <module> is loaded and run
- shell=after:<module> : starts a shell after <module> is loaded and run
- shell-debug : run set -x as soon as possible
- shell-debug=before:<module> : run set -x before <module> is loaded and run
- shell-debug=after:<module> : run set -x after <module> is loaded and run
--- .../initrdscripts/initramfs-module-debug/debug | 82 ++++++++++++++++++++ .../initrdscripts/initramfs-module-debug_1.0.bb | 15 ++++ 2 files changed, 97 insertions(+), 0 deletions(-) create mode 100644 meta/recipes-core/initrdscripts/initramfs-module-debug/debug create mode 100644 meta/recipes-core/initrdscripts/initramfs-module-debug_1.0.bb
meta/recipes-core/initrdscripts/initramfs-module-debug/debug new file +82 -0
@@ -0,0 +1,82 @@ +#!/bin/sh +# Copyright (C) 2011 O.S. Systems Software LTDA. +# Licensed on MIT + +# Adds support to dynamic debugging of initramfs using bootparam in +# following format: +# shell : starts a shell before and after each module +# shell=before:<module> : starts a shell before <module> is loaded and run +# shell=after:<module> : starts a shell after <module> is loaded and run +# +# shell-debug : run set -x as soon as possible +# shell-debug=before:<module> : run set -x before <module> is loaded and run +# shell-debug=after:<module> : run set -x after <module> is loaded and run + +DEBUG_SHELL="false" + +debug_hook_handler() { + status=$1 + module=$2 + + if [ -n "$bootparam_shell" ] && [ "$bootparam_shell" != "true" ]; then + shell_wanted_status=`expr $bootparam_shell : '\(.*\):.*'` + shell_wanted_module=`expr $bootparam_shell : '.*:\(.*\)'` + + if [ "$shell_wanted_status" = "before" ]; then + shell_wanted_status=pre + else + shell_wanted_status=post + fi + fi + + if [ "$bootparam_shell" = "true" ] || + ( [ "$status" = "$shell_wanted_status" ] && + [ "$module" = "$shell_wanted_module" ] ); then + if [ "$status" = "pre" ]; then + status_msg="before" + else + status_msg="after" + fi + + msg "Starting shell $status_msg $module..." + sh + fi + + if [ -n "$bootparam_shell_debug" ] && [ "$bootparam_shell_debug" != "true" ]; then + shell_debug_wanted_status=`expr $bootparam_shell_debug : '\(.*\):.*'` + shell_debug_wanted_module=`expr $bootparam_shell_debug : '.*:\(.*\)'` + + if [ "$shell_debug_wanted_status" = "before" ]; then + shell_debug_wanted_status=pre + else + shell_debug_wanted_status=post + fi + fi + + if [ "$bootparam_shell_debug" = "true" ] || + ( [ "$status" = "$shell_debug_wanted_status" ] && + [ "$module" = "$shell_debug_wanted_module" ] ); then + if [ "$DEBUG_SHELL" = "true" ]; then + return 0 + fi + + if [ "$status" = "pre" ]; then + status_msg="before" + else + status_msg="after" + fi + + msg "Starting shell debugging $status_msg $module..." + DEBUG_SHELL="true" + set -x + fi +} + +debug_enabled() { + return 0 +} + +debug_run() { + add_module_pre_hook "debug_hook_handler" + add_module_post_hook "debug_hook_handler" +}
meta/recipes-core/initrdscripts/initramfs-module-debug_1.0.bb new file +15 -0
@@ -0,0 +1,15 @@ +DESCRIPTION = "initramfs debug helper" +LICENSE = "MIT" +LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420" +RDEPENDS = "initramfs-base" + +inherit allarch + +SRC_URI = "file://debug" + +do_install() { + install -d ${D}/init.d + install -m 0755 ${WORKDIR}/debug ${D}/init.d/00-debug +} + +FILES_${PN} = "/init.d/*"
Signature · 1 line
1.7.2.5
PATCH 3/5 initramfs-module-mdev: add
In reply to Otavio Salvador--- .../initrdscripts/initramfs-module-mdev/mdev | 30 ++++++++++++++++++++ .../initrdscripts/initramfs-module-mdev_1.0.bb | 16 ++++++++++ 2 files changed, 46 insertions(+), 0 deletions(-) create mode 100644 meta/recipes-core/initrdscripts/initramfs-module-mdev/mdev create mode 100644 meta/recipes-core/initrdscripts/initramfs-module-mdev_1.0.bb
meta/recipes-core/initrdscripts/initramfs-module-mdev/mdev new file +30 -0
@@ -0,0 +1,30 @@ +#!/bin/sh +# Copyright (C) 2011 O.S. Systems Software LTDA. +# Licensed on MIT + +mdev_enabled() { + if [ ! -e /sbin/mdev ]; then + debug "/sbin/mdev doesn't exist" + return 1 + fi + + return 0 +} + +mdev_run() { + # setup the environment + mount -t tmpfs tmpfs /dev + + mkdir -m 1777 /dev/shm + + mkdir -m 0755 /dev/pts + mount -t devpts devpts /dev/pts + + echo /sbin/mdev > /proc/sys/kernel/hotplug + mdev -s + + # load modules for devices + find /sys -name modalias | while read m; do + load_kernel_module $(cat $m) + done +}
meta/recipes-core/initrdscripts/initramfs-module-mdev_1.0.bb new file +16 -0
@@ -0,0 +1,16 @@ +DESCRIPTION = "initramfs support for mdev" +LICENSE = "MIT" +LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420" +RDEPENDS = "initramfs-base" +RCONFLICTS = "initramfs-module-udev" + +inherit allarch + +SRC_URI = "file://mdev" + +do_install() { + install -d ${D}/init.d + install -m 0755 ${WORKDIR}/mdev ${D}/init.d/01-mdev +} + +FILES_${PN} = "/init.d/*"
Signature · 1 line
1.7.2.5
PATCH 4/5 initramfs-module-e2fs: add
In reply to Otavio Salvador--- .../initrdscripts/initramfs-module-e2fs/e2fs | 28 ++++++++++++++++++++ .../initrdscripts/initramfs-module-e2fs_1.0.bb | 15 ++++++++++ 2 files changed, 43 insertions(+), 0 deletions(-) create mode 100755 meta/recipes-core/initrdscripts/initramfs-module-e2fs/e2fs create mode 100644 meta/recipes-core/initrdscripts/initramfs-module-e2fs_1.0.bb
meta/recipes-core/initrdscripts/initramfs-module-e2fs/e2fs new file +28 -0
@@ -0,0 +1,28 @@ +#!/bin/sh +# Copyright (C) 2011 O.S. Systems Software LTDA. +# Licensed on MIT + +e2fs_enabled() { + return 0 +} + +e2fs_run() { + filesystems="ext4 ext3 ext2" + + # load modules + for fs in $filesystems; do + load_kernel_module $fs + done + + for fs in $filesystems; do + eval "fs_options=\$bootparam_${fs}" + if [ -n "$fs_options" ]; then + dev=`expr "$fs_options" : '\([^:]*\).*'` + path=`expr "$fs_options" : '[^:]*:\([^:]*\).*'` + + info "Mounting $dev as $fs on $path as $fs..." + mkdir -p $path + mount -t $fs $dev $path + fi + done +}
meta/recipes-core/initrdscripts/initramfs-module-e2fs_1.0.bb new file +15 -0
@@ -0,0 +1,15 @@ +DESCRIPTION = "initramfs support for ext2/ext3/ext3" +LICENSE = "MIT" +LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420" +RDEPENDS = "initramfs-base" + +inherit allarch + +SRC_URI = "file://e2fs" + +do_install() { + install -d ${D}/init.d + install -m 0755 ${WORKDIR}/e2fs ${D}/init.d/20-e2fs +} + +FILES_${PN} = "/init.d/*"
Signature · 1 line
1.7.2.5
PATCH 5/5 initramfs-module-udev: add
In reply to Otavio Salvador--- .../initrdscripts/initramfs-module-udev/udev | 22 ++++++++++++++++++++ .../initrdscripts/initramfs-module-udev_1.0.bb | 16 ++++++++++++++ 2 files changed, 38 insertions(+), 0 deletions(-) create mode 100644 meta/recipes-core/initrdscripts/initramfs-module-udev/udev create mode 100644 meta/recipes-core/initrdscripts/initramfs-module-udev_1.0.bb
meta/recipes-core/initrdscripts/initramfs-module-udev/udev new file +22 -0
@@ -0,0 +1,22 @@ +#!/bin/sh +# Copyright (C) 2011 O.S. Systems Software LTDA. +# Licensed on MIT + +udev_enabled() { + if [ ! -e /sbin/udevd ]; then + debug "/sbin/udev doesn't exist" + return 1 + fi + + return 0 +} + +udev_run() { + mkdir -p /run + + udevd --daemon > /dev/null + udevadm trigger --action=add + udevadm settle + + killall udevd 2>/dev/null +}
meta/recipes-core/initrdscripts/initramfs-module-udev_1.0.bb new file +16 -0
@@ -0,0 +1,16 @@ +DESCRIPTION = "initramfs support for udev" +LICENSE = "MIT" +LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420" +RDEPENDS = "initramfs-base udev udev-utils" +RCONFLICTS = "initramfs-module-mdev" + +inherit allarch + +SRC_URI = "file://udev" + +do_install() { + install -d ${D}/init.d + install -m 0755 ${WORKDIR}/udev ${D}/init.d/01-udev +} + +FILES_${PN} = "/init.d/*"
Signature · 1 line
1.7.2.5
Quoted 12 lines · Otavio Salvador
This patchset adds a very flexible and powerful initramfs framework together with a small set of modules using it. Please refer to each commit for the respective documentation.
The following changes since commit
fb642d21111691b9302e16e984aff9d8fb18c431:buildhistory bbclass: avoid absolute paths for files-in-image.txt to avoid diff churn when relocating TMPDIR (2011-12-06 14:40:00 +0000)
are available in the git repository at:
git://github.com/OSSystems/oe-coremaster
https://github.com/OSSystems/oe-core/tree/HEAD
Quoted 7 lines
Otavio Salvador (5):
initramfs-base: provides the base for a modular initramfs
initramfs-module-debug: add
initramfs-module-mdev: add
initramfs-module-e2fs: add
initramfs-module-udev: add
Rather than add five different recipes for this, could we have one recipe with five different packages? I'm a little bit sensitive to parsing speed and whilst its a detail, small details add up :)
Cheers,
Richard
Quoted 4 lines · Richard Purdie
Rather than add five different recipes for this, could we have one recipe with five different packages? I'm a little bit sensitive to parsing speed and whilst its a detail, small details add up :)
Yes; that works for me.
Besides that, are you OK with that?
Signature · 3 lines
Otavio Salvador O.S. Systems E-mail: [email protected] http://www.ossystems.com.br Mobile: +55 53 9981-7854 http://projetos.ossystems.com.br