Blame view

fs/jffs2/compr.h 3.07 KB
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1
2
3
  /*
   * JFFS2 -- Journalling Flash File System, Version 2.
   *
c00c310ea   David Woodhouse   [JFFS2] Tidy up l...
4
   * Copyright © 2004   Ferenc Havasi <havasi@inf.u-szeged.hu>,
ef53cb02f   David Woodhouse   [JFFS2] Whitespac...
5
   *		      University of Szeged, Hungary
6088c0587   David Woodhouse   jffs2: Update cop...
6
   * Copyright © 2004-2010 David Woodhouse <dwmw2@infradead.org>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
7
   *
c00c310ea   David Woodhouse   [JFFS2] Tidy up l...
8
   * For licensing information, see the file 'LICENCE' in this directory.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
   *
   */
  
  #ifndef __JFFS2_COMPR_H__
  #define __JFFS2_COMPR_H__
  
  #include <linux/kernel.h>
  #include <linux/vmalloc.h>
  #include <linux/list.h>
  #include <linux/types.h>
  #include <linux/string.h>
  #include <linux/slab.h>
  #include <linux/errno.h>
  #include <linux/fs.h>
  #include <linux/jffs2.h>
cbb9a5617   David Woodhouse   Move jffs2_fs_i.h...
24
25
  #include "jffs2_fs_i.h"
  #include "jffs2_fs_sb.h"
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
26
27
28
29
30
  #include "nodelist.h"
  
  #define JFFS2_RUBINMIPS_PRIORITY 10
  #define JFFS2_DYNRUBIN_PRIORITY  20
  #define JFFS2_LZARI_PRIORITY     30
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
31
32
  #define JFFS2_RTIME_PRIORITY     50
  #define JFFS2_ZLIB_PRIORITY      60
c799aca31   Richard Purdie   [JFFS2] Add LZO c...
33
  #define JFFS2_LZO_PRIORITY       80
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
34
35
  
  #define JFFS2_RUBINMIPS_DISABLED /* RUBINs will be used only */
ef53cb02f   David Woodhouse   [JFFS2] Whitespac...
36
  #define JFFS2_DYNRUBIN_DISABLED  /*	   for decompression */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
37
38
39
40
  
  #define JFFS2_COMPR_MODE_NONE       0
  #define JFFS2_COMPR_MODE_PRIORITY   1
  #define JFFS2_COMPR_MODE_SIZE       2
3b23c1f5f   Richard Purdie   [JFFS2] Add a "fa...
41
  #define JFFS2_COMPR_MODE_FAVOURLZO  3
123005f3c   Andres Salomon   jffs2: add compr=...
42
43
  #define JFFS2_COMPR_MODE_FORCELZO   4
  #define JFFS2_COMPR_MODE_FORCEZLIB  5
3b23c1f5f   Richard Purdie   [JFFS2] Add a "fa...
44
45
  
  #define FAVOUR_LZO_PERCENT 80
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
46
47
  
  struct jffs2_compressor {
ef53cb02f   David Woodhouse   [JFFS2] Whitespac...
48
49
50
51
52
  	struct list_head list;
  	int priority;			/* used by prirority comr. mode */
  	char *name;
  	char compr;			/* JFFS2_COMPR_XXX */
  	int (*compress)(unsigned char *data_in, unsigned char *cpage_out,
088bd455c   Mike Frysinger   jffs2: drop unuse...
53
  			uint32_t *srclen, uint32_t *destlen);
ef53cb02f   David Woodhouse   [JFFS2] Whitespac...
54
  	int (*decompress)(unsigned char *cdata_in, unsigned char *data_out,
088bd455c   Mike Frysinger   jffs2: drop unuse...
55
  			  uint32_t cdatalen, uint32_t datalen);
ef53cb02f   David Woodhouse   [JFFS2] Whitespac...
56
57
58
59
60
61
62
63
  	int usecount;
  	int disabled;		/* if set the compressor won't compress */
  	unsigned char *compr_buf;	/* used by size compr. mode */
  	uint32_t compr_buf_size;	/* used by size compr. mode */
  	uint32_t stat_compr_orig_size;
  	uint32_t stat_compr_new_size;
  	uint32_t stat_compr_blocks;
  	uint32_t stat_decompr_blocks;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
64
65
66
67
68
69
70
71
72
  };
  
  int jffs2_register_compressor(struct jffs2_compressor *comp);
  int jffs2_unregister_compressor(struct jffs2_compressor *comp);
  
  int jffs2_compressors_init(void);
  int jffs2_compressors_exit(void);
  
  uint16_t jffs2_compress(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
ef53cb02f   David Woodhouse   [JFFS2] Whitespac...
73
74
  			unsigned char *data_in, unsigned char **cpage_out,
  			uint32_t *datalen, uint32_t *cdatalen);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
75
76
  
  int jffs2_decompress(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
ef53cb02f   David Woodhouse   [JFFS2] Whitespac...
77
78
  		     uint16_t comprtype, unsigned char *cdata_in,
  		     unsigned char *data_out, uint32_t cdatalen, uint32_t datalen);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
79
80
  
  void jffs2_free_comprbuf(unsigned char *comprbuf, unsigned char *orig);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
  /* Compressor modules */
  /* These functions will be called by jffs2_compressors_init/exit */
  
  #ifdef CONFIG_JFFS2_RUBIN
  int jffs2_rubinmips_init(void);
  void jffs2_rubinmips_exit(void);
  int jffs2_dynrubin_init(void);
  void jffs2_dynrubin_exit(void);
  #endif
  #ifdef CONFIG_JFFS2_RTIME
  int jffs2_rtime_init(void);
  void jffs2_rtime_exit(void);
  #endif
  #ifdef CONFIG_JFFS2_ZLIB
  int jffs2_zlib_init(void);
  void jffs2_zlib_exit(void);
  #endif
0fc72b81d   David Woodhouse   [JFFS2] Add decla...
98
99
100
101
  #ifdef CONFIG_JFFS2_LZO
  int jffs2_lzo_init(void);
  void jffs2_lzo_exit(void);
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
102
103
  
  #endif /* __JFFS2_COMPR_H__ */