• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <bluce.liguifu@huawei.com>
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 	char c_timeinherit;
50 	char c_chunkbits;
51 	bool c_inline_data;
52 	bool c_ztailpacking;
53 	bool c_fragments;
54 	bool c_all_fragments;
55 	bool c_dedupe;
56 	bool c_ignore_mtime;
57 	bool c_showprogress;
58 	bool c_extra_ea_name_prefixes;
59 	bool c_xattr_name_filter;
60 	bool c_ovlfs_strip;
61 	bool c_hard_dereference;
62 
63 #ifdef HAVE_LIBSELINUX
64 	struct selabel_handle *sehnd;
65 #endif
66 	/* related arguments for mkfs.erofs */
67 	char *c_img_path;
68 	char *c_src_path;
69 	char *c_blobdev_path;
70 	char *c_compress_hints_file;
71 	struct erofs_compr_opts c_compr_opts[EROFS_MAX_COMPR_CFGS];
72 	char c_force_inodeversion;
73 	char c_force_chunkformat;
74 	/* < 0, xattr disabled and INT_MAX, always use inline xattrs */
75 	int c_inline_xattr_tolerance;
76 #ifdef EROFS_MT_ENABLED
77 	u64 c_mkfs_segment_size;
78 	u32 c_mt_workers;
79 #endif
80 	u32 c_mkfs_pclustersize_max;
81 	u32 c_mkfs_pclustersize_def;
82 	u32 c_mkfs_pclustersize_packed;
83 	u32 c_max_decompressed_extent_bytes;
84 	u64 c_unix_timestamp;
85 	u32 c_uid, c_gid;
86 	const char *mount_point;
87 	long long c_uid_offset, c_gid_offset;
88 	u32 c_root_xattr_isize;
89 #ifdef WITH_ANDROID
90 	char *target_out_path;
91 	char *fs_config_file;
92 	char *block_list_file;
93 #endif
94 #ifndef NDEBUG
95 	bool c_random_pclusterblks;
96 	bool c_random_algorithms;
97 #endif
98 };
99 
100 extern struct erofs_configure cfg;
101 
102 void erofs_init_configure(void);
103 void erofs_show_config(void);
104 void erofs_exit_configure(void);
105 
106 /* (will be deprecated) temporary helper for updating global the cfg */
107 struct erofs_configure *erofs_get_configure();
108 
109 void erofs_set_fs_root(const char *rootdir);
110 const char *erofs_fspath(const char *fullpath);
111 
112 #ifdef HAVE_LIBSELINUX
113 int erofs_selabel_open(const char *file_contexts);
114 #else
erofs_selabel_open(const char * file_contexts)115 static inline int erofs_selabel_open(const char *file_contexts)
116 {
117 	return -EINVAL;
118 }
119 #endif
120 
121 void erofs_update_progressinfo(const char *fmt, ...);
122 char *erofs_trim_for_progressinfo(const char *str, int placeholder);
123 unsigned int erofs_get_available_processors(void);
124 
125 #ifdef __cplusplus
126 }
127 #endif
128 
129 #endif
130