compr.h 3.5 KB

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