]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
lsinitrd: list squash content as well
authorKairui Song <kasong@redhat.com>
Wed, 26 Dec 2018 09:38:02 +0000 (17:38 +0800)
committerHarald Hoyer <harald@hoyer.xyz>
Thu, 10 Jan 2019 09:16:44 +0000 (10:16 +0100)
When the initramfs is built with squash module enabled, the content
inside squash image will be invisible from the lsinitrd tool. This
commit make lsinitrd detect and list the content of the squash image as
well to avoid possible confusion.

Signed-off-by: Kairui Song <kasong@redhat.com>
lsinitrd.sh

index a2fa4d7a6aee25625472b97fd6230a1f943411cd..0b42b9a48bc19d33c976691a2f37be2200874340 100755 (executable)
@@ -160,6 +160,21 @@ list_files()
     echo "========================================================================"
 }
 
+list_squash_content()
+{
+    SQUASH_IMG="squash/root.img"
+    SQUASH_TMPFILE="$(mktemp -t --suffix=.root.sqsh lsinitrd.XXXXXX)"
+    trap "rm -f '$SQUASH_TMPFILE'" EXIT
+    $CAT "$image" 2>/dev/null | cpio --extract --verbose --quiet --to-stdout -- \
+        $SQUASH_IMG > "$SQUASH_TMPFILE" 2>/dev/null
+    if [[ -s $SQUASH_TMPFILE ]]; then
+        echo "Squashed content ($SQUASH_IMG):"
+        echo "========================================================================"
+        unsquashfs -ll "$SQUASH_TMPFILE" | tail -n +4
+        echo "========================================================================"
+    fi
+}
+
 unpack_files()
 {
     if (( ${#filenames[@]} > 0 )); then
@@ -287,6 +302,7 @@ else
         echo
         list_modules
         list_files
+        list_squash_content
     fi
 fi