From 115d0aa6a71e89888765fac12c5135c97aef12c6 Mon Sep 17 00:00:00 2001 From: Andres Salomon Date: Mon, 1 Sep 2008 11:22:34 -0400 Subject: Fix parse_numeric() to ignore non hex root string prefixes On OLPC machines, root is a nand device that is mounted as mtd0 (it is neither a block device nor a char device). The arguments passed to the kernel are "ro root=mtd0 rootfstype=jffs2". Unfortunately, attempting to use an initrd based upon initramfs-tools on such a machine results in a kernel panic and a syntax error. Begin: Mounting root file system ... /init: line 172: syntax error: 0xmtd0 The probably appears to be in parse_numeric(); the init scripts assume that normal devices are always prefixed with /, and root= strings that aren't are raw device numbers (prefixing them with 0x). I'm not sure if there are other devices similar to mtd that don't begin with a /. How about something like the following patch? It's not foolproof, but it at least ignores things that can't possibly be hex strings. fixes partially #497133 --- scripts/functions | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'scripts/functions') diff --git a/scripts/functions b/scripts/functions index 5d81afd..299c29c 100644 --- a/scripts/functions +++ b/scripts/functions @@ -242,11 +242,14 @@ parse_numeric() { minor=${1#*:} major=${1%:*} ;; - *) + [A-Fa-f0-9]*) value=$(( 0x${1} )) minor=$(( ${value} % 256 )) major=$(( ${value} / 256 )) ;; + *) + return + ;; esac mknod -m 600 /dev/root b ${major} ${minor} -- cgit v1.2.3