[readonly/geninitrd: 452/1068] - we can grab the proper lvm path from lvdisplay output

draenog draenog at pld-linux.org
Sat Nov 2 19:50:22 CET 2013


commit 18a69561f1876b1d44dfe18dbe6ddadd0758ada6
Author: Elan Ruusamäe <glen at pld-linux.org>
Date:   Tue Oct 23 19:30:13 2007 +0000

    - we can grab the proper lvm path from lvdisplay output
    
    svn-id: @8843

 functions | 22 +++-------------------
 1 file changed, 3 insertions(+), 19 deletions(-)
---
diff --git a/functions b/functions
index 842e49a..6217fb8 100644
--- a/functions
+++ b/functions
@@ -77,25 +77,9 @@ find_root() {
 # which they got from blkid program fs was specifed as UUID= in fstab
 dm_lvm2_name() {
 	local node="$1"
-
-	# redirect output to tmpfile so we won't get subshell
-	local tmp ret
-	tmp=$(mktemp) || return 1
-
-	/sbin/lvdisplay -c 2>/dev/null | awk -F: '{print $1}' > $tmp
-	while read dev; do
-		count=$(ls -Ll $dev $node | awk '{print $5, $6}' | sort -u | wc -l)
-		if [ "$count" = 1 ]; then
-			ret="$dev"
-			break
-		fi
-	done < $tmp
-	rm -f $tmp
-
-	if [ -z "$ret" ]; then
-		ret=$node
-	fi
-	echo "$ret"
+	local dm_minor=${node#/dev/dm-}
+	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}')
+	echo $lvm_path
 }
 
 # try to resolve /dev/dm-0 to item from /dev/mapper dir
================================================================

---- gitweb:

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



More information about the pld-cvs-commit mailing list