1 /* SPDX-License-Identifier: GPL-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_NONE,
31 TIMESTAMP_FIXED,
32 TIMESTAMP_CLAMPING,
33 };
34
35 struct erofs_configure {
36 const char *c_version;
37 int c_dbg_lvl;
38 bool c_dry_run;
39 bool c_legacy_compress;
40 #ifndef NDEBUG
41 bool c_random_pclusterblks;
42 #endif
43 char c_timeinherit;
44 char c_chunkbits;
45 bool c_noinline_data;
46 bool c_ignore_mtime;
47
48 #ifdef HAVE_LIBSELINUX
49 struct selabel_handle *sehnd;
50 #endif
51 /* related arguments for mkfs.erofs */
52 char *c_img_path;
53 char *c_src_path;
54 char *c_blobdev_path;
55 char *c_compress_hints_file;
56 char *c_compr_alg_master;
57 int c_compr_level_master;
58 char c_force_inodeversion;
59 char c_force_chunkformat;
60 /* < 0, xattr disabled and INT_MAX, always use inline xattrs */
61 int c_inline_xattr_tolerance;
62
63 u32 c_pclusterblks_max, c_pclusterblks_def;
64 u32 c_max_decompressed_extent_bytes;
65 u32 c_dict_size;
66 u64 c_unix_timestamp;
67 u32 c_uid, c_gid;
68 #ifdef WITH_ANDROID
69 char *mount_point;
70 char *target_out_path;
71 char *fs_config_file;
72 char *block_list_file;
73 #endif
74 };
75
76 extern struct erofs_configure cfg;
77
78 void erofs_init_configure(void);
79 void erofs_show_config(void);
80 void erofs_exit_configure(void);
81
82 void erofs_set_fs_root(const char *rootdir);
83 const char *erofs_fspath(const char *fullpath);
84
85 #ifdef HAVE_LIBSELINUX
86 int erofs_selabel_open(const char *file_contexts);
87 #else
erofs_selabel_open(const char * file_contexts)88 static inline int erofs_selabel_open(const char *file_contexts)
89 {
90 return -EINVAL;
91 }
92 #endif
93
94 #ifdef __cplusplus
95 }
96 #endif
97
98 #endif
99