xref: /aosp_15_r20/external/erofs-utils/include/erofs/compress.h (revision 33b1fccf6a0fada2c2875d400ed01119b7676ee5)
1 /* SPDX-License-Identifier: GPL-2.0+ OR Apache-2.0 */
2 /*
3  * Copyright (C) 2019 HUAWEI, Inc.
4  *             http://www.huawei.com/
5  * Created by Gao Xiang <[email protected]>
6  */
7 #ifndef __EROFS_COMPRESS_H
8 #define __EROFS_COMPRESS_H
9 
10 #ifdef __cplusplus
11 extern "C"
12 {
13 #endif
14 
15 #include "internal.h"
16 
17 #define EROFS_CONFIG_COMPR_MAX_SZ	(4000 * 1024)
18 #define Z_EROFS_COMPR_QUEUE_SZ		(EROFS_CONFIG_COMPR_MAX_SZ * 2)
19 
20 struct z_erofs_compress_ictx;
21 
22 void z_erofs_drop_inline_pcluster(struct erofs_inode *inode);
23 void *erofs_begin_compressed_file(struct erofs_inode *inode, int fd, u64 fpos);
24 int erofs_write_compressed_file(struct z_erofs_compress_ictx *ictx);
25 
26 int z_erofs_compress_init(struct erofs_sb_info *sbi,
27 			  struct erofs_buffer_head *bh);
28 int z_erofs_compress_exit(void);
29 
30 const char *z_erofs_list_supported_algorithms(int i, unsigned int *mask);
31 const struct erofs_algorithm *z_erofs_list_available_compressors(int *i);
32 
erofs_is_packed_inode(struct erofs_inode * inode)33 static inline bool erofs_is_packed_inode(struct erofs_inode *inode)
34 {
35 	erofs_nid_t packed_nid = inode->sbi->packed_nid;
36 
37 	if (inode->nid == EROFS_PACKED_NID_UNALLOCATED) {
38 		DBG_BUGON(packed_nid != EROFS_PACKED_NID_UNALLOCATED);
39 		return true;
40 	}
41 	return (packed_nid > 0 && inode->nid == packed_nid);
42 }
43 
44 #ifdef __cplusplus
45 }
46 #endif
47 
48 #endif
49