All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/9] Dracut cleanups, part 2
@ 2009-02-11 11:46 Victor Lowther
       [not found] ` <215b373ce2de8b9c47c7f3bd3550c7fc96a49614.1234351770.git.victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 12+ messages in thread
From: Victor Lowther @ 2009-02-11 11:46 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

The first third of this patch series (which applies on top of my last one) 
adds three hook points into the init script:
     one just before udev kicks off, 
     one just before we try to mount the root filesystem, 
     and one just before we switch to the root filesystem. 

It moves encrypted root support and setting the initial SELinux policy to 
hooks, and adds support for resuming from hibernate.

The second two-thirds POSIX-izes all the scripts that are part of dracut that 
end up on the initramfs, and arranges for dash to be used as /bin/sh on the 
initramfs if it is available. 
--- 
Created pre-mount hook directory

This is for tasks that should run after device discovery, but before
mounting the new rootfs.  Things like cryptoroot and resume from hibernate
should go here.

Hooks are sourced, not executed as separate scripts.
---
 init                  |   16 ++++++++++------
 pre-mount/50cryptroot |    6 ++++++
 pre-mount/99resume    |    7 +++++++
 3 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/init b/init
index b12743c..0b158dc 100755
--- a/init
+++ b/init
@@ -14,9 +14,17 @@ emergency_shell()
 }
 
 getarg() {
+    local o;
     for o in $(< /proc/cmdline); do
 	[[ $o == $1 ]] && { echo $o; break; }
     done
+    return 1
+}
+
+source_all() {
+    local f
+    [[ -d $1 ]] || return
+    for f in "$d"/*; do; . "$f"; done
 }
 
 echo "Starting initrd..."
@@ -67,12 +75,8 @@ esac
 tries=0
 echo "Waiting up to 30 seconds for $root to become available"
 udevadm settle --timeout=30
-[[ -f /cryptroot ]] && {
-    echo "Encrypted root detected."
-    cryptopts=$(< /cryptroot)
-    /sbin/cryptsetup luksOpen $cryptopts || emergency_shell
-    udevadm settle --timeout=30
-}
+source_all /pre-mount
+
 echo "Trying to mount rootfs $root"
 [[ -e $root ]] || emergency_shell
 ln -s "$root" /dev/root    
diff --git a/pre-mount/50cryptroot b/pre-mount/50cryptroot
new file mode 100644
index 0000000..39e6e6e
--- /dev/null
+++ b/pre-mount/50cryptroot
@@ -0,0 +1,6 @@
+#!/bin/bash
+[[ -f /cryptroot ]] || return
+echo "Encrypted root detected."
+cryptopts=$(< /cryptroot)
+/sbin/cryptsetup luksOpen $cryptopts || emergency_shell
+udevadm settle --timeout=30
diff --git a/pre-mount/99resume b/pre-mount/99resume
new file mode 100644
index 0000000..7eacd38
--- /dev/null
+++ b/pre-mount/99resume
@@ -0,0 +1,7 @@
+#!/bin/bash
+resume=$(getarg 'resume=*') || return
+resume=${resume#resume=}
+[[ -b $resume ]] || return
+# parsing the output of ls is Bad, but until there is a better way...
+read x x x x maj min x < <(ls -lH "$resume")
+echo "${maj/,/}:$min"> /sys/power/resume
-- 
1.6.0.6

--
To unsubscribe from this list: send the line "unsubscribe initramfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 2/9] Dracut cleanups, part 2
       [not found] ` <215b373ce2de8b9c47c7f3bd3550c7fc96a49614.1234351770.git.victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2009-02-11 11:46   ` Victor Lowther
  2009-02-11 11:46   ` [PATCH 3/9] " Victor Lowther
                     ` (7 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: Victor Lowther @ 2009-02-11 11:46 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

We now have a simple hook structure and 3 defined hook points.

Any script placed in /pre-udev will be sourced just before udev starts
device scanning and loading.

Any script placed in /pre-mount will be sourced just before we try to
mount a root filesystem.

Any script placed in /pre-pivot will be sourced just before we switch to the
new root filesystem.

These hooks should be the minimum needed to add back plymouth and deal with
more advanced filesysem mounting needs (multipath, iscsi, nfs, nbd, etc.)
---
 Makefile                       |    5 ++++-
 dracut                         |    5 +++++
 init                           |   19 ++++++-------------
 pre-pivot/50selinux-loadpolicy |   10 ++++++++++
 4 files changed, 25 insertions(+), 14 deletions(-)

diff --git a/Makefile b/Makefile
index a4d1348..6d7cb68 100644
--- a/Makefile
+++ b/Makefile
@@ -4,6 +4,9 @@ all:
 install:
 	mkdir -p $(DESTDIR)/usr/libexec/dracut
 	mkdir -p $(DESTDIR)/sbin
+	mkdir -p $(DESTDIR)/usr/libexec/dracut/pre-mount
+	mkdir -p $(DESTDIR)/usr/libexec/dracut/pre-udev
+	mkdir -p $(DESTDIR)/usr/libexec/dracut/pre-pivot
 	install -m 0755 dracut $(DESTDIR)/sbin/dracut
 	install -m 0755 init $(DESTDIR)/usr/libexec/dracut/init
 	install -m 0755 switch_root $(DESTDIR)/usr/libexec/dracut/switch_root
@@ -11,7 +14,7 @@ install:
 	install -m 0755 echoer $(DESTDIR)/usr/libexec/dracut/echoer
 	mkdir $(DESTDIR)/usr/libexec/dracut/rules.d
 	for rule in rules.d/*.rules ; do install -m 0644 $$rule $(DESTDIR)/usr/libexec/dracut/rules.d ; done
-
+	for hooks in pre-*/* ; do install -m 0755 $$hook $(DESTDIR/usr/libexec/dracut ; done
 clean:
 	rm -f *~
 
diff --git a/dracut b/dracut
index 382290e..ecf58dc 100755
--- a/dracut
+++ b/dracut
@@ -110,6 +110,11 @@ fi
 cp $initfile "$initdir/init"
 cp $switchroot "$initdir/sbin/switch_root"
 cp $echoer "$initdir/echoer"
+for hookdir in $hookdirs; do
+    for hook in "$dsrc/$hookdir"/*; do
+	[[ -f $hook ]] && inst "$hook" "/$hookdir/${hook##*/}"
+    done
+done
 
 # and create some directory structure
 for d in etc proc sys sysroot dev/pts; do mkdir -p "$initdir/$d"; done
diff --git a/init b/init
index 0b158dc..611781c 100755
--- a/init
+++ b/init
@@ -23,8 +23,8 @@ getarg() {
 
 source_all() {
     local f
-    [[ -d $1 ]] || return
-    for f in "$d"/*; do; . "$f"; done
+    [[ $1 &&  -d /$1 ]] || return
+    for f in "/$1"/*; do [[ -f $f ]] && . "$f"; done
 }
 
 echo "Starting initrd..."
@@ -51,6 +51,8 @@ mknod /dev/tty0 c 4 0
 mknod /dev/tty1 c 4 1
 mknod /dev/null c 1 3
 
+source_all pre-udev
+
 # start up udev and trigger cold plugs
 udevd --daemon
 udevadm trigger >/dev/null 2>&1
@@ -75,7 +77,7 @@ esac
 tries=0
 echo "Waiting up to 30 seconds for $root to become available"
 udevadm settle --timeout=30
-source_all /pre-mount
+source_all pre-mount
 
 echo "Trying to mount rootfs $root"
 [[ -e $root ]] || emergency_shell
@@ -91,16 +93,7 @@ mount --bind /dev $NEWROOT/dev
 mount -t proc /proc $NEWROOT/proc
 mount -t sysfs /sys $NEWROOT/sys
 
-# FIXME: load selinux policy.  this should really be done after we switchroot 
-if [ -x $NEWROOT/usr/sbin/load_policy ]; then
-  chroot $NEWROOT /usr/sbin/load_policy -i
-  if (($? == 3)); then
-    echo "Initial SELinux policy load failed and enforcing mode requested."
-    echo "Not continuing"
-    sleep 100d
-    exit 1
-  fi
-fi
+source_all pre-pivot
 
 # kill off udev
 kill $(pidof udevd)
diff --git a/pre-mount/50cryptroot b/pre-mount/50cryptroot
old mode 100644
new mode 100755
diff --git a/pre-mount/99resume b/pre-mount/99resume
old mode 100644
new mode 100755
diff --git a/pre-pivot/50selinux-loadpolicy b/pre-pivot/50selinux-loadpolicy
new file mode 100755
index 0000000..8cc3133
--- /dev/null
+++ b/pre-pivot/50selinux-loadpolicy
@@ -0,0 +1,10 @@
+#!/bin/bash
+# FIXME: load selinux policy.  this should really be done after we switchroot 
+[[ -x $NEWROOT/usr/sbin/load_policy ]] || return
+chroot $NEWROOT /usr/sbin/load_policy -i
+if (($? == 3)); then
+   echo "Initial SELinux policy load failed and enforcing mode requested."
+   echo "Not continuing"
+   sleep 100d
+   exit 1
+fi
-- 
1.6.0.6

--
To unsubscribe from this list: send the line "unsubscribe initramfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 3/9] Dracut cleanups, part 2
       [not found] ` <215b373ce2de8b9c47c7f3bd3550c7fc96a49614.1234351770.git.victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  2009-02-11 11:46   ` [PATCH 2/9] " Victor Lowther
@ 2009-02-11 11:46   ` Victor Lowther
  2009-02-11 11:46   ` [PATCH 4/9] " Victor Lowther
                     ` (6 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: Victor Lowther @ 2009-02-11 11:46 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

Use inst to install hooks.

This will ensure that pathname mangling is handled correctly, and that
whatever interpreter is handling /bin/sh is installed as /bin/sh
---
 dracut |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/dracut b/dracut
index ecf58dc..aec20c0 100755
--- a/dracut
+++ b/dracut
@@ -37,6 +37,7 @@ initfile=$dsrc/init
 switchroot=$dsrc/switch_root
 rulesdir=$dsrc/rules.d
 echoer=$dsrc/echoer
+hookdirs="pre-udev pre-mount pre-pivot"
 
 initdir=$(mktemp -d -t initramfs.XXXXXX)
 trap 'rm -rf "$initdir"' 0 # clean up after ourselves no matter how we die.
-- 
1.6.0.6

--
To unsubscribe from this list: send the line "unsubscribe initramfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 4/9] Dracut cleanups, part 2
       [not found] ` <215b373ce2de8b9c47c7f3bd3550c7fc96a49614.1234351770.git.victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  2009-02-11 11:46   ` [PATCH 2/9] " Victor Lowther
  2009-02-11 11:46   ` [PATCH 3/9] " Victor Lowther
@ 2009-02-11 11:46   ` Victor Lowther
  2009-02-11 11:46   ` [PATCH 5/9] " Victor Lowther
                     ` (5 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: Victor Lowther @ 2009-02-11 11:46 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

POSIX-ize all the shell scripts that get installed to the initramfs.

Also install all the scripts using inst, so that we can install the right
shell interpreter for our scripts.  We still install bash as well.
---
 dracut                         |    6 +++---
 echoer                         |    2 +-
 init                           |   18 +++++++++---------
 pre-mount/50cryptroot          |   13 +++++++------
 pre-mount/99resume             |   17 ++++++++++-------
 pre-pivot/50selinux-loadpolicy |   19 ++++++++++---------
 6 files changed, 40 insertions(+), 35 deletions(-)

diff --git a/dracut b/dracut
index aec20c0..c5f68c7 100755
--- a/dracut
+++ b/dracut
@@ -108,9 +108,9 @@ if [ -f /etc/sysconfig/i18n ]; then
 fi
 
 # install our files
-cp $initfile "$initdir/init"
-cp $switchroot "$initdir/sbin/switch_root"
-cp $echoer "$initdir/echoer"
+inst "$initfile" "/init"
+inst "$switchroot" "/sbin/switch_root"
+inst "$echoer" "/echoer"
 for hookdir in $hookdirs; do
     for hook in "$dsrc/$hookdir"/*; do
 	[[ -f $hook ]] && inst "$hook" "/$hookdir/${hook##*/}"
diff --git a/echoer b/echoer
index 249155d..9fc7abf 100755
--- a/echoer
+++ b/echoer
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 target=$1
 shift
 echo "$@" >"$target"
\ No newline at end of file
diff --git a/init b/init
index 611781c..84ae051 100755
--- a/init
+++ b/init
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 #
 # Licensed under the GPLv2
 #
@@ -10,28 +10,28 @@ emergency_shell()
     echo ; echo
     echo "Bug in initramfs /init detected. Dropping to a shell. Good luck!"
     echo
-    bash < /dev/console
+    sh < /dev/console
 }
 
 getarg() {
     local o;
-    for o in $(< /proc/cmdline); do
-	[[ $o == $1 ]] && { echo $o; break; }
+    for o in $(cat /proc/cmdline); do
+	[ "${o%%=*}" = "$1" ] && { echo $o; break; }
     done
     return 1
 }
 
 source_all() {
     local f
-    [[ $1 &&  -d /$1 ]] || return
-    for f in "/$1"/*; do [[ -f $f ]] && . "$f"; done
+    [ "$1" ] && [  -d "/$1" ] || return
+    for f in "/$1"/*; do [ -f "$f" ] && . "$f"; done
 }
 
 echo "Starting initrd..."
 export PATH=/sbin:/bin:/usr/sbin:/usr/bin
 export TERM=linux
 
-trap "emergency_shell" 0 2
+trap "emergency_shell" 0
 # /dev/console comes from the built-in initramfs crud in the kernel
 # someday, we may need to mkdir /dev first here
 exec > /dev/console 2>&1 < /dev/console
@@ -63,7 +63,7 @@ NEWROOT="/sysroot"
 # FIXME: there's got to be a better way ...
 # it'd be nice if we had a udev rule that just did all of the bits for
 # figuring out what the specified root is and linking it /dev/root
-root=$(getarg 'root=*'); root=${root#root=}
+root=$(getarg root); root=${root#root=}
 case $root in
     LABEL=*) root=${root#LABEL=}
              root=${root//\//\\x2f}
@@ -80,7 +80,7 @@ udevadm settle --timeout=30
 source_all pre-mount
 
 echo "Trying to mount rootfs $root"
-[[ -e $root ]] || emergency_shell
+[ -e "$root" ] || emergency_shell
 ln -s "$root" /dev/root    
 mount -o ro /dev/root $NEWROOT || emergency_shell
 
diff --git a/pre-mount/50cryptroot b/pre-mount/50cryptroot
index 39e6e6e..de7eca4 100755
--- a/pre-mount/50cryptroot
+++ b/pre-mount/50cryptroot
@@ -1,6 +1,7 @@
-#!/bin/bash
-[[ -f /cryptroot ]] || return
-echo "Encrypted root detected."
-cryptopts=$(< /cryptroot)
-/sbin/cryptsetup luksOpen $cryptopts || emergency_shell
-udevadm settle --timeout=30
+#!/bin/sh
+[ -f /cryptroot ] && { 
+    echo "Encrypted root detected."
+    cryptopts=$(cat /cryptroot)
+    /sbin/cryptsetup luksOpen $cryptopts || emergency_shell
+    udevadm settle --timeout=30
+}
diff --git a/pre-mount/99resume b/pre-mount/99resume
index 7eacd38..4f1d6c3 100755
--- a/pre-mount/99resume
+++ b/pre-mount/99resume
@@ -1,7 +1,10 @@
-#!/bin/bash
-resume=$(getarg 'resume=*') || return
-resume=${resume#resume=}
-[[ -b $resume ]] || return
-# parsing the output of ls is Bad, but until there is a better way...
-read x x x x maj min x < <(ls -lH "$resume")
-echo "${maj/,/}:$min"> /sys/power/resume
+#!/bin/sh
+resume=$(getarg resume) && {
+    resume=${resume#resume=}
+    [ -b "$resume" ] && {
+        # parsing the output of ls is Bad, but until there is a better way...
+	ls -lH "$resume" | ( 
+	    read x x x x maj min x;
+	    echo "${maj%,}:$min"> /sys/power/resume)
+    }
+}
diff --git a/pre-pivot/50selinux-loadpolicy b/pre-pivot/50selinux-loadpolicy
index 8cc3133..ceece63 100755
--- a/pre-pivot/50selinux-loadpolicy
+++ b/pre-pivot/50selinux-loadpolicy
@@ -1,10 +1,11 @@
-#!/bin/bash
+#!/bin/sh
 # FIXME: load selinux policy.  this should really be done after we switchroot 
-[[ -x $NEWROOT/usr/sbin/load_policy ]] || return
-chroot $NEWROOT /usr/sbin/load_policy -i
-if (($? == 3)); then
-   echo "Initial SELinux policy load failed and enforcing mode requested."
-   echo "Not continuing"
-   sleep 100d
-   exit 1
-fi
+[ -x "$NEWROOT/usr/sbin/load_policy" ] && {
+    chroot $NEWROOT /usr/sbin/load_policy -i
+    if [ $? -eq 3 ]; then
+	echo "Initial SELinux policy load failed and enforcing mode requested."
+	echo "Not continuing"
+	sleep 100d
+	exit 1
+    fi
+}
-- 
1.6.0.6

--
To unsubscribe from this list: send the line "unsubscribe initramfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 5/9] Dracut cleanups, part 2
       [not found] ` <215b373ce2de8b9c47c7f3bd3550c7fc96a49614.1234351770.git.victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
                     ` (2 preceding siblings ...)
  2009-02-11 11:46   ` [PATCH 4/9] " Victor Lowther
@ 2009-02-11 11:46   ` Victor Lowther
  2009-02-11 11:46   ` [PATCH 6/9] " Victor Lowther
                     ` (4 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: Victor Lowther @ 2009-02-11 11:46 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

Move cat into the list of required executables

---
 dracut |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/dracut b/dracut
index c5f68c7..530524c 100755
--- a/dracut
+++ b/dracut
@@ -43,11 +43,11 @@ initdir=$(mktemp -d -t initramfs.XXXXXX)
 trap 'rm -rf "$initdir"' 0 # clean up after ourselves no matter how we die.
 
 # executables that we have to have
-exe="/bin/bash /bin/mount /bin/mknod /bin/mkdir /sbin/modprobe /sbin/udevd /sbin/udevadm /sbin/nash /sbin/pidof /bin/sleep /usr/sbin/chroot /bin/echo"
+exe="/bin/bash /bin/mount /bin/mknod /bin/mkdir /sbin/modprobe /sbin/udevd /sbin/udevadm /sbin/nash /sbin/pidof /bin/sleep /usr/sbin/chroot /bin/echo /bin/cat"
 lvmexe="/sbin/lvm"
 cryptexe="/sbin/cryptsetup"
 # and some things that are nice for debugging
-debugexe="/bin/ls /bin/cat /bin/ln /bin/ps /bin/grep /bin/more /bin/dmesg"
+debugexe="/bin/ls /bin/ln /bin/ps /bin/grep /bin/more /bin/dmesg"
 # udev things we care about
 udevexe="/lib/udev/vol_id /lib/udev/console_init"
 
-- 
1.6.0.6

--
To unsubscribe from this list: send the line "unsubscribe initramfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 6/9] Dracut cleanups, part 2
       [not found] ` <215b373ce2de8b9c47c7f3bd3550c7fc96a49614.1234351770.git.victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
                     ` (3 preceding siblings ...)
  2009-02-11 11:46   ` [PATCH 5/9] " Victor Lowther
@ 2009-02-11 11:46   ` Victor Lowther
  2009-02-11 11:46   ` [PATCH 7/9] " Victor Lowther
                     ` (3 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: Victor Lowther @ 2009-02-11 11:46 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA


Try to install file as scripts before installing them as binaries

This ensures that scripts will have their interpreter installed before
they get installed.

Also included a minor fixup that skips library checking if the binary
we are testing is already installed.
---
 dracut-functions |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/dracut-functions b/dracut-functions
index 1ded3d8..97ac626 100755
--- a/dracut-functions
+++ b/dracut-functions
@@ -59,6 +59,7 @@ inst_library() {
 inst_binary() {
     local bin="$1" target="${2:-$1}"
     local LDSO NAME IO FILE ADDR I1 n f TLIBDIR
+    [[ -f $initdir$target ]] && return 0
 
     LDSO=$(LANG=C eu-readelf -l $bin 2>/dev/null | \
 	awk '/interpreter/ {print $4}' |sed -e 's/]$//')
@@ -122,7 +123,7 @@ inst() {
         return 1
     fi
     local src=$1 dest=${2:-$1}
-    for x in inst_symlink inst_binary inst_script inst_simple; do
+    for x in inst_symlink inst_script inst_binary inst_simple; do
 	$x "$src" "$dest" && return 0
     done
     return 1
-- 
1.6.0.6

--
To unsubscribe from this list: send the line "unsubscribe initramfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 7/9] Dracut cleanups, part 2
       [not found] ` <215b373ce2de8b9c47c7f3bd3550c7fc96a49614.1234351770.git.victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
                     ` (4 preceding siblings ...)
  2009-02-11 11:46   ` [PATCH 6/9] " Victor Lowther
@ 2009-02-11 11:46   ` Victor Lowther
  2009-02-11 11:46   ` [PATCH 8/9] " Victor Lowther
                     ` (2 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: Victor Lowther @ 2009-02-11 11:46 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

Missed some non-POSIX substitution in root filesystem label parsing.

---
 init |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/init b/init
index 84ae051..4b36e69 100755
--- a/init
+++ b/init
@@ -10,7 +10,7 @@ emergency_shell()
     echo ; echo
     echo "Bug in initramfs /init detected. Dropping to a shell. Good luck!"
     echo
-    sh < /dev/console
+    exec sh -i
 }
 
 getarg() {
@@ -34,7 +34,7 @@ export TERM=linux
 trap "emergency_shell" 0
 # /dev/console comes from the built-in initramfs crud in the kernel
 # someday, we may need to mkdir /dev first here
-exec > /dev/console 2>&1 < /dev/console
+# exec > /dev/console 2>&1 < /dev/console
 
 # mount some important things
 mount -t proc /proc /proc
@@ -66,7 +66,7 @@ NEWROOT="/sysroot"
 root=$(getarg root); root=${root#root=}
 case $root in
     LABEL=*) root=${root#LABEL=}
-             root=${root//\//\\x2f}
+             root="$(echo $root |sed 's,/,\\x2f,g')"
 	     root="/dev/disk/by-label/${root}" ;;
     UUID=*) root="/dev/disk/by-uuid/${root#UUID=}" ;;
     '') echo "Warning: no root specified"
-- 
1.6.0.6

--
To unsubscribe from this list: send the line "unsubscribe initramfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 8/9] Dracut cleanups, part 2
       [not found] ` <215b373ce2de8b9c47c7f3bd3550c7fc96a49614.1234351770.git.victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
                     ` (5 preceding siblings ...)
  2009-02-11 11:46   ` [PATCH 7/9] " Victor Lowther
@ 2009-02-11 11:46   ` Victor Lowther
  2009-02-11 11:46   ` [PATCH 9/9] " Victor Lowther
  2009-02-11 22:07   ` [PATCH 1/9] " Karel Zak
  8 siblings, 0 replies; 12+ messages in thread
From: Victor Lowther @ 2009-02-11 11:46 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

Prefer /bin/dash as /bin/sh on the initrd if it is available.

This is mainly for testing purposes -- if something non-POSIX is added to the
on initrd scripts, dash will die horribly.
---
 dracut |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/dracut b/dracut
index 530524c..186d6ad 100755
--- a/dracut
+++ b/dracut
@@ -43,7 +43,7 @@ initdir=$(mktemp -d -t initramfs.XXXXXX)
 trap 'rm -rf "$initdir"' 0 # clean up after ourselves no matter how we die.
 
 # executables that we have to have
-exe="/bin/bash /bin/mount /bin/mknod /bin/mkdir /sbin/modprobe /sbin/udevd /sbin/udevadm /sbin/nash /sbin/pidof /bin/sleep /usr/sbin/chroot /bin/echo /bin/cat"
+exe="/bin/bash /bin/mount /bin/mknod /bin/mkdir /sbin/modprobe /sbin/udevd /sbin/udevadm /sbin/nash /sbin/pidof /bin/sleep /usr/sbin/chroot /bin/echo /bin/cat /bin/sed"
 lvmexe="/sbin/lvm"
 cryptexe="/sbin/cryptsetup"
 # and some things that are nice for debugging
@@ -56,6 +56,12 @@ for binary in $exe $debugexe $udevexe $lvmexe $cryptexe ; do
   inst $binary
 done
 
+# Prefer dash as /bin/sh if it is available.
+if [[ -f /bin/dash ]]; then
+    inst /bin/dash
+    ln -sf /bin/dash "${initdir}/bin/sh"
+fi
+
 # FIXME: would be nice if we didn't have to know which rules to grab....
 # ultimately, /lib/initramfs/rules.d or somesuch which includes links/copies
 # of the rules we want so that we just copy those in would be best
-- 
1.6.0.6

--
To unsubscribe from this list: send the line "unsubscribe initramfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 9/9] Dracut cleanups, part 2
       [not found] ` <215b373ce2de8b9c47c7f3bd3550c7fc96a49614.1234351770.git.victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
                     ` (6 preceding siblings ...)
  2009-02-11 11:46   ` [PATCH 8/9] " Victor Lowther
@ 2009-02-11 11:46   ` Victor Lowther
  2009-02-11 22:07   ` [PATCH 1/9] " Karel Zak
  8 siblings, 0 replies; 12+ messages in thread
From: Victor Lowther @ 2009-02-11 11:46 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

Rearranged dracut script to make it easier to split things out for 
modularization.

---
 dracut |   55 +++++++++++++++++++++++++++++++++----------------------
 1 files changed, 33 insertions(+), 22 deletions(-)

diff --git a/dracut b/dracut
index 186d6ad..30f0f9d 100755
--- a/dracut
+++ b/dracut
@@ -42,6 +42,11 @@ hookdirs="pre-udev pre-mount pre-pivot"
 initdir=$(mktemp -d -t initramfs.XXXXXX)
 trap 'rm -rf "$initdir"' 0 # clean up after ourselves no matter how we die.
 
+# Create some directory structure first
+for d in bin sbin usr/bin usr/sbin usr/lib etc proc sys sysroot dev/pts; do 
+    mkdir -p "$initdir/$d"; 
+done
+
 # executables that we have to have
 exe="/bin/bash /bin/mount /bin/mknod /bin/mkdir /sbin/modprobe /sbin/udevd /sbin/udevadm /sbin/nash /sbin/pidof /bin/sleep /usr/sbin/chroot /bin/echo /bin/cat /bin/sed"
 lvmexe="/sbin/lvm"
@@ -51,7 +56,7 @@ debugexe="/bin/ls /bin/ln /bin/ps /bin/grep /bin/more /bin/dmesg"
 # udev things we care about
 udevexe="/lib/udev/vol_id /lib/udev/console_init"
 
-# install base files
+# install base executables
 for binary in $exe $debugexe $udevexe $lvmexe $cryptexe ; do
   inst $binary
 done
@@ -62,6 +67,26 @@ if [[ -f /bin/dash ]]; then
     ln -sf /bin/dash "${initdir}/bin/sh"
 fi
 
+# install our scripts and hooks
+inst "$initfile" "/init"
+inst "$switchroot" "/sbin/switch_root"
+inst "$echoer" "/echoer"
+for hookdir in $hookdirs; do
+    for hook in "$dsrc/$hookdir"/*; do
+	[[ -f $hook ]] && inst "$hook" "/$hookdir/${hook##*/}"
+    done
+done
+
+# FIXME: hard-coded module list of doom.
+[[ $modules ]] || modules="=ata =block =drm dm-crypt aes sha256 cbc"
+
+instmods $modules
+
+# Grab modules for all filesystem types we currently have mounted
+while read d mp t rest; do
+    instmods "$t"
+done </proc/mounts
+
 # FIXME: would be nice if we didn't have to know which rules to grab....
 # ultimately, /lib/initramfs/rules.d or somesuch which includes links/copies
 # of the rules we want so that we just copy those in would be best
@@ -73,6 +98,8 @@ done
 # terminfo bits make things work better if you fall into interactive mode
 for f in $(find /lib/terminfo -type f) ; do cp  --parents $f "$initdir" ; done
 
+## this stuff should be moved out of the main dracut script
+
 # FIXME: i18n stuff isn't really distro-independent :/
 if [[ -f /etc/sysconfig/keyboard || -f /etc/sysconfig/console/default.kmap ]]; then
     if [ -f /etc/sysconfig/console/default.kmap ]; then
@@ -113,31 +140,15 @@ if [ -f /etc/sysconfig/i18n ]; then
     [[ $UNIMAP ]] && inst /lib/kbd/unimaps/$UNIMAP
 fi
 
-# install our files
-inst "$initfile" "/init"
-inst "$switchroot" "/sbin/switch_root"
-inst "$echoer" "/echoer"
-for hookdir in $hookdirs; do
-    for hook in "$dsrc/$hookdir"/*; do
-	[[ -f $hook ]] && inst "$hook" "/$hookdir/${hook##*/}"
-    done
-done
-
-# and create some directory structure
-for d in etc proc sys sysroot dev/pts; do mkdir -p "$initdir/$d"; done
-# FIXME: hard-coded module list of doom.
-[[ $modules ]] || modules="=ata =block =drm dm-crypt aes sha256 cbc"
-
-instmods $modules
-
-# Grab modules for all filesystem types we currently know about
-while read d mp t rest; do
-    instmods "$t"
-done </proc/mounts
+## final stuff that has to happen
 
+# generate module dependencies for the initrd
 /sbin/depmod -a -b "$initdir" $kernel || {
     error "\"/sbin/depmod -a $kernel\" failed."
     exit 1
 }
 
+# make sure that library links are correct and up to date
+ldconfig -r "$initdir"
+
 ( cd "$initdir"; find . |cpio -H newc -o |gzip -9 > "$outfile"; )
-- 
1.6.0.6

--
To unsubscribe from this list: send the line "unsubscribe initramfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/9] Dracut cleanups, part 2
       [not found] ` <215b373ce2de8b9c47c7f3bd3550c7fc96a49614.1234351770.git.victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
                     ` (7 preceding siblings ...)
  2009-02-11 11:46   ` [PATCH 9/9] " Victor Lowther
@ 2009-02-11 22:07   ` Karel Zak
       [not found]     ` <20090211220712.GC21052-sHeGUpI7y9L/9pzu0YdTqQ@public.gmane.org>
  8 siblings, 1 reply; 12+ messages in thread
From: Karel Zak @ 2009-02-11 22:07 UTC (permalink / raw)
  To: Victor Lowther; +Cc: initramfs-u79uwXL29TY76Z2rM5mHXA

On Wed, Feb 11, 2009 at 03:46:38AM -0800, Victor Lowther wrote:
> +# parsing the output of ls is Bad, but until there is a better way...
> +read x x x x maj min x < <(ls -lH "$resume")

  read maj min < <(stat --format="%t %T" "$resume")

> +echo "${maj/,/}:$min"> /sys/power/resume

    Karel

-- 
 Karel Zak  <kzak-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
--
To unsubscribe from this list: send the line "unsubscribe initramfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/9] Dracut cleanups, part 2
       [not found]     ` <20090211220712.GC21052-sHeGUpI7y9L/9pzu0YdTqQ@public.gmane.org>
@ 2009-02-11 22:35       ` Victor Lowther
       [not found]         ` <921e043f0902111435v54ee1bc1yb44ce3f745459f10-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 12+ messages in thread
From: Victor Lowther @ 2009-02-11 22:35 UTC (permalink / raw)
  To: Karel Zak; +Cc: initramfs-u79uwXL29TY76Z2rM5mHXA

On Wed, Feb 11, 2009 at 4:07 PM, Karel Zak <kzak-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> wrote:
> On Wed, Feb 11, 2009 at 03:46:38AM -0800, Victor Lowther wrote:
>> +# parsing the output of ls is Bad, but until there is a better way...
>> +read x x x x maj min x < <(ls -lH "$resume")
>
>  read maj min < <(stat --format="%t %T" "$resume")

Indeed, but that adds yet another executable to the initrd.

>> +echo "${maj/,/}:$min"> /sys/power/resume
>
>    Karel
>
> --
>  Karel Zak  <kzak-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
>
--
To unsubscribe from this list: send the line "unsubscribe initramfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/9] Dracut cleanups, part 2
       [not found]         ` <921e043f0902111435v54ee1bc1yb44ce3f745459f10-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2009-02-11 23:17           ` Karel Zak
  0 siblings, 0 replies; 12+ messages in thread
From: Karel Zak @ 2009-02-11 23:17 UTC (permalink / raw)
  To: Victor Lowther; +Cc: initramfs-u79uwXL29TY76Z2rM5mHXA

On Wed, Feb 11, 2009 at 04:35:00PM -0600, Victor Lowther wrote:
> On Wed, Feb 11, 2009 at 4:07 PM, Karel Zak <kzak-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> wrote:
> > On Wed, Feb 11, 2009 at 03:46:38AM -0800, Victor Lowther wrote:
> >> +# parsing the output of ls is Bad, but until there is a better way...
> >> +read x x x x maj min x < <(ls -lH "$resume")
> >
> >  read maj min < <(stat --format="%t %T" "$resume")
> 
> Indeed, but that adds yet another executable to the initrd.

 I don't see ls(1) at any other place than here. It seems you can
 remove ls(1) and add stat(1).

 BTW (Fedora 10):

$ ls -la /bin/ls /usr/bin/stat
-rwxr-xr-x 1 root root 114400 2008-11-21 16:33 /bin/ls
-rwxr-xr-x 1 root root  56584 2008-11-21 16:33 /usr/bin/stat

$ ldd /bin/ls
        linux-vdso.so.1 =>  (0x00007fffdf9ff000)
        librt.so.1 => /lib64/librt.so.1 (0x0000003779c00000)
        libselinux.so.1 => /lib64/libselinux.so.1 (0x0000003779800000)
        libcap.so.2 => /lib64/libcap.so.2 (0x0000003782200000)
        libacl.so.1 => /lib64/libacl.so.1 (0x0000003779400000)
        libc.so.6 => /lib64/libc.so.6 (0x0000003778400000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x0000003779000000)
        /lib64/ld-linux-x86-64.so.2 (0x0000003778000000)
        libdl.so.2 => /lib64/libdl.so.2 (0x0000003778c00000)
        libattr.so.1 => /lib64/libattr.so.1 (0x0000003783600000)

$ ldd /usr/bin/stat
        linux-vdso.so.1 =>  (0x00007fff5a1fe000)
        libselinux.so.1 => /lib64/libselinux.so.1 (0x0000003779800000)
        libc.so.6 => /lib64/libc.so.6 (0x0000003778400000)
        libdl.so.2 => /lib64/libdl.so.2 (0x0000003778c00000)
        /lib64/ld-linux-x86-64.so.2 (0x0000003778000000)


    Karel

-- 
 Karel Zak  <kzak-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
--
To unsubscribe from this list: send the line "unsubscribe initramfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2009-02-11 23:17 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-11 11:46 [PATCH 1/9] Dracut cleanups, part 2 Victor Lowther
     [not found] ` <215b373ce2de8b9c47c7f3bd3550c7fc96a49614.1234351770.git.victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2009-02-11 11:46   ` [PATCH 2/9] " Victor Lowther
2009-02-11 11:46   ` [PATCH 3/9] " Victor Lowther
2009-02-11 11:46   ` [PATCH 4/9] " Victor Lowther
2009-02-11 11:46   ` [PATCH 5/9] " Victor Lowther
2009-02-11 11:46   ` [PATCH 6/9] " Victor Lowther
2009-02-11 11:46   ` [PATCH 7/9] " Victor Lowther
2009-02-11 11:46   ` [PATCH 8/9] " Victor Lowther
2009-02-11 11:46   ` [PATCH 9/9] " Victor Lowther
2009-02-11 22:07   ` [PATCH 1/9] " Karel Zak
     [not found]     ` <20090211220712.GC21052-sHeGUpI7y9L/9pzu0YdTqQ@public.gmane.org>
2009-02-11 22:35       ` Victor Lowther
     [not found]         ` <921e043f0902111435v54ee1bc1yb44ce3f745459f10-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2009-02-11 23:17           ` Karel Zak

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.