Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * JFFS2 -- Journalling Flash File System, Version 2.
0003  *
0004  * Copyright © 2004   Ferenc Havasi <havasi@inf.u-szeged.hu>,
0005  *            University of Szeged, Hungary
0006  * Copyright © 2004-2010 David Woodhouse <dwmw2@infradead.org>
0007  *
0008  * For licensing information, see the file 'LICENCE' in this directory.
0009  *
0010  */
0011 
0012 #ifndef __JFFS2_COMPR_H__
0013 #define __JFFS2_COMPR_H__
0014 
0015 #include <linux/kernel.h>
0016 #include <linux/vmalloc.h>
0017 #include <linux/list.h>
0018 #include <linux/types.h>
0019 #include <linux/string.h>
0020 #include <linux/slab.h>
0021 #include <linux/errno.h>
0022 #include <linux/fs.h>
0023 #include <linux/jffs2.h>
0024 #include "jffs2_fs_i.h"
0025 #include "jffs2_fs_sb.h"
0026 #include "nodelist.h"
0027 
0028 #define JFFS2_RUBINMIPS_PRIORITY 10
0029 #define JFFS2_DYNRUBIN_PRIORITY  20
0030 #define JFFS2_LZARI_PRIORITY     30
0031 #define JFFS2_RTIME_PRIORITY     50
0032 #define JFFS2_ZLIB_PRIORITY      60
0033 #define JFFS2_LZO_PRIORITY       80
0034 
0035 
0036 #define JFFS2_RUBINMIPS_DISABLED /* RUBINs will be used only */
0037 #define JFFS2_DYNRUBIN_DISABLED  /*    for decompression */
0038 
0039 #define JFFS2_COMPR_MODE_NONE       0
0040 #define JFFS2_COMPR_MODE_PRIORITY   1
0041 #define JFFS2_COMPR_MODE_SIZE       2
0042 #define JFFS2_COMPR_MODE_FAVOURLZO  3
0043 #define JFFS2_COMPR_MODE_FORCELZO   4
0044 #define JFFS2_COMPR_MODE_FORCEZLIB  5
0045 
0046 #define FAVOUR_LZO_PERCENT 80
0047 
0048 struct jffs2_compressor {
0049     struct list_head list;
0050     int priority;           /* used by prirority comr. mode */
0051     char *name;
0052     char compr;         /* JFFS2_COMPR_XXX */
0053     int (*compress)(unsigned char *data_in, unsigned char *cpage_out,
0054             uint32_t *srclen, uint32_t *destlen);
0055     int (*decompress)(unsigned char *cdata_in, unsigned char *data_out,
0056               uint32_t cdatalen, uint32_t datalen);
0057     int usecount;
0058     int disabled;       /* if set the compressor won't compress */
0059     unsigned char *compr_buf;   /* used by size compr. mode */
0060     uint32_t compr_buf_size;    /* used by size compr. mode */
0061     uint32_t stat_compr_orig_size;
0062     uint32_t stat_compr_new_size;
0063     uint32_t stat_compr_blocks;
0064     uint32_t stat_decompr_blocks;
0065 };
0066 
0067 int jffs2_register_compressor(struct jffs2_compressor *comp);
0068 int jffs2_unregister_compressor(struct jffs2_compressor *comp);
0069 
0070 int jffs2_compressors_init(void);
0071 int jffs2_compressors_exit(void);
0072 
0073 uint16_t jffs2_compress(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
0074             unsigned char *data_in, unsigned char **cpage_out,
0075             uint32_t *datalen, uint32_t *cdatalen);
0076 
0077 int jffs2_decompress(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
0078              uint16_t comprtype, unsigned char *cdata_in,
0079              unsigned char *data_out, uint32_t cdatalen, uint32_t datalen);
0080 
0081 void jffs2_free_comprbuf(unsigned char *comprbuf, unsigned char *orig);
0082 
0083 /* Compressor modules */
0084 /* These functions will be called by jffs2_compressors_init/exit */
0085 
0086 #ifdef CONFIG_JFFS2_RUBIN
0087 int jffs2_rubinmips_init(void);
0088 void jffs2_rubinmips_exit(void);
0089 int jffs2_dynrubin_init(void);
0090 void jffs2_dynrubin_exit(void);
0091 #endif
0092 #ifdef CONFIG_JFFS2_RTIME
0093 int jffs2_rtime_init(void);
0094 void jffs2_rtime_exit(void);
0095 #endif
0096 #ifdef CONFIG_JFFS2_ZLIB
0097 int jffs2_zlib_init(void);
0098 void jffs2_zlib_exit(void);
0099 #endif
0100 #ifdef CONFIG_JFFS2_LZO
0101 int jffs2_lzo_init(void);
0102 void jffs2_lzo_exit(void);
0103 #endif
0104 
0105 #endif /* __JFFS2_COMPR_H__ */