xref: /aosp_15_r20/external/erofs-utils/include/erofs/config.h (revision 33b1fccf6a0fada2c2875d400ed01119b7676ee5)
1 /* SPDX-License-Identifier: GPL-2.0+ OR Apache-2.0 */
2 /*
3  * Copyright (C) 2018-2019 HUAWEI, Inc.
4  *             http://www.huawei.com/
5  * Created by Li Guifu <[email protected]>
6  */
7 #ifndef __EROFS_CONFIG_H
8 #define __EROFS_CONFIG_H
9 
10 #ifdef __cplusplus
11 extern "C"
12 {
13 #endif
14 
15 #include "defs.h"
16 #include "err.h"
17 
18 
19 enum {
20 	FORCE_INODE_COMPACT = 1,
21 	FORCE_INODE_EXTENDED,
22 };
23 
24 enum {
25 	FORCE_INODE_BLOCK_MAP = 1,
26 	FORCE_INODE_CHUNK_INDEXES,
27 };
28 
29 enum {
30 	TIMESTAMP_UNSPECIFIED,
31 	TIMESTAMP_NONE,
32 	TIMESTAMP_FIXED,
33 	TIMESTAMP_CLAMPING,
34 };
35 
36 #define EROFS_MAX_COMPR_CFGS		64
37 
38 struct erofs_compr_opts {
39 	char *alg;
40 	int level;
41 	u32 dict_size;
42 };
43 
44 struct erofs_configure {
45 	const char *c_version;
46 	int c_dbg_lvl;
47 	bool c_dry_run;
48 	bool c_legacy_compress;
49 #ifndef NDEBUG
50 	bool c_random_pclusterblks;
51 	bool c_random_algorithms;
52 #endif
53 	char c_timeinherit;
54 	char c_chunkbits;
55 	bool c_inline_data;
56 	bool c_ztailpacking;
57 	bool c_fragments;
58 	bool c_all_fragments;
59 	bool c_dedupe;
60 	bool c_ignore_mtime;
61 	bool c_showprogress;
62 	bool c_extra_ea_name_prefixes;
63 	bool c_xattr_name_filter;
64 	bool c_ovlfs_strip;
65 
66 #ifdef HAVE_LIBSELINUX
67 	struct selabel_handle *sehnd;
68 #endif
69 	/* related arguments for mkfs.erofs */
70 	char *c_img_path;
71 	char *c_src_path;
72 	char *c_blobdev_path;
73 	char *c_compress_hints_file;
74 	struct erofs_compr_opts c_compr_opts[EROFS_MAX_COMPR_CFGS];
75 	char c_force_inodeversion;
76 	char c_force_chunkformat;
77 	/* < 0, xattr disabled and INT_MAX, always use inline xattrs */
78 	int c_inline_xattr_tolerance;
79 #ifdef EROFS_MT_ENABLED
80 	u64 c_mkfs_segment_size;
81 	u32 c_mt_workers;
82 #endif
83 	u32 c_mkfs_pclustersize_max;
84 	u32 c_mkfs_pclustersize_def;
85 	u32 c_mkfs_pclustersize_packed;
86 	u32 c_max_decompressed_extent_bytes;
87 	u64 c_unix_timestamp;
88 	u32 c_uid, c_gid;
89 	const char *mount_point;
90 	long long c_uid_offset, c_gid_offset;
91 	u32 c_root_xattr_isize;
92 #ifdef WITH_ANDROID
93 	char *target_out_path;
94 	char *fs_config_file;
95 	char *block_list_file;
96 #endif
97 };
98 
99 extern struct erofs_configure cfg;
100 
101 void erofs_init_configure(void);
102 void erofs_show_config(void);
103 void erofs_exit_configure(void);
104 
105 /* (will be deprecated) temporary helper for updating global the cfg */
106 struct erofs_configure *erofs_get_configure();
107 
108 void erofs_set_fs_root(const char *rootdir);
109 const char *erofs_fspath(const char *fullpath);
110 
111 #ifdef HAVE_LIBSELINUX
112 int erofs_selabel_open(const char *file_contexts);
113 #else
erofs_selabel_open(const char * file_contexts)114 static inline int erofs_selabel_open(const char *file_contexts)
115 {
116 	return -EINVAL;
117 }
118 #endif
119 
120 void erofs_update_progressinfo(const char *fmt, ...);
121 char *erofs_trim_for_progressinfo(const char *str, int placeholder);
122 unsigned int erofs_get_available_processors(void);
123 
124 #ifdef __cplusplus
125 }
126 #endif
127 
128 #endif
129