a54828a4e9c6cafff75f455c6f843fd1a1e0e609
[safe/jmp/linux-2.6] / fs / jffs2 / compr.h
1 /*
2  * JFFS2 -- Journalling Flash File System, Version 2.
3  *
4  * Copyright © 2004   Ferenc Havasi <havasi@inf.u-szeged.hu>,
5  *                    University of Szeged, Hungary
6  *
7  * For licensing information, see the file 'LICENCE' in this directory.
8  *
9  */
10
11 #ifndef __JFFS2_COMPR_H__
12 #define __JFFS2_COMPR_H__
13
14 #include <linux/kernel.h>
15 #include <linux/vmalloc.h>
16 #include <linux/list.h>
17 #include <linux/types.h>
18 #include <linux/string.h>
19 #include <linux/slab.h>
20 #include <linux/errno.h>
21 #include <linux/fs.h>
22 #include <linux/jffs2.h>
23 #include "jffs2_fs_i.h"
24 #include "jffs2_fs_sb.h"
25 #include "nodelist.h"
26
27 #define JFFS2_RUBINMIPS_PRIORITY 10
28 #define JFFS2_DYNRUBIN_PRIORITY  20
29 #define JFFS2_LZARI_PRIORITY     30
30 #define JFFS2_RTIME_PRIORITY     50
31 #define JFFS2_ZLIB_PRIORITY      60
32 #define JFFS2_LZO_PRIORITY       80
33
34
35 #define JFFS2_RUBINMIPS_DISABLED /* RUBINs will be used only */
36 #define JFFS2_DYNRUBIN_DISABLED  /*        for decompression */
37
38 #define JFFS2_COMPR_MODE_NONE       0
39 #define JFFS2_COMPR_MODE_PRIORITY   1
40 #define JFFS2_COMPR_MODE_SIZE       2
41
42 struct jffs2_compressor {
43         struct list_head list;
44         int priority;                   /* used by prirority comr. mode */
45         char *name;
46         char compr;                     /* JFFS2_COMPR_XXX */
47         int (*compress)(unsigned char *data_in, unsigned char *cpage_out,
48                         uint32_t *srclen, uint32_t *destlen, void *model);
49         int (*decompress)(unsigned char *cdata_in, unsigned char *data_out,
50                           uint32_t cdatalen, uint32_t datalen, void *model);
51         int usecount;
52         int disabled;           /* if set the compressor won't compress */
53         unsigned char *compr_buf;       /* used by size compr. mode */
54         uint32_t compr_buf_size;        /* used by size compr. mode */
55         uint32_t stat_compr_orig_size;
56         uint32_t stat_compr_new_size;
57         uint32_t stat_compr_blocks;
58         uint32_t stat_decompr_blocks;
59 };
60
61 int jffs2_register_compressor(struct jffs2_compressor *comp);
62 int jffs2_unregister_compressor(struct jffs2_compressor *comp);
63
64 int jffs2_compressors_init(void);
65 int jffs2_compressors_exit(void);
66
67 uint16_t jffs2_compress(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
68                         unsigned char *data_in, unsigned char **cpage_out,
69                         uint32_t *datalen, uint32_t *cdatalen);
70
71 int jffs2_decompress(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
72                      uint16_t comprtype, unsigned char *cdata_in,
73                      unsigned char *data_out, uint32_t cdatalen, uint32_t datalen);
74
75 void jffs2_free_comprbuf(unsigned char *comprbuf, unsigned char *orig);
76
77 /* Compressor modules */
78 /* These functions will be called by jffs2_compressors_init/exit */
79
80 #ifdef CONFIG_JFFS2_RUBIN
81 int jffs2_rubinmips_init(void);
82 void jffs2_rubinmips_exit(void);
83 int jffs2_dynrubin_init(void);
84 void jffs2_dynrubin_exit(void);
85 #endif
86 #ifdef CONFIG_JFFS2_RTIME
87 int jffs2_rtime_init(void);
88 void jffs2_rtime_exit(void);
89 #endif
90 #ifdef CONFIG_JFFS2_ZLIB
91 int jffs2_zlib_init(void);
92 void jffs2_zlib_exit(void);
93 #endif
94
95 #endif /* __JFFS2_COMPR_H__ */