[OpenWrt-Devel] Unable to mount squashfs, no real error returned (Invalid argument)

2012-08-24 Thread Rafał Miłecki
Hey,

I have original firmware installed on my (unsupported) router and I'm
booting ELF image using tftp. My purpose is to get correct partitions
layout and access to them.

Linux correctly detects mtds, I get:
0x001c-0x001416a4 : linux
0x001416a4-0x007ba000 : rootfs

# cat /proc/mtd
dev:size   erasesize  name
mtd0: 001e  boot
mtd1: 0001  board_data
mtd2: 0001  nvram
mtd3: 00141688 0002 linux
mtd4: 0067895c 0002 rootfs

So the mtd I'm interested in is mtd4.

# head /dev/mtd4 | hexdump -C
  73 68 73 71 2b 03 00 00  00 00 00 54 03 00 00 d8  |shsq+..T|

# head /dev/mtdblock4 | hexdump -C
head: /: Input/output error
  3d 3d 3e 20 2f 20 3c 3d  3d 0a 0a 3d 3d 3e 20 64  |== / ==..== d|
0010  65 76 2f 6d 74 64 62 6c  6f 63 6b 34 20 3c 3d 3d  |ev/mtdblock4 ==|
0020  0a 73 68 73 71 2b 03 00  00 00 00 00 54 03 00 00  |.shsq+..T...|

Again...

# head /dev/mtdblock4 | hexdump -C
  73 68 73 71 2b 03 00 00  00 00 00 54 03 00 00 d8  |shsq+..T|

Now the most interesting part:

# mount -t squashfs /dev/mtdblock4 /mnt/
mount: mounting /dev/mtdblock4 on /mnt/ failed: Invalid argument


Can someone explain to me, what does it mean? Is there something wrong
with my mtdblock4? I don't get anything interesting in dmesg.

Is that possible squashfs used by original firmware is somehow
malformed and requires original-vendor-hacked squashfs support?

-- 
Rafał
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] Unable to mount squashfs, no real error returned (Invalid argument)

2012-08-24 Thread Jonas Gorski
Hi Rafał,

On 24 August 2012 23:09, Rafał Miłecki zaj...@gmail.com wrote:
 (...)
 # head /dev/mtd4 | hexdump -C
   73 68 73 71 2b 03 00 00  00 00 00 54 03 00 00 d8  |shsq+..T|
 (...)
 Can someone explain to me, what does it mean? Is there something wrong
 with my mtdblock4? I don't get anything interesting in dmesg.

The problem is that Broadcom uses its own squashfs with lzma-magic.
The standard squashfs magic is sqsh or hsqs (depending on
endianess), and Broadcom chose to use a different one (since squashfs3
does not support storing the compressor type). There is a patch adding
support for unsquashfs in the repo (so you should be able to just
throw a copy of the image at it), but the in-kernel squashfs only
accepts standard squashfs magics.


Jonas
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] Unable to mount squashfs, no real error returned (Invalid argument)

2012-08-24 Thread Rafał Miłecki
2012/8/24 Jonas Gorski jonas.gorski+open...@gmail.com:
 Hi Rafał,

 On 24 August 2012 23:09, Rafał Miłecki zaj...@gmail.com wrote:
 (...)
 # head /dev/mtd4 | hexdump -C
   73 68 73 71 2b 03 00 00  00 00 00 54 03 00 00 d8  
 |shsq+..T|
 (...)
 Can someone explain to me, what does it mean? Is there something wrong
 with my mtdblock4? I don't get anything interesting in dmesg.

 The problem is that Broadcom uses its own squashfs with lzma-magic.
 The standard squashfs magic is sqsh or hsqs (depending on
 endianess), and Broadcom chose to use a different one (since squashfs3
 does not support storing the compressor type). There is a patch adding
 support for unsquashfs in the repo (so you should be able to just
 throw a copy of the image at it), but the in-kernel squashfs only
 accepts standard squashfs magics.

Ah, OK, thanks a lot!

I've managed to track where mounting fails. It's
fs/squashfs/super.c::squashfs_fill_super. As you said, it fails at:

if (sb-s_magic != SQUASHFS_MAGIC)

Unfortunately error wasn't displayed to me, because flag MS_SILENT was set.

Backtrace after I put WARN_ON(1):

[   33.984000] [ cut here ]
[   33.988000] WARNING: at fs/squashfs/super.c:126
squashfs_fill_super+0x1a0/0x84c()
[   33.996000] Modules linked in:
[   34.00] Call Trace:
[   34.004000] [8025ce80] dump_stack+0x8/0x34
[   34.008000] [80023780] warn_slowpath_common+0x78/0xa4
[   34.012000] [800237c4] warn_slowpath_null+0x18/0x24
[   34.016000] [80103640] squashfs_fill_super+0x1a0/0x84c
[   34.024000] [800a7c0c] mount_bdev+0x14c/0x1cc
[   34.028000] [801033b0] squashfs_mount+0x18/0x24
[   34.032000] [800a856c] mount_fs+0x20/0xe4
[   34.036000] [800bfaf4] vfs_kern_mount+0x64/0xe8
[   34.04] [800bfda0] do_kern_mount+0x48/0xf4
[   34.048000] [800c1cc0] do_mount+0x67c/0x6fc
[   34.052000] [800c1dcc] sys_mount+0x8c/0xf0
[   34.056000] [8000d1d0] stack_done+0x20/0x40
[   34.06]
[   34.06] ---[ end trace 088bd3492332a7b0 ]---

-- 
Rafał
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel