All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 02/18] No need to quote variable expansion in [[ ]]
       [not found] ` <0b90cfaa9ff10f594018fdcc686fe1b7a3924e4f.1250455879.git.victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
                     ` (10 preceding siblings ...)
  2009-08-16 21:14   ` [PATCH 03/18] Update dracut-catimages to make it much more robust Victor Lowther
@ 2009-08-16 21:14   ` Victor Lowther
  2009-08-16 21:14   ` [PATCH 12/18] Tighten up lvm hostonly checking Victor Lowther
                     ` (4 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: Victor Lowther @ 2009-08-16 21:14 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

---
 dracut |   18 +++++++++---------
 1 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/dracut b/dracut
index 78cd2ef..6d4fccb 100755
--- a/dracut
+++ b/dracut
@@ -155,7 +155,7 @@ chmod 755 "$initdir"
 export initdir hookdirs dsrc dracutmodules drivers \
     fw_dir drivers_dir debug beverbose no_kernel kernel_only
 
-if [[ "$kernel_only" != "yes" ]]; then
+if [[ $kernel_only != yes ]]; then
     # Create some directory structure first
     for d in bin sbin usr/bin usr/sbin usr/lib etc proc sys sysroot tmp dev/pts var/run; do 
 	mkdir -p "$initdir/$d"; 
@@ -170,11 +170,11 @@ check_modules
 for moddir in "$dsrc/modules.d"/[0-9][0-9]*; do
     mod=${moddir##*/}; mod=${mod#[0-9][0-9]}
     if strstr "$mods_to_load" " $mod "; then
-	if [[ "$kernel_only" = "yes" ]]; then
-	    [[ -x "$moddir/installkernel" ]] && . "$moddir/installkernel"
+	if [[ $kernel_only = yes ]]; then
+	    [[ -x $moddir/installkernel ]] && . "$moddir/installkernel"
 	else
 	    . "$moddir/install"
-	    if [[ "$no_kernel" != "yes" && -x "$moddir/installkernel" ]]; then
+	    if [[ $no_kernel != yes && -x $moddir/installkernel ]]; then
 		. "$moddir/installkernel"
 	    fi
 	fi
@@ -187,7 +187,7 @@ echo $mods_to_load
 ## final stuff that has to happen
 
 # generate module dependencies for the initrd
-if [ -d "$initdir/lib/modules/$kernel" ]; then
+if [[ -d $initdir/lib/modules/$kernel ]]; then
     if ! depmod -a -b "$initdir" $kernel; then
         echo "\"depmod -a $kernel\" failed."
         exit 1
@@ -207,10 +207,10 @@ for item in $install_items; do
 done
 unset item
 
-[[ "$beverbose" = "yes" ]] && (du -c "$initdir" | sort -n)
+[[ $beverbose = yes ]] && (du -c "$initdir" | sort -n)
 
 # strip binaries 
-if [ "$do_strip" = "yes" ] ; then
+if [[ $do_strip = yes ]] ; then
     for p in strip objdump sed grep find; do 
 	if ! which $p >/dev/null 2>&1; then
 	    derror "Could not find '$p'. You should run $0 with '--nostrip'."
@@ -219,7 +219,7 @@ if [ "$do_strip" = "yes" ] ; then
     done
 fi
 
-if [ "$do_strip" = "yes" ] ; then
+if [[ $do_strip = yes ]] ; then
     for f in $(find "$initdir" -type f \( -perm -0100 -or -perm -0010 -or -perm -0001 \) -exec file {} \; | 
 	grep -v ' shared object,' | 
 	sed -n -e 's/^\(.*\):[ 	]*ELF.*, not stripped/\1/p'); do
@@ -240,7 +240,7 @@ fi
 
 ( cd "$initdir"; find . |cpio -R 0:0 -H newc -o |gzip -9 > "$outfile"; )
 
-[[ "$beverbose" = "yes" ]] && ls -lh "$outfile"
+[[ $beverbose = yes ]] && ls -lh "$outfile"
 
 exit 0
 
-- 
1.6.0.4

--
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] 18+ messages in thread

* [PATCH 06/18] Simplify dracut_install a bit, an make a minor fixup to check_module_deps
       [not found] ` <0b90cfaa9ff10f594018fdcc686fe1b7a3924e4f.1250455879.git.victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  2009-08-16 21:14   ` [PATCH 11/18] Tighen up mdraid hostonly checking Victor Lowther
  2009-08-16 21:14   ` [PATCH 07/18] More quotation fixups in dracut-functions Victor Lowther
@ 2009-08-16 21:14   ` Victor Lowther
  2009-08-16 21:14   ` [PATCH 05/18] Some quotation cleanups in dracut-functions Victor Lowther
                     ` (13 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: Victor Lowther @ 2009-08-16 21:14 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

---
 dracut-functions |   33 ++++++++++++++-------------------
 1 files changed, 14 insertions(+), 19 deletions(-)

diff --git a/dracut-functions b/dracut-functions
index c82c7c7..ffc2724 100755
--- a/dracut-functions
+++ b/dracut-functions
@@ -203,32 +203,27 @@ inst_hook() {
 }
 
 dracut_install() {
-    local optional=
+    if [[ $1 = '-o' ]]; then 
+	local optional=yes
+	shift
+    fi
     while (($# > 0)); do
-        # Might be nice to optionally install a binary
-        if [[ $1 = '-o' ]]; then
-           optional=yes
-           shift
-           continue
-        fi
-	if inst "$1" ; then
-            shift 
-            continue
-        fi
-        if [ "$optional" == "yes" ]; then
-          dwarning "Skipping program $1 as it cannot be found and is flagged to be optional"
-          shift
-          continue
-        else
-          derror "Failed to install $1"; exit 1
-        fi
+	if ! inst "$1" ; then
+	    if [[ $optional = yes ]]; then
+		dwarning "Skipping program $1 as it cannot be found and is flagged to be optional"
+	    else
+		derror "Failed to install $1"
+		exit 1
+            fi
+	fi
+	shift
     done
 }
 
 check_module_deps() {
     local moddir dep ret
     # if we are already set to be loaded, we do not have to be checked again.
-    strstr "$mods_to_load" " $1 "
+    strstr "$mods_to_load" " $1 " && return
     # turn a module name into a directory, if we can.
     moddir=$(echo ${dsrc}/modules.d/??${1})
     [[ -d $moddir && -x $moddir/install ]] || return 1
-- 
1.6.0.4

--
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] 18+ messages in thread

* [PATCH 04/18] Get rid of redundant NONL stuff in dracut-gencmdline
       [not found] ` <0b90cfaa9ff10f594018fdcc686fe1b7a3924e4f.1250455879.git.victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
                     ` (8 preceding siblings ...)
  2009-08-16 21:14   ` [PATCH 13/18] The network check script must use /bin/bash Victor Lowther
@ 2009-08-16 21:14   ` Victor Lowther
  2009-08-16 21:14   ` [PATCH 03/18] Update dracut-catimages to make it much more robust Victor Lowther
                     ` (6 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: Victor Lowther @ 2009-08-16 21:14 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

bash's built-in echo already understands -n.

---
 dracut-gencmdline |   15 ++-------------
 1 files changed, 2 insertions(+), 13 deletions(-)

diff --git a/dracut-gencmdline b/dracut-gencmdline
index 733f199..2901199 100755
--- a/dracut-gencmdline
+++ b/dracut-gencmdline
@@ -21,22 +21,11 @@
 
 
 function error() {
-    local NONL=""
-    if [ "$1" == "-n" ]; then
-        NONL="-n"
-        shift
-    fi
-    echo $NONL "$@" >&2
+    echo "$@" >&2
 }
 
 function vecho() {
-    return
-    local NONL=""
-    if [ "$1" == "-n" ]; then
-        NONL="-n"
-        shift
-    fi
-    is_verbose && echo $NONL "$@"
+    is_verbose && echo "$@"
 }
 
 # module dep finding and installation functions
-- 
1.6.0.4

--
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] 18+ messages in thread

* [PATCH 08/18] Split kernel module loading into smaller chunks.
       [not found] ` <0b90cfaa9ff10f594018fdcc686fe1b7a3924e4f.1250455879.git.victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
                     ` (6 preceding siblings ...)
  2009-08-16 21:14   ` [PATCH 09/18] Tighten up hostonly checking in 90crypt Victor Lowther
@ 2009-08-16 21:14   ` Victor Lowther
  2009-08-16 21:14   ` [PATCH 13/18] The network check script must use /bin/bash Victor Lowther
                     ` (8 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: Victor Lowther @ 2009-08-16 21:14 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

This prepares to more tightly integrate dracut-gencmdline with the
rest of the dracut scripts, among other 
---
 dracut                                   |    2 +
 dracut-functions                         |   67 ++++++++++++++++++------------
 dracut-gencmdline                        |    7 ---
 modules.d/90kernel-modules/installkernel |    2 +-
 4 files changed, 43 insertions(+), 35 deletions(-)

diff --git a/dracut b/dracut
index 6d4fccb..7e5f2d4 100755
--- a/dracut
+++ b/dracut
@@ -113,6 +113,8 @@ PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH
 [[ $dracutbasedir ]] || dracutbasedir=/usr/share/dracut
 [[ $fw_dir ]] || fw_dir=/lib/firmware
 [[ $do_strip ]] || do_strip=yes
+# eliminate IFS hackery when messing with fw_dir
+fw_dir=${fw_dir//:/ }
 
 [[ $allowlocal && -f "$(dirname $0)/dracut-functions" ]] && dsrc="$(dirname $0)" || dsrc=$dracutbasedir
 
diff --git a/dracut-functions b/dracut-functions
index 79982ce..c57174c 100755
--- a/dracut-functions
+++ b/dracut-functions
@@ -31,7 +31,7 @@ if ! [[ $dracutlogfile ]]; then
        dracutlogfile=/tmp/dracut.log
     [[ -w $dracutlogfile ]] || dracutlogfile=/tmp/dracut.log
     >"$dracutlogfile"
-fi
+ fi
 
 dwarning() {
     echo "W: $@" >&2
@@ -275,7 +275,43 @@ check_modules() {
     done
 }
 
-# install kernel modules, and handle installing all their dependencies as well.
+# Install a single kernel module along with any firmware it may require.
+# $1 = full path to kernel module to install
+install_kmod_with_fw() {
+    local modname=${1##*/} fwdir found
+    modname=${modname%.ko}
+    inst_simple "$1" "/lib/modules/$kernel/${1##*/lib/modules/$kernel/}"
+    for fw in $(modinfo -k $kernel -F firmware $1 2>/dev/null); do
+	found=''
+	for fwdir in $fw_dir; do
+	    if [[ -d $fwdir && -f $fwdir/$fw ]]; then
+		inst_simple "$fwdir/$fw" "/lib/firmware/$fw"
+		found=yes
+	    fi
+	done
+	if [[ $found != yes ]]; then
+	    dwarning "Possible missing firmware ${fw} for module ${mod}.ko"
+	fi
+    done
+}
+
+# Do something with all the dependencies of a kernel module.
+# Note that kernel modules depend on themselves using the technique we use
+# $1 = function to call for each dependency we find 
+#      It will be passed the full path to the found kernel module 
+# $2 = module to get dependencies for
+# rest of args = arguments to modprobe
+for_each_kmod_dep() {
+    local func=$1 kmod=$2 cmd modpapth options
+    shift 2
+    modprobe "$@" --ignore-install --show-depends $kmod 2>/dev/null | \
+	while read cmd modpath options; do
+	    [[ $cmd = insmod ]] || continue
+	    $func $modpath
+    done
+}
+
+# install kernel modules along with all their dependencies.
 instmods() {
     [[ $no_kernel = yes ]] && return
     local mod mpargs modpath modname cmd
@@ -308,31 +344,8 @@ instmods() {
 		}
 		# ok, load the module, all its dependencies, and any firmware
 		# it may require
-                modprobe $mpargs --ignore-install --set-version $kernel -d ${srcmods%%/lib/modules/*}/ \
-		    --show-depends $mod 2>/dev/null | \
-		    while read cmd modpath options; do
-		    [[ $cmd = insmod ]] || continue
-		    modname=${modpath##*/}
-		    modname=${modname%.ko}
-		    if [[ ${mod/-/_} != ${modname/-/_} ]]; then
-			dinfo "Installing dependencies for $mod ($modpath)"
-			instmods $mpargs $modname
-		    fi
-		    inst_simple "$modpath" "/lib/modules/$kernel/${modpath##*/lib/modules/$kernel/}"
-		    for fw in $(modinfo -k $kernel -F firmware $modpath 2>/dev/null); do
-			unset found
-			IFS=: 
-			for fwdir in $fw_dir; do		    
-		            if [ -d "$fwdir" -a -f $fwdir/$fw ]; then
-				inst_simple "$fwdir/$fw" "/lib/firmware/$fw"
-				found=yes
-			    fi
-			done
-			if [[ $found != yes ]]; then
-			    dwarning "Possible missing firmware ${fw} for module ${mod}.ko"
-			fi
-		    done
-		done
+		for_each_kmod_dep install_kmod_with_fw $mod \
+		    --set-version $kernel -d ${srcmods%%/lib/modules/*}/
 		;;
 	esac      
 	shift
diff --git a/modules.d/90kernel-modules/installkernel b/modules.d/90kernel-modules/installkernel
index 94e3ba9..f9a1ab4 100755
--- a/modules.d/90kernel-modules/installkernel
+++ b/modules.d/90kernel-modules/installkernel
@@ -1,5 +1,5 @@
 #!/bin/bash
-if [ -z "$drivers" ]; then
+if [[ -z $drivers ]]; then
   drivers="sd_mod =fs"
   # Include block controller drivers
   blockfuncs='ata_scsi_ioctl|scsi_add_host|blk_init_queue|register_mtd_blktrans|scsi_esp_register|register_virtio_device'
-- 
1.6.0.4

--
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] 18+ messages in thread

* [PATCH 07/18] More quotation fixups in dracut-functions
       [not found] ` <0b90cfaa9ff10f594018fdcc686fe1b7a3924e4f.1250455879.git.victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  2009-08-16 21:14   ` [PATCH 11/18] Tighen up mdraid hostonly checking Victor Lowther
@ 2009-08-16 21:14   ` Victor Lowther
  2009-08-16 21:14   ` [PATCH 06/18] Simplify dracut_install a bit, an make a minor fixup to check_module_deps Victor Lowther
                     ` (14 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: Victor Lowther @ 2009-08-16 21:14 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

---
 dracut-functions |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/dracut-functions b/dracut-functions
index ffc2724..79982ce 100755
--- a/dracut-functions
+++ b/dracut-functions
@@ -245,7 +245,7 @@ check_module_deps() {
 should_source_module() {
     local dep
     [[ -x $1/install ]] || return 1
-    if [[ "$kernel_only" = "yes" ]]; then
+    if [[ $kernel_only = yes ]]; then
         [[ -x $1/installkernel ]] && return 0
         return 1
     fi
@@ -277,14 +277,14 @@ check_modules() {
 
 # install kernel modules, and handle installing all their dependencies as well.
 instmods() {
-    [[ "$no_kernel" = "yes" ]] && return
+    [[ $no_kernel = yes ]] && return
     local mod mpargs modpath modname cmd
     while (($# > 0)); do
 	mod=${1%.ko}
 	case $mod in
 	    =*) # This introduces 2 incompatible meanings for =* arguments
                 # to instmods.  We need to decide which one to keep.
-		if [ "$mod" = "=ata" -a -f $srcmods/modules.block ] ; then 
+		if [[ $mod = =ata && -f $srcmods/modules.block ]] ; then 
 		    instmods $mpargs $(egrep 'ata|ahci' "${srcmods}/modules.block")
 		elif [ -f $srcmods/modules.${mod#=} ]; then
 		    instmods $mpargs $(cat ${srcmods}/modules.${mod#=} )
@@ -306,6 +306,8 @@ instmods() {
 		[[ $hostonly ]] && ! grep -q "$mod" /proc/modules && { 
 		    shift; continue; 
 		}
+		# ok, load the module, all its dependencies, and any firmware
+		# it may require
                 modprobe $mpargs --ignore-install --set-version $kernel -d ${srcmods%%/lib/modules/*}/ \
 		    --show-depends $mod 2>/dev/null | \
 		    while read cmd modpath options; do
@@ -326,7 +328,7 @@ instmods() {
 				found=yes
 			    fi
 			done
-			if [ "$found" != "yes" ]; then
+			if [[ $found != yes ]]; then
 			    dwarning "Possible missing firmware ${fw} for module ${mod}.ko"
 			fi
 		    done
-- 
1.6.0.4

--
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] 18+ messages in thread

* [PATCH 01/18] Bashify drivers_dir check
@ 2009-08-16 21:14 Victor Lowther
       [not found] ` <0b90cfaa9ff10f594018fdcc686fe1b7a3924e4f.1250455879.git.victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 18+ messages in thread
From: Victor Lowther @ 2009-08-16 21:14 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

This patch series includes some code cleanups, makes --hostonly mode a bit more
finegrained w.r.t initramfs creation, and lays some groundwork for integrating 
dracut-gencmdline in with the rest of dracut.

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

diff --git a/dracut b/dracut
index 6e47077..78cd2ef 100755
--- a/dracut
+++ b/dracut
@@ -136,7 +136,7 @@ esac
 [[ $1 ]] && outfile=$(readlink -f $1) || outfile="/boot/initrd-$kernel.img"
 
 srcmods="/lib/modules/$kernel/"
-[ -n "$drivers_dir" ] && srcmods="$drivers_dir"
+[[ $drivers_dir ]] && srcmods="$drivers_dir"
 export srcmods
 
 if [[ -f $outfile && ! $force ]]; then
-- 
1.6.0.4

--
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] 18+ messages in thread

* [PATCH 03/18] Update dracut-catimages to make it much more robust.
       [not found] ` <0b90cfaa9ff10f594018fdcc686fe1b7a3924e4f.1250455879.git.victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
                     ` (9 preceding siblings ...)
  2009-08-16 21:14   ` [PATCH 04/18] Get rid of redundant NONL stuff in dracut-gencmdline Victor Lowther
@ 2009-08-16 21:14   ` Victor Lowther
  2009-08-16 21:14   ` [PATCH 02/18] No need to quote variable expansion in [[ ]] Victor Lowther
                     ` (5 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: Victor Lowther @ 2009-08-16 21:14 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

dracut-catimages will now handle image filenames with spaces, carriage returns,
and other such nasty characters in them.  Bash arrays are very useful for 
these sorts of things.

---
 dracut-catimages |   26 ++++++++++++++------------
 1 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/dracut-catimages b/dracut-catimages
index 66b03fe..b19f20a 100755
--- a/dracut-catimages
+++ b/dracut-catimages
@@ -70,7 +70,7 @@ done
 
 outfile=$1; shift
 
-if [ -z "$outfile" ]; then
+if [[ -z $outfile ]]; then
     derror "No output file specified."
     usage
     exit 1
@@ -78,45 +78,47 @@ fi
 
 baseimage=$1; shift
 
-if [ -z "$baseimage" ]; then
+if [[ -z $baseimage ]]; then
     derror "No base image specified."
     usage
     exit 1
 fi
 
-if [ -f $outfile -a -z "$force" ]; then
+if [[ -f $outfile && ! $force ]]; then
     derror "Will not override existing initramfs ($outfile) without --force"
     exit 1
 fi
 
-if [ -z "$no_imagedir" -a ! -d "$imagedir" ]; then
+if [[ ! $no_imagedir && ! -d $imagedir ]]; then
     derror "Image directory $overlay is not a directory"
     exit 1
 fi
 
-if [ -z "$no_overlay" -a ! -d "$overlay" ]; then
+if [[ ! $no_overlay && ! -d $overlay ]]; then
     derror "Overlay $overlay is not a directory"
     exit 1
 fi
 
-if [ -z "$no_overlay" ]; then
+if [[ ! $no_overlay ]]; then
     ofile="$imagedir/90-overlay.img"
     dinfo "Creating image $ofile from directory $overlay"
     ( cd "$overlay"; find . |cpio --quiet -H newc -o  |gzip -9 > "$ofile"; )
 fi
 
-if [ -z "$no_imagedir" ]; then
-    images=$(for i in $imagedir/*.img;do [ -f $i ] || continue; echo $i; done)
+if [[ ! $no_imagedir ]]; then
+    for i in "$imagedir/"*.img; do
+	[[ -f $i ]] && images+=("$i")
+    done
 fi
 
-images="$images $@"
+images+=($@)
 
 dinfo "Using base image $baseimage"
-cat $baseimage > $outfile
+cat "$baseimage" > "$outfile"
 
-for i in $images; do 
+for i in "${images[@]}"; do 
     dinfo "Appending $i"
-    cat $i >> $outfile
+    cat "$i" >> "$outfile"
 done
 
 dinfo "Created $outfile"
-- 
1.6.0.4

--
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] 18+ messages in thread

* [PATCH 05/18] Some quotation cleanups in dracut-functions.
       [not found] ` <0b90cfaa9ff10f594018fdcc686fe1b7a3924e4f.1250455879.git.victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
                     ` (2 preceding siblings ...)
  2009-08-16 21:14   ` [PATCH 06/18] Simplify dracut_install a bit, an make a minor fixup to check_module_deps Victor Lowther
@ 2009-08-16 21:14   ` Victor Lowther
  2009-08-16 21:14   ` [PATCH 16/18] Make dmraid checking use stuff " Victor Lowther
                     ` (12 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: Victor Lowther @ 2009-08-16 21:14 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

Quotes are generally not needed in when assigning one variable to another,
and are also not needed inside [[ ]] comaprisons, as word splitting and
pathname expansion are not performed in these cases.

---
 dracut-functions |   30 +++++++++++++++---------------
 1 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/dracut-functions b/dracut-functions
index 73bf1fe..c82c7c7 100755
--- a/dracut-functions
+++ b/dracut-functions
@@ -29,23 +29,23 @@ if ! [[ $dracutlogfile ]]; then
     [[ $dsrc = /usr/share/dracut ]] && \
        dracutlogfile=/var/log/dracut.log || \
        dracutlogfile=/tmp/dracut.log
-    [[ -w "$dracutlogfile" ]] || dracutlogfile=/tmp/dracut.log
+    [[ -w $dracutlogfile ]] || dracutlogfile=/tmp/dracut.log
     >"$dracutlogfile"
 fi
 
 dwarning() {
     echo "W: $@" >&2
-    [[ -w "$dracutlogfile" ]] && echo "W: $@" >>"$dracutlogfile"
+    [[ -w $dracutlogfile ]] && echo "W: $@" >>"$dracutlogfile"
 }
 
 dinfo() {
     [[ $beverbose ]] && echo "I: $@" >&2
-    [[ -w "$dracutlogfile" ]] && echo "I: $@" >>"$dracutlogfile"
+    [[ -w $dracutlogfile ]] && echo "I: $@" >>"$dracutlogfile"
 }
 
 derror() {
     echo "E: $@" >&2
-    [[ -w "$dracutlogfile" ]] && echo "E: $@" >>"$dracutlogfile"
+    [[ -w $dracutlogfile ]] && echo "E: $@" >>"$dracutlogfile"
 }
 
 # $1 = file to copy to ramdisk
@@ -55,7 +55,7 @@ derror() {
 inst_simple() {
     local src target
     [[ -f $1 ]] || return 1
-    src=$1 target="${initdir}${2:-$1}"
+    src=$1 target=${initdir}${2:-$1}
     [[ -f $target ]] && return 0
     mkdir -p "${target%/*}"
     dinfo "Installing $src" 
@@ -69,10 +69,10 @@ inst_library() {
     local src=$1 dest=${2:-$1}
     [[ -f $initdir$dest ]] && return 0
     if [[ -L $src ]]; then
-	reallib="$(readlink -f "$src")"
+	reallib=$(readlink -f "$src")
 	lib=${src##*/}
 	inst_simple "$reallib" "$reallib"
-	mkdir -p ${initdir}${dest%/*}
+	mkdir -p "${initdir}${dest%/*}"
 	(cd "${initdir}${dest%/*}" && ln -s "$reallib" "$lib")
     else
 	inst_simple "$src" "$dest"
@@ -115,15 +115,15 @@ inst_binary() {
 	lib_regex='^(/lib[^/]*).*'
 	if [[ $FILE =~ $lib_regex ]]; then
             TLIBDIR=${BASH_REMATCH[1]}
-            BASE="${FILE##*/}"
+            BASE=${FILE##*/}
 	    # prefer nosegneg libs, then unoptimized ones.
 	    for f in "$TLIBDIR/i686/nosegneg" "$TLIBDIR"; do
 		[[ -f $f/$BASE ]] || continue
-		FILE="$f/$BASE"
+		FILE=$f/$BASE
 		break
 	    done
 	    inst_library "$FILE" "$TLIBDIR/$BASE"
-            IF_dynamic="yes"
+            IF_dynamic=yes
 	    continue
 	fi
         inst_library "$FILE" 
@@ -150,7 +150,7 @@ inst_symlink() {
     [[ -L $1 ]] || return 1
     [[ -L $target ]] && return 0
     realsrc=$(readlink -f "$src")
-    [[ $realsrc = ${realsrc##*/} ]] && realsrc="${src%/*}/$realsrc"
+    [[ $realsrc = ${realsrc##*/} ]] && realsrc=${src%/*}/$realsrc
     inst "$realsrc" && ln -s "$realsrc" "$target"
 }
 
@@ -166,10 +166,10 @@ find_rule() {
 # udev rules always get installed in the same place, so
 # create a function to install them to make life simpler.
 inst_rules() { 
-    local target="/etc/udev/rules.d"
+    local target=/etc/udev/rules.d
     mkdir -p "$initdir/lib/udev/rules.d" "$initdir$target"
     for rule in "$@"; do 
-	rule=$(find_rule $rule) && \
+	rule=$(find_rule "$rule") && \
 	    inst_simple "$rule" "$target/${rule##*/}"
     done
 }
@@ -206,8 +206,8 @@ dracut_install() {
     local optional=
     while (($# > 0)); do
         # Might be nice to optionally install a binary
-        if [ "$1" == "-o" ]; then
-           optional="yes"
+        if [[ $1 = '-o' ]]; then
+           optional=yes
            shift
            continue
         fi
-- 
1.6.0.4

--
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] 18+ messages in thread

* [PATCH 16/18] Make dmraid checking use stuff in dracut-functions
       [not found] ` <0b90cfaa9ff10f594018fdcc686fe1b7a3924e4f.1250455879.git.victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
                     ` (3 preceding siblings ...)
  2009-08-16 21:14   ` [PATCH 05/18] Some quotation cleanups in dracut-functions Victor Lowther
@ 2009-08-16 21:14   ` Victor Lowther
  2009-08-16 21:14   ` [PATCH 10/18] Tighten hostonly check for dmraid Victor Lowther
                     ` (11 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: Victor Lowther @ 2009-08-16 21:14 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

---
 modules.d/90dmraid/check |   66 ++++++++++++++++-----------------------------
 1 files changed, 24 insertions(+), 42 deletions(-)

diff --git a/modules.d/90dmraid/check b/modules.d/90dmraid/check
dissimilarity index 79%
index 1757dfd..7008f81 100755
--- a/modules.d/90dmraid/check
+++ b/modules.d/90dmraid/check
@@ -1,42 +1,24 @@
-#!/bin/bash
-
-# if we don't have dmraid installed on the host system, no point
-# in trying to support it in the initramfs.
-which dmraid >/dev/null 2>&1 || exit 1
-
-is_dmraid() { /lib/udev/vol_id /dev/block/$1 |grep -v linux_raid_member | \
-    grep -q _raid_member; }
-
-check_block_and_slaves() (
-    # $1 = block device in major:minor format
-    local x
-    cd /sys/dev/block/$1
-    [[ -b /dev/block/$1 ]] || return 1 # Not a block device? So sorry.
-    is_dmraid $1 && return
-    [[ -d slaves ]] || return 1 # there are no underlying devices, done.
-    # we want to search the tree breadthwise, so...
-    for x in slaves/*/dev; do
-	is_dmraid $(cat "$x") && return 0
-    done
-    for x in slaves/*/dev; do
-	check_block_and_slaves $(cat "$x") &&  return 0
-    done
-    return 1
-)
-
-if [[ $1 = '-h' ]] ; then
-    rootdev=''
-    while read blkdev fs type opts misc; do
-	[[ $blkdev = rootfs ]] && continue # skip rootfs entry
-	[[ $fs = / ]] && { rootdev=$blkdev; break; }
-    done < /proc/mounts
-    [[ -b $rootdev ]] || exit 1 # Not on a block device?  Definitly not dmraid
-    # get major/minor for the device
-    majmin=$(ls -nLl "$rootdev" | \
-	(read x x x x maj min x; maj=${maj//,/}; echo $maj:$min))
-    # now, walk backwards though our master/slave relationships looking
-    # for a dmraid device
-    check_block_and_slaves $majmin || exit 1
-fi
-
-exit 0
+#!/bin/bash
+
+# if we don't have dmraid installed on the host system, no point
+# in trying to support it in the initramfs.
+which dmraid >/dev/null 2>&1 || exit 1
+
+. $dracutfunctions
+
+is_dmraid() { /lib/udev/vol_id /dev/block/$1 |grep -v linux_raid_member | \
+    grep -q _raid_member; }
+
+[[ $1 = '-h' ]] && {
+    rootdev=$(find_root_block_device)
+    if [[ $rootdev ]]; then
+	# root lives on a block device, so we can be more precise about 
+	# hostonly checking
+	check_block_and_slaves is_dmraid "$rootdev" || exit 1
+    else
+	# root is not on a block device, use the shotgun approach
+	dmraid -r | grep -q ok || exit 1
+    fi
+}
+
+exit 0
-- 
1.6.0.4

--
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] 18+ messages in thread

* [PATCH 12/18] Tighten up lvm hostonly checking.
       [not found] ` <0b90cfaa9ff10f594018fdcc686fe1b7a3924e4f.1250455879.git.victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
                     ` (11 preceding siblings ...)
  2009-08-16 21:14   ` [PATCH 02/18] No need to quote variable expansion in [[ ]] Victor Lowther
@ 2009-08-16 21:14   ` Victor Lowther
  2009-08-16 21:14   ` [PATCH 15/18] Move common rootfs finding and backing store functions Victor Lowther
                     ` (3 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: Victor Lowther @ 2009-08-16 21:14 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

Make the script really check to see if root is on an lvm device somehow 
when run in hostonly mode.

---
 modules.d/90lvm/check |   36 +++++++++++++++++++++++++++++++++++-
 1 files changed, 35 insertions(+), 1 deletions(-)

diff --git a/modules.d/90lvm/check b/modules.d/90lvm/check
index 35f9344..03281a9 100755
--- a/modules.d/90lvm/check
+++ b/modules.d/90lvm/check
@@ -1,8 +1,42 @@
-#!/bin/sh
+#!/bin/bash
 
 # No point trying to support lvm if the binaries are missing
 which lvm >/dev/null 2>&1 || exit 1
 
+is_lvm() { /lib/udev/vol_id /dev/block/$1 |grep -q LVM2_member; }
+
+check_block_and_slaves() (
+    # $1 = block device in major:minor format
+    local x
+    cd /sys/dev/block/$1
+    [[ -b /dev/block/$1 ]] || return 1 # Not a block device? So sorry.
+    is_lvm $1 && return
+    [[ -d slaves ]] || return 1 # there are no underlying devices, done.
+    # we want to search the tree breadthwise, so...
+    for x in slaves/*/dev; do
+	is_lvm $(cat "$x") && return 0
+    done
+    for x in slaves/*/dev; do
+	check_block_and_slaves $(cat "$x") &&  return 0
+    done
+    return 1
+)
+
+if [[ $1 = '-h' ]] ; then
+    rootdev=''
+    while read blkdev fs type opts misc; do
+	[[ $blkdev = rootfs ]] && continue # skip rootfs entry
+	[[ $fs = / ]] && { rootdev=$blkdev; break; }
+    done < /proc/mounts
+    [[ -b $rootdev ]] || exit 1 # Not on a block device?  Definitly not crypted.
+    # get major/minor for the device
+    majmin=$(ls -nLl "$rootdev" | \
+	(read x x x x maj min x; maj=${maj//,/}; echo $maj:$min))
+    # now, walk backwards though our master/slave relationships looking
+    # for a LVM2_member device
+    check_block_and_slaves $majmin || exit 1
+fi
+
 # We should really just check to see if root is on a logical volume
 # when running in hostonly mode. I am lazy. Therefore, fail the hostonly
 # check unless there is a logical volume in use somewhere.
-- 
1.6.0.4

--
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] 18+ messages in thread

* [PATCH 14/18] Minor spacing fixups in dracut-finctions
       [not found] ` <0b90cfaa9ff10f594018fdcc686fe1b7a3924e4f.1250455879.git.victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
                     ` (13 preceding siblings ...)
  2009-08-16 21:14   ` [PATCH 15/18] Move common rootfs finding and backing store functions Victor Lowther
@ 2009-08-16 21:14   ` Victor Lowther
  2009-08-16 21:14   ` [PATCH 17/18] Make mdraid checking use stuff in dracut-functions Victor Lowther
  2009-08-16 21:14   ` [PATCH 18/18] Modified lvm hostonly checking to use dracut-functions Victor Lowther
  16 siblings, 0 replies; 18+ messages in thread
From: Victor Lowther @ 2009-08-16 21:14 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

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

diff --git a/dracut-functions b/dracut-functions
index c57174c..66e0e20 100755
--- a/dracut-functions
+++ b/dracut-functions
@@ -27,11 +27,11 @@ strstr() { [[ ! ${1#*$2*} = $1 ]]; }
 # Log initrd creation.
 if ! [[ $dracutlogfile ]]; then
     [[ $dsrc = /usr/share/dracut ]] && \
-       dracutlogfile=/var/log/dracut.log || \
-       dracutlogfile=/tmp/dracut.log
+	dracutlogfile=/var/log/dracut.log || \
+	dracutlogfile=/tmp/dracut.log
     [[ -w $dracutlogfile ]] || dracutlogfile=/tmp/dracut.log
     >"$dracutlogfile"
- fi
+fi
 
 dwarning() {
     echo "W: $@" >&2
-- 
1.6.0.4

--
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] 18+ messages in thread

* [PATCH 11/18] Tighen up mdraid hostonly checking.
       [not found] ` <0b90cfaa9ff10f594018fdcc686fe1b7a3924e4f.1250455879.git.victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2009-08-16 21:14   ` Victor Lowther
  2009-08-16 21:14   ` [PATCH 07/18] More quotation fixups in dracut-functions Victor Lowther
                     ` (15 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: Victor Lowther @ 2009-08-16 21:14 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

Have the script really check to see of the rootfs is on an mdraid block 
device when run in hostonly mode.

---
 modules.d/{90dmraid => 90mdraid}/check |   16 +++++++---------
 1 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/modules.d/90dmraid/check b/modules.d/90mdraid/check
similarity index 73%
copy from modules.d/90dmraid/check
copy to modules.d/90mdraid/check
index 1757dfd..a13d671 100755
--- a/modules.d/90dmraid/check
+++ b/modules.d/90mdraid/check
@@ -1,22 +1,20 @@
 #!/bin/bash
 
-# if we don't have dmraid installed on the host system, no point
-# in trying to support it in the initramfs.
-which dmraid >/dev/null 2>&1 || exit 1
+# No mdadm?  No mdraid support.
+which mdadm >/dev/null 2>&1 || exit 1
 
-is_dmraid() { /lib/udev/vol_id /dev/block/$1 |grep -v linux_raid_member | \
-    grep -q _raid_member; }
+is_mdraid() { /lib/udev/vol_id /dev/block/$1 |egrep -q '(linux|isw)_raid'; }
 
 check_block_and_slaves() (
     # $1 = block device in major:minor format
     local x
     cd /sys/dev/block/$1
     [[ -b /dev/block/$1 ]] || return 1 # Not a block device? So sorry.
-    is_dmraid $1 && return
+    is_mdraid $1 && return
     [[ -d slaves ]] || return 1 # there are no underlying devices, done.
     # we want to search the tree breadthwise, so...
     for x in slaves/*/dev; do
-	is_dmraid $(cat "$x") && return 0
+	is_mdraid $(cat "$x") && return 0
     done
     for x in slaves/*/dev; do
 	check_block_and_slaves $(cat "$x") &&  return 0
@@ -30,12 +28,12 @@ if [[ $1 = '-h' ]] ; then
 	[[ $blkdev = rootfs ]] && continue # skip rootfs entry
 	[[ $fs = / ]] && { rootdev=$blkdev; break; }
     done < /proc/mounts
-    [[ -b $rootdev ]] || exit 1 # Not on a block device?  Definitly not dmraid
+    [[ -b $rootdev ]] || exit 1 # Not on a block device?  Definitly not mdraid.
     # get major/minor for the device
     majmin=$(ls -nLl "$rootdev" | \
 	(read x x x x maj min x; maj=${maj//,/}; echo $maj:$min))
     # now, walk backwards though our master/slave relationships looking
-    # for a dmraid device
+    # for a mdraid device
     check_block_and_slaves $majmin || exit 1
 fi
 
-- 
1.6.0.4

--
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] 18+ messages in thread

* [PATCH 09/18] Tighten up hostonly checking in 90crypt
       [not found] ` <0b90cfaa9ff10f594018fdcc686fe1b7a3924e4f.1250455879.git.victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
                     ` (5 preceding siblings ...)
  2009-08-16 21:14   ` [PATCH 10/18] Tighten hostonly check for dmraid Victor Lowther
@ 2009-08-16 21:14   ` Victor Lowther
  2009-08-16 21:14   ` [PATCH 08/18] Split kernel module loading into smaller chunks Victor Lowther
                     ` (9 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: Victor Lowther @ 2009-08-16 21:14 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

Only pass if root is really on an encrypted block device somewhere along the
chain of block devices.

---
 modules.d/90crypt/check |   37 ++++++++++++++++++++++++++++++++++---
 1 files changed, 34 insertions(+), 3 deletions(-)

diff --git a/modules.d/90crypt/check b/modules.d/90crypt/check
index 2297e0f..7d78c4b 100755
--- a/modules.d/90crypt/check
+++ b/modules.d/90crypt/check
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 
 # if cryptsetup is not installed, then we cannot support encrypted devices.
 which cryptsetup >/dev/null 2>&1 || exit 1
@@ -6,8 +6,39 @@ which cryptsetup >/dev/null 2>&1 || exit 1
 # hostonly checking should only return true if root is on a LUKS device
 # in some way, but I am too lazy to figure out how to do that.
 # Instead, fail if we do not have a LUKS device in use somewhere.
-if [ "$1" = "-h" ] ; then
-    blkid | grep -q crypt_LUKS || exit 1
+
+is_crypt() { /lib/udev/vol_id /dev/block/$1 |grep -q crypto_LUKS; }
+
+check_block_and_slaves() (
+    # $1 = block device in major:minor format
+    local x
+    cd /sys/dev/block/$1
+    [[ -b /dev/block/$1 ]] || return 1 # Not a block device? So sorry.
+    is_crypt $1 && return
+    [[ -d slaves ]] || return 1 # there are no underlying devices, done.
+    # we want to search the tree breadthwise, so...
+    for x in slaves/*/dev; do
+	is_crypt $(cat "$x") && return 0
+    done
+    for x in slaves/*/dev; do
+	check_block_and_slaves $(cat "$x") &&  return 0
+    done
+    return 1
+)
+
+if [[ $1 = '-h' ]] ; then
+    rootdev=''
+    while read blkdev fs type opts misc; do
+	[[ $blkdev = rootfs ]] && continue # skip rootfs entry
+	[[ $fs = / ]] && { rootdev=$blkdev; break; }
+    done < /proc/mounts
+    [[ -b $rootdev ]] || exit 1 # Not on a block device?  Definitly not crypted.
+    # get major/minor for the device
+    majmin=$(ls -nLl "$rootdev" | \
+	(read x x x x maj min x; maj=${maj//,/}; echo $maj:$min))
+    # now, walk backwards though our master/slave relationships looking
+    # for a crypt_LUKS device
+    check_block_and_slaves $majmin || exit 1
 fi
 
 exit 0
-- 
1.6.0.4

--
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] 18+ messages in thread

* [PATCH 10/18] Tighten hostonly check for dmraid.
       [not found] ` <0b90cfaa9ff10f594018fdcc686fe1b7a3924e4f.1250455879.git.victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
                     ` (4 preceding siblings ...)
  2009-08-16 21:14   ` [PATCH 16/18] Make dmraid checking use stuff " Victor Lowther
@ 2009-08-16 21:14   ` Victor Lowther
  2009-08-16 21:14   ` [PATCH 09/18] Tighten up hostonly checking in 90crypt Victor Lowther
                     ` (10 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: Victor Lowther @ 2009-08-16 21:14 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

Only pass if root is really on a dmraid volume somehow.

---
 modules.d/{90crypt => 90dmraid}/check |   20 +++++++++-----------
 1 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/modules.d/90crypt/check b/modules.d/90dmraid/check
similarity index 66%
copy from modules.d/90crypt/check
copy to modules.d/90dmraid/check
index 7d78c4b..1757dfd 100755
--- a/modules.d/90crypt/check
+++ b/modules.d/90dmraid/check
@@ -1,24 +1,22 @@
 #!/bin/bash
 
-# if cryptsetup is not installed, then we cannot support encrypted devices.
-which cryptsetup >/dev/null 2>&1 || exit 1
+# if we don't have dmraid installed on the host system, no point
+# in trying to support it in the initramfs.
+which dmraid >/dev/null 2>&1 || exit 1
 
-# hostonly checking should only return true if root is on a LUKS device
-# in some way, but I am too lazy to figure out how to do that.
-# Instead, fail if we do not have a LUKS device in use somewhere.
-
-is_crypt() { /lib/udev/vol_id /dev/block/$1 |grep -q crypto_LUKS; }
+is_dmraid() { /lib/udev/vol_id /dev/block/$1 |grep -v linux_raid_member | \
+    grep -q _raid_member; }
 
 check_block_and_slaves() (
     # $1 = block device in major:minor format
     local x
     cd /sys/dev/block/$1
     [[ -b /dev/block/$1 ]] || return 1 # Not a block device? So sorry.
-    is_crypt $1 && return
+    is_dmraid $1 && return
     [[ -d slaves ]] || return 1 # there are no underlying devices, done.
     # we want to search the tree breadthwise, so...
     for x in slaves/*/dev; do
-	is_crypt $(cat "$x") && return 0
+	is_dmraid $(cat "$x") && return 0
     done
     for x in slaves/*/dev; do
 	check_block_and_slaves $(cat "$x") &&  return 0
@@ -32,12 +30,12 @@ if [[ $1 = '-h' ]] ; then
 	[[ $blkdev = rootfs ]] && continue # skip rootfs entry
 	[[ $fs = / ]] && { rootdev=$blkdev; break; }
     done < /proc/mounts
-    [[ -b $rootdev ]] || exit 1 # Not on a block device?  Definitly not crypted.
+    [[ -b $rootdev ]] || exit 1 # Not on a block device?  Definitly not dmraid
     # get major/minor for the device
     majmin=$(ls -nLl "$rootdev" | \
 	(read x x x x maj min x; maj=${maj//,/}; echo $maj:$min))
     # now, walk backwards though our master/slave relationships looking
-    # for a crypt_LUKS device
+    # for a dmraid device
     check_block_and_slaves $majmin || exit 1
 fi
 
-- 
1.6.0.4

--
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] 18+ messages in thread

* [PATCH 13/18] The network check script must use /bin/bash
       [not found] ` <0b90cfaa9ff10f594018fdcc686fe1b7a3924e4f.1250455879.git.victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
                     ` (7 preceding siblings ...)
  2009-08-16 21:14   ` [PATCH 08/18] Split kernel module loading into smaller chunks Victor Lowther
@ 2009-08-16 21:14   ` Victor Lowther
  2009-08-16 21:14   ` [PATCH 04/18] Get rid of redundant NONL stuff in dracut-gencmdline Victor Lowther
                     ` (7 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: Victor Lowther @ 2009-08-16 21:14 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

It sources dracut-functions.

---
 modules.d/40network/check |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/modules.d/40network/check b/modules.d/40network/check
index 95662f3..f2b137c 100755
--- a/modules.d/40network/check
+++ b/modules.d/40network/check
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 
 . $dracutfunctions
 
-- 
1.6.0.4

--
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] 18+ messages in thread

* [PATCH 15/18] Move common rootfs finding and backing store functions.
       [not found] ` <0b90cfaa9ff10f594018fdcc686fe1b7a3924e4f.1250455879.git.victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
                     ` (12 preceding siblings ...)
  2009-08-16 21:14   ` [PATCH 12/18] Tighten up lvm hostonly checking Victor Lowther
@ 2009-08-16 21:14   ` Victor Lowther
  2009-08-16 21:14   ` [PATCH 14/18] Minor spacing fixups in dracut-finctions Victor Lowther
                     ` (2 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: Victor Lowther @ 2009-08-16 21:14 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

The code for crupt, mdraid, dmraid, and lvm is nearly identical, so factor
the common stuff into dracut-functions.

---
 dracut-functions        |   32 +++++++++++++++++++++
 modules.d/90crypt/check |   70 +++++++++++++++++-----------------------------
 2 files changed, 58 insertions(+), 44 deletions(-)

diff --git a/dracut-functions b/dracut-functions
index 66e0e20..1df2045 100755
--- a/dracut-functions
+++ b/dracut-functions
@@ -48,6 +48,38 @@ derror() {
     [[ -w $dracutlogfile ]] && echo "E: $@" >>"$dracutlogfile"
 }
 
+# finds the major:minor of the block device backing the root filesystem.
+find_root_block_device() {
+    local rootdev blkdev fs type opts misc
+    while read blkdev fs type opts misc; do
+	[[ $blkdev = rootfs ]] && continue # skip rootfs entry
+	[[ $fs = / ]] && { rootdev=$blkdev; break; } # we have a winner!
+    done < /proc/mounts
+    [[ -b $rootdev ]] || return 1 # oops, not a block device.
+    # get major/minor for the device
+    ls -nLl "$rootdev" | \
+	(read x x x x maj min x; maj=${maj//,/}; echo $maj:$min)
+}
+
+# Walk all the slave relationships for a given block device.
+# Stop when our helper function returns success
+# $1 = function to call on every found block device
+# $2 = block device in major:minor format
+check_block_and_slaves() {    
+    local x 
+    [[ -b /dev/block/$2 ]] || return 1 # Not a block device? So sorry.
+    "$1" $2 && return
+    [[ -d /sys/dev/block/$2/slaves ]] || return 1
+    # we want to search the tree breadthwise, so...
+    for x in /sys/dev/block/$2/slaves/*/dev; do
+	$1 $(cat "$x") && return 0
+    done
+    for x in /sys/dev/block/$2/slaves/*/dev; do
+	check_block_and_slaves $1 $(cat "$x") &&  return 0
+    done
+    return 1
+}
+
 # $1 = file to copy to ramdisk
 # $2 (optional) Name for the file on the ramdisk
 # Location of the image dir is assumed to be $initdir
diff --git a/modules.d/90crypt/check b/modules.d/90crypt/check
dissimilarity index 72%
index 7d78c4b..edd450d 100755
--- a/modules.d/90crypt/check
+++ b/modules.d/90crypt/check
@@ -1,44 +1,26 @@
-#!/bin/bash
-
-# if cryptsetup is not installed, then we cannot support encrypted devices.
-which cryptsetup >/dev/null 2>&1 || exit 1
-
-# hostonly checking should only return true if root is on a LUKS device
-# in some way, but I am too lazy to figure out how to do that.
-# Instead, fail if we do not have a LUKS device in use somewhere.
-
-is_crypt() { /lib/udev/vol_id /dev/block/$1 |grep -q crypto_LUKS; }
-
-check_block_and_slaves() (
-    # $1 = block device in major:minor format
-    local x
-    cd /sys/dev/block/$1
-    [[ -b /dev/block/$1 ]] || return 1 # Not a block device? So sorry.
-    is_crypt $1 && return
-    [[ -d slaves ]] || return 1 # there are no underlying devices, done.
-    # we want to search the tree breadthwise, so...
-    for x in slaves/*/dev; do
-	is_crypt $(cat "$x") && return 0
-    done
-    for x in slaves/*/dev; do
-	check_block_and_slaves $(cat "$x") &&  return 0
-    done
-    return 1
-)
-
-if [[ $1 = '-h' ]] ; then
-    rootdev=''
-    while read blkdev fs type opts misc; do
-	[[ $blkdev = rootfs ]] && continue # skip rootfs entry
-	[[ $fs = / ]] && { rootdev=$blkdev; break; }
-    done < /proc/mounts
-    [[ -b $rootdev ]] || exit 1 # Not on a block device?  Definitly not crypted.
-    # get major/minor for the device
-    majmin=$(ls -nLl "$rootdev" | \
-	(read x x x x maj min x; maj=${maj//,/}; echo $maj:$min))
-    # now, walk backwards though our master/slave relationships looking
-    # for a crypt_LUKS device
-    check_block_and_slaves $majmin || exit 1
-fi
-
-exit 0
+#!/bin/bash
+
+# if cryptsetup is not installed, then we cannot support encrypted devices.
+which cryptsetup >/dev/null 2>&1 || exit 1
+
+# hostonly checking should only return true if root is on a LUKS device
+# in some way, but I am too lazy to figure out how to do that.
+# Instead, fail if we do not have a LUKS device in use somewhere.
+
+. $dracutfunctions
+
+is_crypt() { /lib/udev/vol_id /dev/block/$1 |grep -q crypto_LUKS; }
+
+[[ $1 = '-h' ]] && {
+    rootdev=$(find_root_block_device)
+    if [[ $rootdev ]]; then
+	# root lives on a block device, so we can be more precise about 
+	# hostonly checking
+	check_block_and_slaves is_crypt "$rootdev" || exit 1
+    else
+	# root is not on a block device, use the shotgun approach
+	blkid | grep -q crypt_LUKS || exit 1
+    fi
+}
+
+exit 0
-- 
1.6.0.4

--
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] 18+ messages in thread

* [PATCH 17/18] Make mdraid checking use stuff in dracut-functions
       [not found] ` <0b90cfaa9ff10f594018fdcc686fe1b7a3924e4f.1250455879.git.victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
                     ` (14 preceding siblings ...)
  2009-08-16 21:14   ` [PATCH 14/18] Minor spacing fixups in dracut-finctions Victor Lowther
@ 2009-08-16 21:14   ` Victor Lowther
  2009-08-16 21:14   ` [PATCH 18/18] Modified lvm hostonly checking to use dracut-functions Victor Lowther
  16 siblings, 0 replies; 18+ messages in thread
From: Victor Lowther @ 2009-08-16 21:14 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

---
 modules.d/90mdraid/check |   62 ++++++++++++++++-----------------------------
 1 files changed, 22 insertions(+), 40 deletions(-)

diff --git a/modules.d/90mdraid/check b/modules.d/90mdraid/check
dissimilarity index 86%
index a13d671..d002bdc 100755
--- a/modules.d/90mdraid/check
+++ b/modules.d/90mdraid/check
@@ -1,40 +1,22 @@
-#!/bin/bash
-
-# No mdadm?  No mdraid support.
-which mdadm >/dev/null 2>&1 || exit 1
-
-is_mdraid() { /lib/udev/vol_id /dev/block/$1 |egrep -q '(linux|isw)_raid'; }
-
-check_block_and_slaves() (
-    # $1 = block device in major:minor format
-    local x
-    cd /sys/dev/block/$1
-    [[ -b /dev/block/$1 ]] || return 1 # Not a block device? So sorry.
-    is_mdraid $1 && return
-    [[ -d slaves ]] || return 1 # there are no underlying devices, done.
-    # we want to search the tree breadthwise, so...
-    for x in slaves/*/dev; do
-	is_mdraid $(cat "$x") && return 0
-    done
-    for x in slaves/*/dev; do
-	check_block_and_slaves $(cat "$x") &&  return 0
-    done
-    return 1
-)
-
-if [[ $1 = '-h' ]] ; then
-    rootdev=''
-    while read blkdev fs type opts misc; do
-	[[ $blkdev = rootfs ]] && continue # skip rootfs entry
-	[[ $fs = / ]] && { rootdev=$blkdev; break; }
-    done < /proc/mounts
-    [[ -b $rootdev ]] || exit 1 # Not on a block device?  Definitly not mdraid.
-    # get major/minor for the device
-    majmin=$(ls -nLl "$rootdev" | \
-	(read x x x x maj min x; maj=${maj//,/}; echo $maj:$min))
-    # now, walk backwards though our master/slave relationships looking
-    # for a mdraid device
-    check_block_and_slaves $majmin || exit 1
-fi
-
-exit 0
+#!/bin/bash
+
+# No mdadm?  No mdraid support.
+which mdadm >/dev/null 2>&1 || exit 1
+
+. $dracutfunctions
+
+is_mdraid() { /lib/udev/vol_id /dev/block/$1 |egrep -q '(linux|isw)_raid'; }
+
+[[ $1 = '-h' ]] && {
+    rootdev=$(find_root_block_device)
+    if [[ $rootdev ]]; then
+	# root lives on a block device, so we can be more precise about 
+	# hostonly checking
+	check_block_and_slaves is_mdraid "$rootdev" || exit 1
+    else
+	# root is not on a block device, use the shotgun approach
+	blkid | grep -q linux_raid || exit 1
+    fi
+}
+
+exit 0
-- 
1.6.0.4

--
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] 18+ messages in thread

* [PATCH 18/18] Modified lvm hostonly checking to use dracut-functions
       [not found] ` <0b90cfaa9ff10f594018fdcc686fe1b7a3924e4f.1250455879.git.victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
                     ` (15 preceding siblings ...)
  2009-08-16 21:14   ` [PATCH 17/18] Make mdraid checking use stuff in dracut-functions Victor Lowther
@ 2009-08-16 21:14   ` Victor Lowther
  16 siblings, 0 replies; 18+ messages in thread
From: Victor Lowther @ 2009-08-16 21:14 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

---
 modules.d/{90mdraid => 90lvm}/check |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/modules.d/90mdraid/check b/modules.d/90lvm/check
similarity index 54%
copy from modules.d/90mdraid/check
copy to modules.d/90lvm/check
index d002bdc..3e6a990 100755
--- a/modules.d/90mdraid/check
+++ b/modules.d/90lvm/check
@@ -1,21 +1,21 @@
 #!/bin/bash
 
-# No mdadm?  No mdraid support.
-which mdadm >/dev/null 2>&1 || exit 1
+# No point trying to support lvm if the binaries are missing
+which lvm >/dev/null 2>&1 || exit 1
 
 . $dracutfunctions
 
-is_mdraid() { /lib/udev/vol_id /dev/block/$1 |egrep -q '(linux|isw)_raid'; }
+is_lvm() { /lib/udev/vol_id /dev/block/$1 |grep -q LVM2_member; }
 
 [[ $1 = '-h' ]] && {
     rootdev=$(find_root_block_device)
     if [[ $rootdev ]]; then
 	# root lives on a block device, so we can be more precise about 
 	# hostonly checking
-	check_block_and_slaves is_mdraid "$rootdev" || exit 1
+	check_block_and_slaves is_lvm "$rootdev" || exit 1
     else
 	# root is not on a block device, use the shotgun approach
-	blkid | grep -q linux_raid || exit 1
+	blkid | grep -q lvm2pv || exit 1
     fi
 }
 
-- 
1.6.0.4

--
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] 18+ messages in thread

end of thread, other threads:[~2009-08-16 21:14 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-16 21:14 [PATCH 01/18] Bashify drivers_dir check Victor Lowther
     [not found] ` <0b90cfaa9ff10f594018fdcc686fe1b7a3924e4f.1250455879.git.victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2009-08-16 21:14   ` [PATCH 11/18] Tighen up mdraid hostonly checking Victor Lowther
2009-08-16 21:14   ` [PATCH 07/18] More quotation fixups in dracut-functions Victor Lowther
2009-08-16 21:14   ` [PATCH 06/18] Simplify dracut_install a bit, an make a minor fixup to check_module_deps Victor Lowther
2009-08-16 21:14   ` [PATCH 05/18] Some quotation cleanups in dracut-functions Victor Lowther
2009-08-16 21:14   ` [PATCH 16/18] Make dmraid checking use stuff " Victor Lowther
2009-08-16 21:14   ` [PATCH 10/18] Tighten hostonly check for dmraid Victor Lowther
2009-08-16 21:14   ` [PATCH 09/18] Tighten up hostonly checking in 90crypt Victor Lowther
2009-08-16 21:14   ` [PATCH 08/18] Split kernel module loading into smaller chunks Victor Lowther
2009-08-16 21:14   ` [PATCH 13/18] The network check script must use /bin/bash Victor Lowther
2009-08-16 21:14   ` [PATCH 04/18] Get rid of redundant NONL stuff in dracut-gencmdline Victor Lowther
2009-08-16 21:14   ` [PATCH 03/18] Update dracut-catimages to make it much more robust Victor Lowther
2009-08-16 21:14   ` [PATCH 02/18] No need to quote variable expansion in [[ ]] Victor Lowther
2009-08-16 21:14   ` [PATCH 12/18] Tighten up lvm hostonly checking Victor Lowther
2009-08-16 21:14   ` [PATCH 15/18] Move common rootfs finding and backing store functions Victor Lowther
2009-08-16 21:14   ` [PATCH 14/18] Minor spacing fixups in dracut-finctions Victor Lowther
2009-08-16 21:14   ` [PATCH 17/18] Make mdraid checking use stuff in dracut-functions Victor Lowther
2009-08-16 21:14   ` [PATCH 18/18] Modified lvm hostonly checking to use dracut-functions Victor Lowther

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.