From e4a04a433e9b792066be30e3c820b7356abc44b5 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Mon, 6 Feb 2017 18:37:08 +0100 Subject: mount-nv: properly detect jffs2 when the superblock starts after empty blocks On some large (?) file JFFS2 systems, it may happen that the superblock starts anywhere. Eg it was observed at 31.5 MB on a 64 MB partition. This could not be mounted because the resulting type was "empty". Now instead if the type appears to be "empty", we skip all the first 0xFF and report what follows. It's not rocket science but works well enough on a really empty image. If that's not enough, a future option could consist in returning "jffs2" when "empty" was found but it would be better to avoid this if possible. --- scripts/mount-nv | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/mount-nv b/scripts/mount-nv index 2c2ce3f..b93680e 100755 --- a/scripts/mount-nv +++ b/scripts/mount-nv @@ -145,6 +145,13 @@ get_image_type() { REPLY="" get_image_type_from_dump $(od -v -An -tx1 -N1082 2>/dev/null < "$dev") + if [ "$REPLY" = "empty" ]; then + # jffs2 can start anywhere, so we must skip all 0xFF and see + # what we have just after. In this case only 4 bytes are needed + # after all this. Otherwise it remains "empty". + get_image_type_from_dump $(tr -d '\377' < "$dev" | od -v -An -tx1 -N4 2>/dev/null) + [ "$REPLY" = "jffs2" ] || REPLY=empty + fi [ -n "$REPLY" ] && return 0 -- 1.7.12.1