diff mbox

[U-Boot,v2] ubifs: Fix ubifsload when using ZLIB

Message ID 1346857514-14742-1-git-send-email-veli-pekka.peltola@bluegiga.com
State Awaiting Upstream
Delegated to: Stefan Roese
Headers show

Commit Message

Veli-Pekka Peltola Sept. 5, 2012, 3:05 p.m. UTC
Using ZLIB compression with UBIFS fails if last data node is not a size of
UBIFS_BLOCK_SIZE (4096 bytes).

Easiest way to test this is trying to read a file smaller than 4k:
=> ubifsload 41000000 /etc/fstab
Loading file '/etc/fstab' to addr 0x41000000 with size 704 (0x000002c0)...
UBIFS error (pid 0): read_block: bad data node (block 0, inode 2506)
UBIFS error (pid 0): do_readpage: cannot read page 0 of inode 2506, error -22
Error reading file '/etc/fstab'
/etc/fstab not found!
exit not allowed from main input shell.
=>

With this patch:

=> ubifsload 41000000 /etc/fstab
Loading file '/etc/fstab' to addr 0x41000000 with size 704 (0x000002c0)...
Done
=>

Signed-off-by: Veli-Pekka Peltola <veli-pekka.peltola@bluegiga.com>
Cc: kmpark@infradead.org
---
Changes for v2: use proper variable type

 fs/ubifs/ubifs.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Andreas Bießmann Sept. 7, 2012, 8 a.m. UTC | #1
On 05.09.2012 17:05, Veli-Pekka Peltola wrote:
> Using ZLIB compression with UBIFS fails if last data node is not a size of
> UBIFS_BLOCK_SIZE (4096 bytes).
> 
> Easiest way to test this is trying to read a file smaller than 4k:
> => ubifsload 41000000 /etc/fstab
> Loading file '/etc/fstab' to addr 0x41000000 with size 704 (0x000002c0)...
> UBIFS error (pid 0): read_block: bad data node (block 0, inode 2506)
> UBIFS error (pid 0): do_readpage: cannot read page 0 of inode 2506, error -22
> Error reading file '/etc/fstab'
> /etc/fstab not found!
> exit not allowed from main input shell.
> =>
> 
> With this patch:
> 
> => ubifsload 41000000 /etc/fstab
> Loading file '/etc/fstab' to addr 0x41000000 with size 704 (0x000002c0)...
> Done
> =>
> 
> Signed-off-by: Veli-Pekka Peltola <veli-pekka.peltola@bluegiga.com>
> Cc: kmpark@infradead.org

Tested-by: Andreas Bießmann <andreas.devel@googlemail.com>
Stefan Roese Sept. 10, 2012, 9:39 a.m. UTC | #2
On 09/05/2012 05:05 PM, Veli-Pekka Peltola wrote:
> Using ZLIB compression with UBIFS fails if last data node is not a size of
> UBIFS_BLOCK_SIZE (4096 bytes).
> 
> Easiest way to test this is trying to read a file smaller than 4k:
> => ubifsload 41000000 /etc/fstab
> Loading file '/etc/fstab' to addr 0x41000000 with size 704 (0x000002c0)...
> UBIFS error (pid 0): read_block: bad data node (block 0, inode 2506)
> UBIFS error (pid 0): do_readpage: cannot read page 0 of inode 2506, error -22
> Error reading file '/etc/fstab'
> /etc/fstab not found!
> exit not allowed from main input shell.
> =>
> 
> With this patch:
> 
> => ubifsload 41000000 /etc/fstab
> Loading file '/etc/fstab' to addr 0x41000000 with size 704 (0x000002c0)...
> Done
> =>

Thanks for this fix.

Applied to u-boot-ubi/master after minor coding style fix (line over 80
chars).

Thanks,
Stefan

--
DENX Software Engineering GmbH,      MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich,  Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-0 Fax: (+49)-8142-66989-80 Email: office@denx.de
diff mbox

Patch

diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c
index c68802b..d241774 100644
--- a/fs/ubifs/ubifs.c
+++ b/fs/ubifs/ubifs.c
@@ -37,8 +37,7 @@  DECLARE_GLOBAL_DATA_PTR;
 static int gzip_decompress(const unsigned char *in, size_t in_len,
 			   unsigned char *out, size_t *out_len)
 {
-	unsigned long len = in_len;
-	return zunzip(out, *out_len, (unsigned char *)in, &len, 0, 0);
+	return zunzip(out, *out_len, (unsigned char *)in, (unsigned long *)out_len, 0, 0);
 }
 
 /* Fake description object for the "none" compressor */