xref: /linux/fs/ntfs/ntfs_codec.h (revision 67f8bc848ee31831336bd478e57d2f993551902e)
1f2240a2fSHyunchul Lee /* SPDX-License-Identifier: GPL-2.0-or-later */
2f2240a2fSHyunchul Lee /*
3f2240a2fSHyunchul Lee  * Transparent compression codec interface.
4f2240a2fSHyunchul Lee  *
5f2240a2fSHyunchul Lee  * Copyright (c) 2026 LG Electronics Co., Ltd.
6f2240a2fSHyunchul Lee  */
7f2240a2fSHyunchul Lee 
8f2240a2fSHyunchul Lee #ifndef _NTFS_CODEC_H
9f2240a2fSHyunchul Lee #define _NTFS_CODEC_H
10f2240a2fSHyunchul Lee 
11f2240a2fSHyunchul Lee #include <linux/types.h>
12f2240a2fSHyunchul Lee #include <linux/fs.h>
13f2240a2fSHyunchul Lee #include <linux/mm.h>
14f2240a2fSHyunchul Lee 
15f2240a2fSHyunchul Lee struct compress_context;
16f2240a2fSHyunchul Lee 
17f2240a2fSHyunchul Lee enum ntfs_codec_id {
18f2240a2fSHyunchul Lee 	NTFS_CODEC_LZNT1,
19f2240a2fSHyunchul Lee #ifdef CONFIG_NTFS_FS_WOF_COMPRESSION
20f2240a2fSHyunchul Lee 	NTFS_CODEC_XPRESS4K,
21f2240a2fSHyunchul Lee 	NTFS_CODEC_XPRESS8K,
22f2240a2fSHyunchul Lee 	NTFS_CODEC_XPRESS16K,
23f2240a2fSHyunchul Lee 	NTFS_CODEC_LZX32K,
24f2240a2fSHyunchul Lee #endif
25f2240a2fSHyunchul Lee };
26f2240a2fSHyunchul Lee 
27f2240a2fSHyunchul Lee struct ntfs_codec_ops {
28f2240a2fSHyunchul Lee 	enum ntfs_codec_id id;
29f2240a2fSHyunchul Lee 	const char *name;
30f2240a2fSHyunchul Lee 	size_t (*scratch_size)(u32 chunk_size);
31f2240a2fSHyunchul Lee 	int (*decompress_chunk)(void *scratch,
32f2240a2fSHyunchul Lee 				const void *src, size_t src_len,
33f2240a2fSHyunchul Lee 				void *dst, size_t dst_len,
34f2240a2fSHyunchul Lee 				u32 chunk_size);
35f2240a2fSHyunchul Lee 	int (*decompress_pages)(struct page *dest_pages[],
36f2240a2fSHyunchul Lee 				int completed_pages[],
37f2240a2fSHyunchul Lee 				int *dest_index, int *dest_ofs,
38f2240a2fSHyunchul Lee 				int dest_max_index, int dest_max_ofs,
39f2240a2fSHyunchul Lee 				int xpage, char *xpage_done,
40f2240a2fSHyunchul Lee 				u8 *cb_start, u32 cb_size,
41f2240a2fSHyunchul Lee 				loff_t i_size, s64 initialized_size);
42f2240a2fSHyunchul Lee 	int (*compress_subblock)(struct compress_context *pctx,
43f2240a2fSHyunchul Lee 				 const char *inbuf, int bufsize, char *outbuf);
44f2240a2fSHyunchul Lee };
45f2240a2fSHyunchul Lee 
46c34e33a6SHyunchul Lee extern const struct ntfs_codec_ops ntfs_lznt1_codec_ops;
47*7ddb3fefSHyunchul Lee #ifdef CONFIG_NTFS_FS_WOF_COMPRESSION
48*7ddb3fefSHyunchul Lee extern const struct ntfs_codec_ops ntfs_xpress4k_codec_ops;
49*7ddb3fefSHyunchul Lee extern const struct ntfs_codec_ops ntfs_xpress8k_codec_ops;
50*7ddb3fefSHyunchul Lee extern const struct ntfs_codec_ops ntfs_xpress16k_codec_ops;
51*7ddb3fefSHyunchul Lee extern const struct ntfs_codec_ops ntfs_lzx32k_codec_ops;
52*7ddb3fefSHyunchul Lee #endif
53c34e33a6SHyunchul Lee 
54f2240a2fSHyunchul Lee #endif /* _NTFS_CODEC_H */
55