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