[projects/geninitrd] save 19 lines of debug output (debugrd)

gotar gotar at pld-linux.org
Sun Aug 14 22:09:58 CEST 2016


commit 6ed0f7b1ebdba0a6aaed765e3f4c293ac09f975b
Author: Tomasz Pala <gotar at pld-linux.org>
Date:   Sun Aug 14 22:01:15 2016 +0200

    save 19 lines of debug output (debugrd)

 geninitrd | 43 ++++++++++++-------------------------------
 1 file changed, 12 insertions(+), 31 deletions(-)
---
diff --git a/geninitrd b/geninitrd
index 0b838e6..d152eec 100755
--- a/geninitrd
+++ b/geninitrd
@@ -937,59 +937,40 @@ initrd_gen_initramfs_switchroot() {
 	add_linuxrc <<-'EOF'
 		device=
 		eval "$(busybox awk -v root="$ROOT" '
-			# http://9fans.net/archive/2006/09/261
-			function h2d(str, hstr, res, num, n, digit, i) {
-				hstr = "0123456789abdcef";
-				res = 0;
+			function h2d(str, hstr, res, num, n, digit, i) {	# http://9fans.net/archive/2006/09/261
+				hstr = "0123456789abdcef"; res = 0;
 				n = split(tolower(str), digit, "");
 
 				for (i = 1; i <= n; i++) {
 					num = index(hstr, digit[i]) - 1;
 					res = res + (num * 16 ^ (n - i));
 				}
-
 				return res;
 			}
 			BEGIN {
-
 				num_pattern_short = "[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]";
 				num_pattern = "[0-9a-fA-F]" num_pattern_short;
 				dev_pattern = "[hms][a-z][a-z]([0-9])+";
-				partition = "";
-				min = -1; maj = -1;
-
-				# see if we have /dev/hdX or hdX, we can just take partition name
-				if (root ~ "^\/dev\/" dev_pattern "$" || root ~ "^" dev_pattern "$") {
-					partition = root
-					sub("^/dev/", "", partition);
-
-				} else {
-					# unify values first
-					if (root ~ "^" num_pattern_short "$")  {
-						# change "303" => "0x0303"
+				partition = ""; min = -1; maj = -1;
+
+				if (root ~ "^\/dev\/" dev_pattern "$" || root ~ "^" dev_pattern "$") {	# see if we have /dev/hdX or hdX, we can just take partition name
+					partition = root; sub("^/dev/", "", partition);
+				} else {	# unify values first
+					if (root ~ "^" num_pattern_short "$")  {	# change "303" => "0x0303"
 						root = "0x0" root
-					} else if (root ~ "^" num_pattern "$")  {
-						# change "0303" => "0x0303"
+					} else if (root ~ "^" num_pattern "$")  {	# change "0303" => "0x0303"
 						root = "0x" root
 					}
-
 					maj = h2d(substr(root, 3, 2));
 					min = h2d(substr(root, 5, 2));
 				}
 			}
-
 			partition && $4 == partition { maj = $1; min = $2; }
 			$1 == maj && $2 == min { partition = $4; }
-
 			END {
-				if (maj >= 0 && min >= 0) {
-					printf("maj=%s; min=%s;\n", maj, min);
-				}
-				if (partition) {
-					printf("device=/dev/%s;\n", partition);
-				}
-			}
-			' /proc/partitions)"
+				if (maj >= 0 && min >= 0) {	printf("maj=%s; min=%s;\n", maj, min);	}
+				if (partition) {		printf("device=/dev/%s;\n", partition);	}
+			}' /proc/partitions)"
 
 		if [ -z "$device" ]; then
 			if [ "$DEBUGINITRD" -a "$DEBUGINITRD" != 'sh' ]; then
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/projects/geninitrd.git/commitdiff/6ed0f7b1ebdba0a6aaed765e3f4c293ac09f975b



More information about the pld-cvs-commit mailing list