]> www.infradead.org Git - mtd-utils.git/commitdiff
Make it possible to compile jffsX-utils without zlib
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>
Sun, 18 Feb 2024 12:52:42 +0000 (13:52 +0100)
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>
Sun, 18 Feb 2024 12:54:59 +0000 (13:54 +0100)
The jffsX-utils already have a CONFIG_JFFS2_ZLIB define, but it is
statically defined in a header and not used consistently. This patch
first replaces it with a "WITH_ZLIB" define, provided via automake,
to bring it in line with the already existing "WITH_LZO". Then, the
missing checks and typedefs are added in jffs2reader.c.

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Makefile.am
jffsX-utils/compr.c
jffsX-utils/compr.h
jffsX-utils/jffs2reader.c

index 299a5fb47140a11016a85b79209b26954d33b513..06d154ad8204a94df81cbeaee4dd9f0bd00df00f 100644 (file)
@@ -3,6 +3,8 @@ ACLOCAL_AMFLAGS = -I m4
 AM_CPPFLAGS = $(WARN_CFLAGS) -D_GNU_SOURCE -std=gnu99 -I$(top_srcdir)/include \
                -include $(top_builddir)/include/config.h
 
+AM_CPPFLAGS += -DWITH_ZLIB
+
 if WITH_XATTR
 AM_CPPFLAGS += -DWITH_XATTR
 endif
index 42d8a70ebac6b9d4bdb3027f846e1fce13debb27..01176ebee8fd0ad72ec3dcdfad00e021c665ee14 100644 (file)
@@ -511,7 +511,7 @@ reinsert:
 
 int jffs2_compressors_init(void)
 {
-#ifdef CONFIG_JFFS2_ZLIB
+#ifdef WITH_ZLIB
        jffs2_zlib_init();
 #endif
 #ifdef CONFIG_JFFS2_RTIME
@@ -528,7 +528,7 @@ int jffs2_compressors_exit(void)
 #ifdef CONFIG_JFFS2_RTIME
        jffs2_rtime_exit();
 #endif
-#ifdef CONFIG_JFFS2_ZLIB
+#ifdef WITH_ZLIB
        jffs2_zlib_exit();
 #endif
 #ifdef WITH_LZO
index 0806f4d608106c9eb97cc44afebdac0821adbd39..f1f597581bff6fc0d6c44de1c62f6e4367a2fd40 100644 (file)
@@ -16,7 +16,6 @@
 #include <stdint.h>
 #include "linux/jffs2.h"
 
-#define CONFIG_JFFS2_ZLIB
 #define CONFIG_JFFS2_RTIME
 
 #define JFFS2_RUBINMIPS_PRIORITY 10
@@ -102,7 +101,7 @@ char *jffs2_stats(void);
 /* Compressor modules */
 
 /* These functions will be called by jffs2_compressors_init/exit */
-#ifdef CONFIG_JFFS2_ZLIB
+#ifdef WITH_ZLIB
 int jffs2_zlib_init(void);
 void jffs2_zlib_exit(void);
 #endif
index 33c55771639fe6ad7baa38cb46de60207cec9843..87a2167512ca9172095c6871d424eb3090616679 100644 (file)
@@ -75,7 +75,11 @@ BUGS:
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <dirent.h>
+#ifdef WITH_ZLIB
 #include <zlib.h>
+#else
+typedef unsigned long uLongf;
+#endif
 
 #include "mtd/jffs2-user.h"
 #include "common.h"
@@ -132,12 +136,13 @@ static void putblock(char *b, size_t bsize, size_t * rsize,
                bzero(b + *rsize, je32_to_cpu(n->isize) - *rsize);
 
        switch (n->compr) {
+#ifdef WITH_ZLIB
                case JFFS2_COMPR_ZLIB:
                        uncompress((Bytef *) b + je32_to_cpu(n->offset), &dlen,
                                        (Bytef *) ((char *) n) + sizeof(struct jffs2_raw_inode),
                                        (uLongf) je32_to_cpu(n->csize));
                        break;
-
+#endif
                case JFFS2_COMPR_NONE:
                        memcpy(b + je32_to_cpu(n->offset),
                                        ((char *) n) + sizeof(struct jffs2_raw_inode), dlen);