[readonly/geninitrd: 484/1068] - more detailed error messages when processing fstab and lvm

draenog draenog at pld-linux.org
Sat Nov 2 19:53:04 CET 2013


commit 8bc082c864db3f5e2acbf523aa24d5aa323dc67f
Author: Elan Ruusamäe <glen at pld-linux.org>
Date:   Tue Oct 30 15:07:28 2007 +0000

    - more detailed error messages when processing fstab and lvm
    
    svn-id: @8898

 functions | 27 ++++++++++++++++++++++-----
 1 file changed, 22 insertions(+), 5 deletions(-)
---
diff --git a/functions b/functions
index 1c1dfdf..32e40c7 100644
--- a/functions
+++ b/functions
@@ -17,9 +17,9 @@ find_root() {
 	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 @@ find_root() {
 
 		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 @@ find_root() {
 		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 @@ dm_lvm2_name() {
 	;;
 	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
 }
 
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/readonly/geninitrd.git/commitdiff/147754ca159d40ca5eb541074dc043d8cbd92090



More information about the pld-cvs-commit mailing list