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