Author: glen
Date: Tue Oct 30 16:07:28 2007
New Revision: 8898

Modified:
   geninitrd/trunk/functions
Log:
- more detailed error messages when processing fstab and lvm

Modified: geninitrd/trunk/functions
==============================================================================
--- geninitrd/trunk/functions   (original)
+++ geninitrd/trunk/functions   Tue Oct 30 16:07:28 2007
@@ -17,9 +17,9 @@
        local function="${PROGRAM:+$PROGRAM: }find_root"
        local rootopt
 
-       eval $(awk '/^[\t ]*#/ {next} {if ( $2 == "/" ) {print "rootdev=\"" $1 
"\"\nrootFs=\"" $3 "\"\nrootopt=\"" $4 "\""}}' $fstab)
+       eval $(awk '!/^[\t ]*#/ && $2 == "/" 
{printf("rootdev=\"%s\"\nrootFs=\"%s\"\nrootopt=\"%s\"\n", $1, $3, $4)}' $fstab)
        if [ -z "$rootdev" ]; then
-               echo >&2 "$function: can't find real device for rootfs"
+               echo >&2 "$function: can't find fstab entry for root mountpoint"
                return 1
        fi
 
@@ -35,7 +35,11 @@
 
                local label=${rootdev#"LABEL="}
                local dev=$(/sbin/blkid -t LABEL="$label" -o device)
-               if [ "$dev" -a -r "$dev" ]; then
+               if [ "$dev" ]; then
+                       if [ ! -r "$dev" ]; then
+                               echo >&2 "$function: blkid returned device $dev 
which doesn't exist"
+                               return 2
+                       fi
                        rootdev=$dev
                fi
                ;;
@@ -49,7 +53,11 @@
                local uuid=${rootdev#"UUID="}
                local dev=$(/sbin/blkid -t UUID="$uuid" -o device)
 
-               if [ "$dev" -a -r "$dev" ]; then
+               if [ "$dev" ]; then
+                       if [ ! -r "$dev" ]; then
+                               echo >&2 "$function: blkid returned device $dev 
which doesn't exist"
+                               return 2
+                       fi
                        rootdev=$dev
                fi
                ;;
@@ -87,7 +95,16 @@
        ;;
        esac
 
-       local lvm_path=$(/sbin/lvdisplay -c 2>/dev/null | awk -F: -vn=$dm_minor 
'{node=$1; major=$12; minor=$13; if (n == minor) print node}')
+       local lvm_path=$(/sbin/lvdisplay -c 2>/dev/null | awk -F: -vn=$dm_minor 
'{node=$1; major=$12; minor=$13; if (n == minor) print node}' | xargs)
+       if [ -z "$lvm_path" ]; then
+               # XXX: this could happen also for non-lvm nodes?
+               echo >&2 "lvdisplay couldn't find device-mapper node with minor 
$dm_minor. try running 'vgscan --mknodes'."
+               return 2
+       fi
+       if [ ! -r "$lvm_path" ]; then
+               echo >&2 "lvdisplay returned $lvm_path which doesn't exist in 
filesystem; try running 'vgscan --mknodes'."
+               return 2
+       fi
        echo $lvm_path
 }
 
_______________________________________________
pld-cvs-commit mailing list
[email protected]
http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit

Reply via email to