* [U-Boot] [PATCH 1/9] ubifs: BUG: Blocks commpressed with zlib
@ 2009-04-24 11:50 Ricardo Ribalda Delgado
2009-04-24 11:50 ` [U-Boot] [PATCH 9/9] ubifs: Add '\0' to the end of the realpath Ricardo Ribalda Delgado
2009-04-24 14:17 ` [U-Boot] [PATCH 1/9] ubifs: BUG: Blocks commpressed with zlib Stefan Roese
0 siblings, 2 replies; 4+ messages in thread
From: Ricardo Ribalda Delgado @ 2009-04-24 11:50 UTC (permalink / raw)
To: u-boot
Blocks compressed with zlib are not handled correctly.
gunzip decompress blocks with the gzip header, but ubi blocks
dont have header.
---
fs/ubifs/ubifs.c | 43 ++++++++++++++++++++++++++++++++++++++++++-
fs/ubifs/ubifs.h | 2 --
2 files changed, 42 insertions(+), 3 deletions(-)
diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c
index 32f9ff8..0708d90 100644
--- a/fs/ubifs/ubifs.c
+++ b/fs/ubifs/ubifs.c
@@ -24,6 +24,7 @@
*/
#include "ubifs.h"
+#include <u-boot/zlib.h>
#if !defined(CONFIG_SYS_64BIT_VSPRINTF)
#warning Please define CONFIG_SYS_64BIT_VSPRINTF for correct output!
@@ -33,6 +34,10 @@ DECLARE_GLOBAL_DATA_PTR;
/* compress.c */
+int ubi_gunzip(void *dst, int dstlen, unsigned char *src, unsigned long *lenp);
+void *zalloc(void *, unsigned, unsigned);
+void zfree(void *, void *, unsigned);
+
/*
* We need a wrapper for gunzip() because the parameters are
* incompatible with the lzo decompressor.
@@ -41,7 +46,7 @@ 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 gunzip(out, *out_len, (unsigned char *)in, &len);
+ return ubi_gunzip(out, *out_len, (unsigned char *)in, &len);
}
/* Fake description object for the "none" compressor */
@@ -685,3 +690,39 @@ out:
ubi_close_volume(c->ubi);
return err;
}
+
+int ubi_gunzip(void *dst, int dstlen, unsigned char *src, unsigned long *lenp)
+{
+ z_stream s;
+ int r, i, flags;
+ i=0;
+
+ s.zalloc = zalloc;
+ s.zfree = zfree;
+#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+ s.outcb = (cb_func)WATCHDOG_RESET;
+#else
+ s.outcb = Z_NULL;
+#endif /* CONFIG_HW_WATCHDOG */
+
+ r = inflateInit2(&s, -MAX_WBITS);
+ if (r != Z_OK) {
+ printf ("Error: inflateInit2() returned %d\n", r);
+ return (-1);
+ }
+ s.next_in = src + i;
+ s.avail_in = *lenp - i;
+ s.next_out = dst;
+ s.avail_out = dstlen;
+ r = inflate(&s, Z_FINISH);
+ if (r != Z_STREAM_END) {
+ //printf ("Error: inflate() returned %d\n", r);
+ //inflateEnd(&s);
+ //return (-1);
+ }
+ *lenp = s.next_out - (unsigned char *) dst;
+ inflateEnd(&s);
+
+ return (0);
+
+}
diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h
index 91351de..a68e4c1 100644
--- a/fs/ubifs/ubifs.h
+++ b/fs/ubifs/ubifs.h
@@ -2172,6 +2172,4 @@ int ubifs_decompress(const void *buf, int len, void *out, int *out_len,
/* todo: Move these to a common U-Boot header */
int lzo1x_decompress_safe(const unsigned char *in, size_t in_len,
unsigned char *out, size_t *out_len);
-int gunzip(void *dst, int dstlen, unsigned char *src, unsigned long *lenp);
-
#endif /* !__UBIFS_H__ */
--
1.6.2.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH 9/9] ubifs: Add '\0' to the end of the realpath
2009-04-24 11:50 [U-Boot] [PATCH 1/9] ubifs: BUG: Blocks commpressed with zlib Ricardo Ribalda Delgado
@ 2009-04-24 11:50 ` Ricardo Ribalda Delgado
2009-04-24 14:13 ` Stefan Roese
2009-04-24 14:17 ` [U-Boot] [PATCH 1/9] ubifs: BUG: Blocks commpressed with zlib Stefan Roese
1 sibling, 1 reply; 4+ messages in thread
From: Ricardo Ribalda Delgado @ 2009-04-24 11:50 UTC (permalink / raw)
To: u-boot
---
fs/ubifs/ubifs.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c
index 0708d90..4dc315e 100644
--- a/fs/ubifs/ubifs.c
+++ b/fs/ubifs/ubifs.c
@@ -646,6 +646,8 @@ int ubifs_load(char *filename, u32 addr, u32 size)
ui = ubifs_inode(inode);
if (((inode->i_mode & S_IFMT) == S_IFLNK) && ui->data_len) {
memcpy(link_name, ui->data, ui->data_len);
+ link_name[ui->data_len]='\0';
+ memcpy(link_name, ui->data, ui->data_len);
printf("%s is linked to %s!\n", filename, link_name);
ubifs_iput(inode);
--
1.6.2.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH 9/9] ubifs: Add '\0' to the end of the realpath
2009-04-24 11:50 ` [U-Boot] [PATCH 9/9] ubifs: Add '\0' to the end of the realpath Ricardo Ribalda Delgado
@ 2009-04-24 14:13 ` Stefan Roese
0 siblings, 0 replies; 4+ messages in thread
From: Stefan Roese @ 2009-04-24 14:13 UTC (permalink / raw)
To: u-boot
On Friday 24 April 2009, Ricardo Ribalda Delgado wrote:
> ---
First of all your Signed-off-by line is missing. In your other patch as well.
And please add a description of the problem that's fixed with this patch. I've
used UBIFS on some boards now and have not seen any problems. Please give an
example of what's broken in the current code and fixed with your patch.
> fs/ubifs/ubifs.c | 2 ++
> 1 files changed, 2 insertions(+), 0 deletions(-)
>
> diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c
> index 0708d90..4dc315e 100644
> --- a/fs/ubifs/ubifs.c
> +++ b/fs/ubifs/ubifs.c
> @@ -646,6 +646,8 @@ int ubifs_load(char *filename, u32 addr, u32 size)
> ui = ubifs_inode(inode);
> if (((inode->i_mode & S_IFMT) == S_IFLNK) && ui->data_len) {
> memcpy(link_name, ui->data, ui->data_len);
> + link_name[ui->data_len]='\0';
> + memcpy(link_name, ui->data, ui->data_len);
Hmmm. This looks strange. Didn't you want to remove the first memcpy()?
Thanks.
Best regards,
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 at denx.de
=====================================================================
^ permalink raw reply [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH 1/9] ubifs: BUG: Blocks commpressed with zlib
2009-04-24 11:50 [U-Boot] [PATCH 1/9] ubifs: BUG: Blocks commpressed with zlib Ricardo Ribalda Delgado
2009-04-24 11:50 ` [U-Boot] [PATCH 9/9] ubifs: Add '\0' to the end of the realpath Ricardo Ribalda Delgado
@ 2009-04-24 14:17 ` Stefan Roese
1 sibling, 0 replies; 4+ messages in thread
From: Stefan Roese @ 2009-04-24 14:17 UTC (permalink / raw)
To: u-boot
On Friday 24 April 2009, Ricardo Ribalda Delgado wrote:
> Blocks compressed with zlib are not handled correctly.
> gunzip decompress blocks with the gzip header, but ubi blocks
> dont have header.
> ---
Again, Signed-off-by missing.
More comments below.
> fs/ubifs/ubifs.c | 43 ++++++++++++++++++++++++++++++++++++++++++-
> fs/ubifs/ubifs.h | 2 --
> 2 files changed, 42 insertions(+), 3 deletions(-)
>
> diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c
> index 32f9ff8..0708d90 100644
> --- a/fs/ubifs/ubifs.c
> +++ b/fs/ubifs/ubifs.c
> @@ -24,6 +24,7 @@
> */
>
> #include "ubifs.h"
> +#include <u-boot/zlib.h>
>
> #if !defined(CONFIG_SYS_64BIT_VSPRINTF)
> #warning Please define CONFIG_SYS_64BIT_VSPRINTF for correct output!
> @@ -33,6 +34,10 @@ DECLARE_GLOBAL_DATA_PTR;
>
> /* compress.c */
>
> +int ubi_gunzip(void *dst, int dstlen, unsigned char *src, unsigned long
> *lenp); +void *zalloc(void *, unsigned, unsigned);
> +void zfree(void *, void *, unsigned);
> +
> /*
> * We need a wrapper for gunzip() because the parameters are
> * incompatible with the lzo decompressor.
> @@ -41,7 +46,7 @@ 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 gunzip(out, *out_len, (unsigned char *)in, &len);
> + return ubi_gunzip(out, *out_len, (unsigned char *)in, &len);
> }
>
> /* Fake description object for the "none" compressor */
> @@ -685,3 +690,39 @@ out:
> ubi_close_volume(c->ubi);
> return err;
> }
> +
> +int ubi_gunzip(void *dst, int dstlen, unsigned char *src, unsigned long
> *lenp) +{
> + z_stream s;
> + int r, i, flags;
> + i=0;
> +
> + s.zalloc = zalloc;
> + s.zfree = zfree;
> +#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
> + s.outcb = (cb_func)WATCHDOG_RESET;
> +#else
> + s.outcb = Z_NULL;
> +#endif /* CONFIG_HW_WATCHDOG */
> +
> + r = inflateInit2(&s, -MAX_WBITS);
> + if (r != Z_OK) {
> + printf ("Error: inflateInit2() returned %d\n", r);
> + return (-1);
> + }
> + s.next_in = src + i;
> + s.avail_in = *lenp - i;
> + s.next_out = dst;
> + s.avail_out = dstlen;
> + r = inflate(&s, Z_FINISH);
> + if (r != Z_STREAM_END) {
> + //printf ("Error: inflate() returned %d\n", r);
> + //inflateEnd(&s);
> + //return (-1);
> + }
Hmmm? Either do something in this if path or remove it completely.
Thanks.
Best regards,
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 at denx.de
=====================================================================
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-04-24 14:17 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-24 11:50 [U-Boot] [PATCH 1/9] ubifs: BUG: Blocks commpressed with zlib Ricardo Ribalda Delgado
2009-04-24 11:50 ` [U-Boot] [PATCH 9/9] ubifs: Add '\0' to the end of the realpath Ricardo Ribalda Delgado
2009-04-24 14:13 ` Stefan Roese
2009-04-24 14:17 ` [U-Boot] [PATCH 1/9] ubifs: BUG: Blocks commpressed with zlib Stefan Roese
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox