• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * Copyright (C) 2018-2019 HUAWEI, Inc.
4  *             http://www.huawei.com/
5  * Created by Gao Xiang <gaoxiang25@huawei.com>
6  */
7 #ifndef __EROFS_LIB_COMPRESSOR_H
8 #define __EROFS_LIB_COMPRESSOR_H
9 
10 #include "erofs/defs.h"
11 
12 struct erofs_compress;
13 
14 struct erofs_compressor {
15 	const char *name;
16 
17 	int default_level;
18 	int best_level;
19 
20 	int (*init)(struct erofs_compress *c);
21 	int (*exit)(struct erofs_compress *c);
22 	int (*setlevel)(struct erofs_compress *c, int compression_level);
23 
24 	int (*compress_destsize)(struct erofs_compress *c,
25 				 void *src, unsigned int *srcsize,
26 				 void *dst, unsigned int dstsize);
27 };
28 
29 struct erofs_compress {
30 	struct erofs_compressor *alg;
31 
32 	unsigned int compress_threshold;
33 	unsigned int compression_level;
34 
35 	/* *_destsize specific */
36 	unsigned int destsize_alignsize;
37 	unsigned int destsize_redzone_begin;
38 	unsigned int destsize_redzone_end;
39 
40 	void *private_data;
41 };
42 
43 /* list of compression algorithms */
44 extern struct erofs_compressor erofs_compressor_lz4;
45 extern struct erofs_compressor erofs_compressor_lz4hc;
46 extern struct erofs_compressor erofs_compressor_lzma;
47 
48 int erofs_compress_destsize(struct erofs_compress *c,
49 			    void *src, unsigned int *srcsize,
50 			    void *dst, unsigned int dstsize);
51 
52 int erofs_compressor_setlevel(struct erofs_compress *c, int compression_level);
53 int erofs_compressor_init(struct erofs_compress *c, char *alg_name);
54 int erofs_compressor_exit(struct erofs_compress *c);
55 
56 #endif
57