]> git.pld-linux.org Git - projects/geninitrd.git/commitdiff
initrd_gen_setrootdev: retry ls -l for busybox 1.22, avoid writing 0 to real-root-dev
authorElan Ruusamäe <glen@delfi.ee>
Tue, 13 May 2014 21:21:16 +0000 (00:21 +0300)
committerElan Ruusamäe <glen@delfi.ee>
Tue, 13 May 2014 21:21:16 +0000 (00:21 +0300)
geninitrd

index 8773697746585c5ab6dee2472571b193275acd16..213cda9ba8bf124f0e189b3e310c062477042c6d 100755 (executable)
--- 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
This page took 0.109513 seconds and 4 git commands to generate.