[projects/geninitrd] initrd_gen_setrootdev: retry ls -l for busybox 1.22, avoid writing 0 to real-root-dev
glen
glen at pld-linux.org
Tue May 13 23:21:19 CEST 2014
commit 94da85dbcdd525e895aa1719965ee3041a5f5ce5
Author: Elan Ruusamäe <glen at delfi.ee>
Date: Wed May 14 00:21:16 2014 +0300
initrd_gen_setrootdev: retry ls -l for busybox 1.22, avoid writing 0 to real-root-dev
geninitrd | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/geninitrd b/geninitrd
index 8773697..213cda9 100755
--- a/geninitrd
+++ b/geninitrd
@@ -855,11 +855,17 @@ initrd_gen_setrootdev() {
add_linuxrc <<-'EOF'
if [ "${ROOT##/dev/}" != "${ROOT}" ]; then
rootnr="$(busybox awk -v rootnode="${ROOT##/dev/}" '$4 == rootnode { print 256 * $1 + $2 }' /proc/partitions)"
- # fallback to ls
- if [ -z "$rootnr" -a -e "$ROOT" ]; then
+ # fallback to ls, try two different formats
+ # http://lists.pld-linux.org/mailman/pipermail/pld-devel-en/2014-May/023915.html
+ if [ "${rootnr:-0}" = 0 -a -e "$ROOT" ]; then
+ # busybox up to 1.22
rootnr="$(busybox ls -lL ${ROOT} | busybox awk '{if (/^b/) { print 256 * $3 + $4; }}')"
fi
- if [ "$rootnr" -gt 0 ]; then
+ if [ "${rootnr:-0}" = 0 -a -e "$ROOT" ]; then
+ # busybox 1.22 and upwards
+ rootnr="$(busybox ls -lL ${ROOT} | busybox awk '{if (/^b/) { print 256 * $5 + $6; }}')"
+ fi
+ if [ "${rootnr:-0}" -gt 0 ]; then
echo "$rootnr" > /proc/sys/kernel/real-root-dev
fi
fi
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/projects/geninitrd.git/commitdiff/94da85dbcdd525e895aa1719965ee3041a5f5ce5
More information about the pld-cvs-commit
mailing list