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

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.