[projects/geninitrd] Check if kernel supports specified INITRDFS (tested with initramfs and romfs only though)
arekm
arekm at pld-linux.org
Fri Feb 26 18:15:18 CET 2016
commit fee61d3f4dd96bfdca441a8ab524d9928309559e
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date: Fri Feb 26 18:15:14 2016 +0100
Check if kernel supports specified INITRDFS (tested with initramfs and romfs only though)
geninitrd | 60 +++++++++++++++++++++++++++++++++++++++++-------------------
1 file changed, 41 insertions(+), 19 deletions(-)
---
diff --git a/geninitrd b/geninitrd
index a4de196..92a519d 100755
--- 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")
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/projects/geninitrd.git/commitdiff/fee61d3f4dd96bfdca441a8ab524d9928309559e
More information about the pld-cvs-commit
mailing list