]> git.pld-linux.org Git - projects/geninitrd.git/commitdiff
Check if kernel supports specified INITRDFS (tested with initramfs and romfs only...
authorArkadiusz Miśkiewicz <arekm@maven.pl>
Fri, 26 Feb 2016 17:15:14 +0000 (18:15 +0100)
committerArkadiusz Miśkiewicz <arekm@maven.pl>
Fri, 26 Feb 2016 17:15:14 +0000 (18:15 +0100)
geninitrd

index a4de1960593a60280b7e8bebd77e858cdfcd10e3..92a519d330a7692c42887516a2ca2485dc5f8097 100755 (executable)
--- a/geninitrd
+++ b/geninitrd
@@ -1097,7 +1097,7 @@ sym_exists() {
                return 1
        fi
 
-       awk -vc=1 -vsymbol="$symbol" '$2 == "T" && $3 == symbol {c = 0} END {exit c}' $mapfile
+       awk -vc=1 -vsymbol="$symbol" '($2 == "T" || $2 == "t") && $3 == symbol {c = 0} END {exit c}' $mapfile
 }
 
 # find best compressor (or forced one) for initrd
@@ -1400,24 +1400,46 @@ if [ -z "$INITRDFS" ]; then
        fi
 fi
 
-case "$INITRDFS" in
-  ext2)
-       [ -x /sbin/mke2fs ] || die "/sbin/mke2fs is missing"
-       ;;
-  rom|romfs)
-       [ -x /sbin/genromfs ] || die "/sbin/genromfs is missing"
-       ;;
-  cram|cramfs)
-       [ -x /sbin/mkcramfs ] || die "/sbin/mkcramfs is missing"
-       ;;
-  initramfs)
-       [ -x /bin/cpio ] || die "/bin/cpio is missing"
-       [ -x /usr/bin/find ] || die "/usr/bin/find is missing"
-       ;;
-  *)
-       die "Filesystem $INITRDFS on initrd is not supported"
-       ;;
-esac
+check_initrd_fs() {
+       local s sfound sym p prog map=/boot/System.map-$kernel
+       case "$INITRDFS" in
+               ext2)
+                       # TODO: symbols to check in case of ext2 used via ext3/4 subsystem
+                       sym=init_ext2_fs
+                       prog=/sbin/mke2fs
+                       ;;
+               rom|romfs)
+                       sym=init_romfs_fs
+                       prog=/sbin/genromfs
+                       ;;
+               cram|cramfs)
+                       sym=init_cramfs_fs
+                       prog=/sbin/mkcramfs
+                       ;;
+               initramfs)
+                       sym=__initramfs_start
+                       prog="/bin/cpio /usr/bin/find"
+                       ;;
+               *)
+                       die "Filesystem $INITRDFS on initrd is not supported by geninitrd"
+                       ;;
+       esac
+
+       # only one is needed (for cases like ext2 via ext2 or via ext3 or via ext4 subsysytem)
+       sfound=0
+       for s in $sym; do
+               sym_exists $map $s && sfound=1
+               break
+       done
+       if [ "$sfound" -eq "0" ]; then
+               die "Filesystem $INITRDFS on initrd is not supported by kernel"
+       fi
+
+       for p in $prog; do
+               [ ! -x "$p" ] && die "$prog is missing"
+       done
+}
+check_initrd_fs
 
 if [ -L "$target" ]; then
        target=$(readlink -f "$target")
This page took 0.216908 seconds and 4 git commands to generate.