/* * JFFS2 -- Journalling Flash File System, Version 2. * * Copyright © 2001-2007 Red Hat, Inc. * Copyright © 2004-2010 David Woodhouse <[email protected]> * Copyright © 2004 Ferenc Havasi <[email protected]>, * University of Szeged, Hungary * * Created by Arjan van de Ven <[email protected]> * * For licensing information, see the file 'LICENCE' in this directory. * */ #define pr_fmt(fmt) … #include "compr.h" static DEFINE_SPINLOCK(jffs2_compressor_list_lock); /* Available compressors are on this list */ static LIST_HEAD(jffs2_compressor_list); /* Actual compression mode */ static int jffs2_compression_mode = …; /* Statistics for blocks stored without compression */ static uint32_t none_stat_compr_blocks= …,none_stat_decompr_blocks= …,none_stat_compr_size= …; /* * Return 1 to use this compression */ static int jffs2_is_best_compression(struct jffs2_compressor *this, struct jffs2_compressor *best, uint32_t size, uint32_t bestsize) { … } /* * jffs2_selected_compress: * @compr: Explicit compression type to use (ie, JFFS2_COMPR_ZLIB). * If 0, just take the first available compression mode. * @data_in: Pointer to uncompressed data * @cpage_out: Pointer to returned pointer to buffer for compressed data * @datalen: On entry, holds the amount of data available for compression. * On exit, expected to hold the amount of data actually compressed. * @cdatalen: On entry, holds the amount of space available for compressed * data. On exit, expected to hold the actual size of the compressed * data. * * Returns: the compression type used. Zero is used to show that the data * could not be compressed; probably because we couldn't find the requested * compression mode. */ static int jffs2_selected_compress(u8 compr, unsigned char *data_in, unsigned char **cpage_out, u32 *datalen, u32 *cdatalen) { … } /* jffs2_compress: * @data_in: Pointer to uncompressed data * @cpage_out: Pointer to returned pointer to buffer for compressed data * @datalen: On entry, holds the amount of data available for compression. * On exit, expected to hold the amount of data actually compressed. * @cdatalen: On entry, holds the amount of space available for compressed * data. On exit, expected to hold the actual size of the compressed * data. * * Returns: Lower byte to be stored with data indicating compression type used. * Zero is used to show that the data could not be compressed - the * compressed version was actually larger than the original. * Upper byte will be used later. (soon) * * If the cdata buffer isn't large enough to hold all the uncompressed data, * jffs2_compress should compress as much as will fit, and should set * *datalen accordingly to show the amount of data which were compressed. */ uint16_t jffs2_compress(struct jffs2_sb_info *c, struct jffs2_inode_info *f, unsigned char *data_in, unsigned char **cpage_out, uint32_t *datalen, uint32_t *cdatalen) { … } int jffs2_decompress(struct jffs2_sb_info *c, struct jffs2_inode_info *f, uint16_t comprtype, unsigned char *cdata_in, unsigned char *data_out, uint32_t cdatalen, uint32_t datalen) { … } int jffs2_register_compressor(struct jffs2_compressor *comp) { … } int jffs2_unregister_compressor(struct jffs2_compressor *comp) { … } void jffs2_free_comprbuf(unsigned char *comprbuf, unsigned char *orig) { … } int __init jffs2_compressors_init(void) { … } int jffs2_compressors_exit(void) { … }