2 * JFFS2 -- Journalling Flash File System, Version 2.
4 * Copyright (C) 2004 Ferenc Havasi <havasi@inf.u-szeged.hu>,
5 * University of Szeged, Hungary
7 * For licensing information, see the file 'LICENCE' in the
10 * $Id: compr.h,v 1.6 2004/07/16 15:17:57 dwmw2 Exp $
14 #ifndef __JFFS2_COMPR_H__
15 #define __JFFS2_COMPR_H__
17 #include <linux/kernel.h>
18 #include <linux/vmalloc.h>
19 #include <linux/list.h>
20 #include <linux/types.h>
21 #include <linux/string.h>
22 #include <linux/slab.h>
23 #include <linux/errno.h>
25 #include <linux/jffs2.h>
26 #include <linux/jffs2_fs_i.h>
27 #include <linux/jffs2_fs_sb.h>
30 #define JFFS2_RUBINMIPS_PRIORITY 10
31 #define JFFS2_DYNRUBIN_PRIORITY 20
32 #define JFFS2_LZARI_PRIORITY 30
33 #define JFFS2_LZO_PRIORITY 40
34 #define JFFS2_RTIME_PRIORITY 50
35 #define JFFS2_ZLIB_PRIORITY 60
37 #define JFFS2_RUBINMIPS_DISABLED /* RUBINs will be used only */
38 #define JFFS2_DYNRUBIN_DISABLED /* for decompression */
40 #define JFFS2_COMPR_MODE_NONE 0
41 #define JFFS2_COMPR_MODE_PRIORITY 1
42 #define JFFS2_COMPR_MODE_SIZE 2
44 void jffs2_set_compression_mode(int mode
);
45 int jffs2_get_compression_mode(void);
47 struct jffs2_compressor
{
48 struct list_head list
;
49 int priority
; /* used by prirority comr. mode */
51 char compr
; /* JFFS2_COMPR_XXX */
52 int (*compress
)(unsigned char *data_in
, unsigned char *cpage_out
,
53 uint32_t *srclen
, uint32_t *destlen
, void *model
);
54 int (*decompress
)(unsigned char *cdata_in
, unsigned char *data_out
,
55 uint32_t cdatalen
, uint32_t datalen
, void *model
);
57 int disabled
; /* if seted the compressor won't compress */
58 unsigned char *compr_buf
; /* used by size compr. mode */
59 uint32_t compr_buf_size
; /* used by size compr. mode */
60 uint32_t stat_compr_orig_size
;
61 uint32_t stat_compr_new_size
;
62 uint32_t stat_compr_blocks
;
63 uint32_t stat_decompr_blocks
;
66 int jffs2_register_compressor(struct jffs2_compressor
*comp
);
67 int jffs2_unregister_compressor(struct jffs2_compressor
*comp
);
69 int jffs2_compressors_init(void);
70 int jffs2_compressors_exit(void);
72 uint16_t jffs2_compress(struct jffs2_sb_info
*c
, struct jffs2_inode_info
*f
,
73 unsigned char *data_in
, unsigned char **cpage_out
,
74 uint32_t *datalen
, uint32_t *cdatalen
);
76 int jffs2_decompress(struct jffs2_sb_info
*c
, struct jffs2_inode_info
*f
,
77 uint16_t comprtype
, unsigned char *cdata_in
,
78 unsigned char *data_out
, uint32_t cdatalen
, uint32_t datalen
);
80 void jffs2_free_comprbuf(unsigned char *comprbuf
, unsigned char *orig
);
82 #ifdef CONFIG_JFFS2_PROC
83 int jffs2_enable_compressor_name(const char *name
);
84 int jffs2_disable_compressor_name(const char *name
);
85 int jffs2_set_compression_mode_name(const char *mode_name
);
86 char *jffs2_get_compression_mode_name(void);
87 int jffs2_set_compressor_priority(const char *mode_name
, int priority
);
88 char *jffs2_list_compressors(void);
89 char *jffs2_stats(void);
92 /* Compressor modules */
93 /* These functions will be called by jffs2_compressors_init/exit */
95 #ifdef CONFIG_JFFS2_RUBIN
96 int jffs2_rubinmips_init(void);
97 void jffs2_rubinmips_exit(void);
98 int jffs2_dynrubin_init(void);
99 void jffs2_dynrubin_exit(void);
101 #ifdef CONFIG_JFFS2_RTIME
102 int jffs2_rtime_init(void);
103 void jffs2_rtime_exit(void);
105 #ifdef CONFIG_JFFS2_ZLIB
106 int jffs2_zlib_init(void);
107 void jffs2_zlib_exit(void);
109 #ifdef CONFIG_JFFS2_LZARI
110 int jffs2_lzari_init(void);
111 void jffs2_lzari_exit(void);
113 #ifdef CONFIG_JFFS2_LZO
114 int jffs2_lzo_init(void);
115 void jffs2_lzo_exit(void);
118 #endif /* __JFFS2_COMPR_H__ */