<div dir="ltr">This patch works for me, thanks!</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Dec 1, 2021 at 5:53 AM Gao Xiang <<a href="mailto:xiang@kernel.org">xiang@kernel.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">From: Kelvin Zhang <<a href="mailto:zhangkelvin@google.com" target="_blank">zhangkelvin@google.com</a>><br>
<br>
1. Add extern "C" wrappers to headers, so that they can be included<br>
   from C++<br>
2. Add const keywords to certain pointer type params<br>
<br>
Signed-off-by: Kelvin Zhang <<a href="mailto:zhangkelvin@google.com" target="_blank">zhangkelvin@google.com</a>><br>
Signed-off-by: Gao Xiang <<a href="mailto:xiang@kernel.org" target="_blank">xiang@kernel.org</a>><br>
---<br>
v3: <a href="https://lore.kernel.org/r/20211130055604.2876828-2-zhangkelvin@google.com/" rel="noreferrer" target="_blank">https://lore.kernel.org/r/20211130055604.2876828-2-zhangkelvin@google.com/</a><br>
Hi Kelvin,<br>
<br>
Please help check if this patch meets your requirement.<br>
And I've applied to experimental branch.<br>
<br>
Thanks,<br>
Gao Xiang<br>
<br>
 include/erofs/blobchunk.h      |  9 +++++++++<br>
 include/erofs/block_list.h     | 10 ++++++++++<br>
 include/erofs/cache.h          |  9 +++++++++<br>
 include/erofs/compress.h       |  9 +++++++++<br>
 include/erofs/compress_hints.h | 10 ++++++++++<br>
 include/erofs/config.h         | 20 +++++++++-----------<br>
 include/erofs/decompress.h     |  9 +++++++++<br>
 include/erofs/defs.h           | 17 ++++++++++++++++-<br>
 include/erofs/err.h            |  9 +++++++++<br>
 include/erofs/exclude.h        | 10 ++++++++++<br>
 include/erofs/flex-array.h     |  9 +++++++++<br>
 include/erofs/hashmap.h        |  9 +++++++++<br>
 include/erofs/hashtable.h      |  9 +++++++++<br>
 include/erofs/inode.h          |  9 +++++++++<br>
 include/erofs/internal.h       |  9 +++++++++<br>
 include/erofs/io.h             | 11 +++++++++++<br>
 include/erofs/list.h           | 10 ++++++++++<br>
 include/erofs/print.h          |  9 +++++++++<br>
 include/erofs/trace.h          |  9 +++++++++<br>
 include/erofs/xattr.h          |  9 +++++++++<br>
 lib/Makefile.am                |  3 ++-<br>
 lib/config.c                   |  1 +<br>
 lib/inode.c                    |  1 +<br>
 lib/liberofs_private.h         | 13 +++++++++++++<br>
 lib/xattr.c                    |  1 +<br>
 25 files changed, 211 insertions(+), 13 deletions(-)<br>
 create mode 100644 lib/liberofs_private.h<br>
<br>
diff --git a/include/erofs/blobchunk.h b/include/erofs/blobchunk.h<br>
index 59a47013017f..4e1ae79938d6 100644<br>
--- a/include/erofs/blobchunk.h<br>
+++ b/include/erofs/blobchunk.h<br>
@@ -7,6 +7,11 @@<br>
 #ifndef __EROFS_BLOBCHUNK_H<br>
 #define __EROFS_BLOBCHUNK_H<br>
<br>
+#ifdef __cplusplus<br>
+extern "C"<br>
+{<br>
+#endif<br>
+<br>
 #include "erofs/internal.h"<br>
<br>
 int erofs_blob_write_chunk_indexes(struct erofs_inode *inode, erofs_off_t off);<br>
@@ -16,4 +21,8 @@ void erofs_blob_exit(void);<br>
 int erofs_blob_init(const char *blobfile_path);<br>
 int erofs_generate_devtable(void);<br>
<br>
+#ifdef __cplusplus<br>
+}<br>
+#endif<br>
+<br>
 #endif<br>
diff --git a/include/erofs/block_list.h b/include/erofs/block_list.h<br>
index 40df2282bf0c..ca8053ed28b7 100644<br>
--- a/include/erofs/block_list.h<br>
+++ b/include/erofs/block_list.h<br>
@@ -6,6 +6,11 @@<br>
 #ifndef __EROFS_BLOCK_LIST_H<br>
 #define __EROFS_BLOCK_LIST_H<br>
<br>
+#ifdef __cplusplus<br>
+extern "C"<br>
+{<br>
+#endif<br>
+<br>
 #include "internal.h"<br>
<br>
 #ifdef WITH_ANDROID<br>
@@ -29,4 +34,9 @@ erofs_droid_blocklist_write_extent(struct erofs_inode *inode,<br>
                                   erofs_blk_t blk_start, erofs_blk_t nblocks,<br>
                                   bool first_extent, bool last_extent) {}<br>
 #endif<br>
+<br>
+#ifdef __cplusplus<br>
+}<br>
+#endif<br>
+<br>
 #endif<br>
diff --git a/include/erofs/cache.h b/include/erofs/cache.h<br>
index 87cd51d9473b..7957ee5d0b73 100644<br>
--- a/include/erofs/cache.h<br>
+++ b/include/erofs/cache.h<br>
@@ -8,6 +8,11 @@<br>
 #ifndef __EROFS_CACHE_H<br>
 #define __EROFS_CACHE_H<br>
<br>
+#ifdef __cplusplus<br>
+extern "C"<br>
+{<br>
+#endif<br>
+<br>
 #include "internal.h"<br>
<br>
 struct erofs_buffer_head;<br>
@@ -104,4 +109,8 @@ bool erofs_bflush(struct erofs_buffer_block *bb);<br>
<br>
 void erofs_bdrop(struct erofs_buffer_head *bh, bool tryrevoke);<br>
<br>
+#ifdef __cplusplus<br>
+}<br>
+#endif<br>
+<br>
 #endif<br>
diff --git a/include/erofs/compress.h b/include/erofs/compress.h<br>
index 4434aaa75b54..fdbf5ff66558 100644<br>
--- a/include/erofs/compress.h<br>
+++ b/include/erofs/compress.h<br>
@@ -7,6 +7,11 @@<br>
 #ifndef __EROFS_COMPRESS_H<br>
 #define __EROFS_COMPRESS_H<br>
<br>
+#ifdef __cplusplus<br>
+extern "C"<br>
+{<br>
+#endif<br>
+<br>
 #include "internal.h"<br>
<br>
 /* workaround for an upstream lz4 compression issue, which can crash us */<br>
@@ -21,4 +26,8 @@ int z_erofs_compress_exit(void);<br>
<br>
 const char *z_erofs_list_available_compressors(unsigned int i);<br>
<br>
+#ifdef __cplusplus<br>
+}<br>
+#endif<br>
+<br>
 #endif<br>
diff --git a/include/erofs/compress_hints.h b/include/erofs/compress_hints.h<br>
index a5772c72b1c4..43f80e117816 100644<br>
--- a/include/erofs/compress_hints.h<br>
+++ b/include/erofs/compress_hints.h<br>
@@ -6,6 +6,11 @@<br>
 #ifndef __EROFS_COMPRESS_HINTS_H<br>
 #define __EROFS_COMPRESS_HINTS_H<br>
<br>
+#ifdef __cplusplus<br>
+extern "C"<br>
+{<br>
+#endif<br>
+<br>
 #include "erofs/internal.h"<br>
 #include <sys/types.h><br>
 #include <regex.h><br>
@@ -20,4 +25,9 @@ struct erofs_compress_hints {<br>
 bool z_erofs_apply_compress_hints(struct erofs_inode *inode);<br>
 void erofs_cleanup_compress_hints(void);<br>
 int erofs_load_compress_hints(void);<br>
+<br>
+#ifdef __cplusplus<br>
+}<br>
+#endif<br>
+<br>
 #endif<br>
diff --git a/include/erofs/config.h b/include/erofs/config.h<br>
index 2040dc6ff154..cb064b651835 100644<br>
--- a/include/erofs/config.h<br>
+++ b/include/erofs/config.h<br>
@@ -7,20 +7,14 @@<br>
 #ifndef __EROFS_CONFIG_H<br>
 #define __EROFS_CONFIG_H<br>
<br>
+#ifdef __cplusplus<br>
+extern "C"<br>
+{<br>
+#endif<br>
+<br>
 #include "defs.h"<br>
 #include "err.h"<br>
<br>
-#ifdef HAVE_LIBSELINUX<br>
-#include <selinux/selinux.h><br>
-#include <selinux/label.h><br>
-#endif<br>
-<br>
-#ifdef WITH_ANDROID<br>
-#include <selinux/android.h><br>
-#include <private/android_filesystem_config.h><br>
-#include <private/canned_fs_config.h><br>
-#include <private/fs_config.h><br>
-#endif<br>
<br>
 enum {<br>
        FORCE_INODE_COMPACT = 1,<br>
@@ -96,4 +90,8 @@ static inline int erofs_selabel_open(const char *file_contexts)<br>
 }<br>
 #endif<br>
<br>
+#ifdef __cplusplus<br>
+}<br>
+#endif<br>
+<br>
 #endif<br>
diff --git a/include/erofs/decompress.h b/include/erofs/decompress.h<br>
index 3d0d9633865d..e649c80cf3a7 100644<br>
--- a/include/erofs/decompress.h<br>
+++ b/include/erofs/decompress.h<br>
@@ -6,6 +6,11 @@<br>
 #ifndef __EROFS_DECOMPRESS_H<br>
 #define __EROFS_DECOMPRESS_H<br>
<br>
+#ifdef __cplusplus<br>
+extern "C"<br>
+{<br>
+#endif<br>
+<br>
 #include "internal.h"<br>
<br>
 struct z_erofs_decompress_req {<br>
@@ -25,4 +30,8 @@ struct z_erofs_decompress_req {<br>
<br>
 int z_erofs_decompress(struct z_erofs_decompress_req *rq);<br>
<br>
+#ifdef __cplusplus<br>
+}<br>
+#endif<br>
+<br>
 #endif<br>
diff --git a/include/erofs/defs.h b/include/erofs/defs.h<br>
index 6398cbb2aa4d..4db237f4dfb0 100644<br>
--- a/include/erofs/defs.h<br>
+++ b/include/erofs/defs.h<br>
@@ -8,6 +8,11 @@<br>
 #ifndef __EROFS_DEFS_H<br>
 #define __EROFS_DEFS_H<br>
<br>
+#ifdef __cplusplus<br>
+extern "C"<br>
+{<br>
+#endif<br>
+<br>
 #include <stddef.h><br>
 #include <stdint.h><br>
 #include <assert.h><br>
@@ -82,7 +87,9 @@ typedef int64_t         s64;<br>
 #endif<br>
 #endif<br>
<br>
-#ifndef __OPTIMIZE__<br>
+#ifdef __cplusplus<br>
+#define BUILD_BUG_ON(condition) static_assert(!(condition))<br>
+#elif !defined(__OPTIMIZE__)<br>
 #define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2 * !!(condition)]))<br>
 #else<br>
 #define BUILD_BUG_ON(condition) assert(!(condition))<br>
@@ -110,6 +117,8 @@ typedef int64_t         s64;<br>
 }                                                      \<br>
 )<br>
<br>
+/* Can easily conflict with C++'s std::min */<br>
+#ifndef __cplusplus<br>
 #define min(x, y) ({                           \<br>
        typeof(x) _min1 = (x);                  \<br>
        typeof(y) _min2 = (y);                  \<br>
@@ -121,6 +130,7 @@ typedef int64_t         s64;<br>
        typeof(y) _max2 = (y);                  \<br>
        (void) (&_max1 == &_max2);              \<br>
        _max1 > _max2 ? _max1 : _max2; })<br>
+#endif<br>
<br>
 /*<br>
  * ..and if you can't take the strict types, you can specify one yourself.<br>
@@ -308,4 +318,9 @@ unsigned long __roundup_pow_of_two(unsigned long n)<br>
 #define stat64         stat<br>
 #define lstat64                lstat<br>
 #endif<br>
+<br>
+#ifdef __cplusplus<br>
+}<br>
+#endif<br>
+<br>
 #endif<br>
diff --git a/include/erofs/err.h b/include/erofs/err.h<br>
index a33bdd137879..18f152aa4608 100644<br>
--- a/include/erofs/err.h<br>
+++ b/include/erofs/err.h<br>
@@ -7,6 +7,11 @@<br>
 #ifndef __EROFS_ERR_H<br>
 #define __EROFS_ERR_H<br>
<br>
+#ifdef __cplusplus<br>
+extern "C"<br>
+{<br>
+#endif<br>
+<br>
 #include <errno.h><br>
<br>
 #define MAX_ERRNO (4095)<br>
@@ -28,4 +33,8 @@ static inline long PTR_ERR(const void *ptr)<br>
        return (long) ptr;<br>
 }<br>
<br>
+#ifdef __cplusplus<br>
+}<br>
+#endif<br>
+<br>
 #endif<br>
diff --git a/include/erofs/exclude.h b/include/erofs/exclude.h<br>
index 6930f2b43a47..599f01895807 100644<br>
--- a/include/erofs/exclude.h<br>
+++ b/include/erofs/exclude.h<br>
@@ -5,6 +5,11 @@<br>
 #ifndef __EROFS_EXCLUDE_H<br>
 #define __EROFS_EXCLUDE_H<br>
<br>
+#ifdef __cplusplus<br>
+extern "C"<br>
+{<br>
+#endif<br>
+<br>
 #include <sys/types.h><br>
 #include <regex.h><br>
<br>
@@ -21,4 +26,9 @@ void erofs_cleanup_exclude_rules(void);<br>
 int erofs_parse_exclude_path(const char *args, bool is_regex);<br>
 struct erofs_exclude_rule *erofs_is_exclude_path(const char *dir,<br>
                                                 const char *name);<br>
+<br>
+#ifdef __cplusplus<br>
+}<br>
+#endif<br>
+<br>
 #endif<br>
diff --git a/include/erofs/flex-array.h b/include/erofs/flex-array.h<br>
index 59168d05ee5a..9b1642f77740 100644<br>
--- a/include/erofs/flex-array.h<br>
+++ b/include/erofs/flex-array.h<br>
@@ -2,6 +2,11 @@<br>
 #ifndef __EROFS_FLEX_ARRAY_H<br>
 #define __EROFS_FLEX_ARRAY_H<br>
<br>
+#ifdef __cplusplus<br>
+extern "C"<br>
+{<br>
+#endif<br>
+<br>
 #include <stdio.h><br>
 #include <stdlib.h><br>
 #include <limits.h><br>
@@ -144,4 +149,8 @@ static inline size_t st_add(size_t a, size_t b)<br>
 #define FLEXPTR_ALLOC_STR(x, ptrname, str) \<br>
        FLEXPTR_ALLOC_MEM((x), ptrname, (str), strlen(str))<br>
<br>
+#ifdef __cplusplus<br>
+}<br>
+#endif<br>
+<br>
 #endif<br>
diff --git a/include/erofs/hashmap.h b/include/erofs/hashmap.h<br>
index 024a14e497d4..3d3857890077 100644<br>
--- a/include/erofs/hashmap.h<br>
+++ b/include/erofs/hashmap.h<br>
@@ -2,6 +2,11 @@<br>
 #ifndef __EROFS_HASHMAP_H<br>
 #define __EROFS_HASHMAP_H<br>
<br>
+#ifdef __cplusplus<br>
+extern "C"<br>
+{<br>
+#endif<br>
+<br>
 /* Copied from <a href="https://github.com/git/git.git" rel="noreferrer" target="_blank">https://github.com/git/git.git</a> */<br>
 #include <stdio.h><br>
 #include <stdlib.h><br>
@@ -100,4 +105,8 @@ static inline const char *strintern(const char *string)<br>
        return memintern(string, strlen(string));<br>
 }<br>
<br>
+#ifdef __cplusplus<br>
+}<br>
+#endif<br>
+<br>
 #endif<br>
diff --git a/include/erofs/hashtable.h b/include/erofs/hashtable.h<br>
index 90eb84ee8598..3c4dfc128eaa 100644<br>
--- a/include/erofs/hashtable.h<br>
+++ b/include/erofs/hashtable.h<br>
@@ -5,6 +5,11 @@<br>
 #ifndef __EROFS_HASHTABLE_H<br>
 #define __EROFS_HASHTABLE_H<br>
<br>
+#ifdef __cplusplus<br>
+extern "C"<br>
+{<br>
+#endif<br>
+<br>
 /*<br>
  * Fast hashing routine for ints,  longs and pointers.<br>
  * (C) 2002 Nadia Yvette Chambers, IBM<br>
@@ -380,4 +385,8 @@ static inline void hash_del(struct hlist_node *node)<br>
 #define hash_for_each_possible(name, obj, member, key)                 \<br>
        hlist_for_each_entry(obj, &name[hash_min(key, HASH_BITS(name))], member)<br>
<br>
+#ifdef __cplusplus<br>
+}<br>
+#endif<br>
+<br>
 #endif<br>
diff --git a/include/erofs/inode.h b/include/erofs/inode.h<br>
index d5343c242aee..e23d65f42249 100644<br>
--- a/include/erofs/inode.h<br>
+++ b/include/erofs/inode.h<br>
@@ -8,6 +8,11 @@<br>
 #ifndef __EROFS_INODE_H<br>
 #define __EROFS_INODE_H<br>
<br>
+#ifdef __cplusplus<br>
+extern "C"<br>
+{<br>
+#endif<br>
+<br>
 #include "erofs/internal.h"<br>
<br>
 unsigned char erofs_mode_to_ftype(umode_t mode);<br>
@@ -17,4 +22,8 @@ erofs_nid_t erofs_lookupnid(struct erofs_inode *inode);<br>
 struct erofs_inode *erofs_mkfs_build_tree_from_path(struct erofs_inode *parent,<br>
                                                    const char *path);<br>
<br>
+#ifdef __cplusplus<br>
+}<br>
+#endif<br>
+<br>
 #endif<br>
diff --git a/include/erofs/internal.h b/include/erofs/internal.h<br>
index 666d1f2df466..a68de325da39 100644<br>
--- a/include/erofs/internal.h<br>
+++ b/include/erofs/internal.h<br>
@@ -7,6 +7,11 @@<br>
 #ifndef __EROFS_INTERNAL_H<br>
 #define __EROFS_INTERNAL_H<br>
<br>
+#ifdef __cplusplus<br>
+extern "C"<br>
+{<br>
+#endif<br>
+<br>
 #include "list.h"<br>
 #include "err.h"<br>
<br>
@@ -331,4 +336,8 @@ static inline u32 erofs_crc32c(u32 crc, const u8 *in, size_t len)<br>
        return crc;<br>
 }<br>
<br>
+#ifdef __cplusplus<br>
+}<br>
+#endif<br>
+<br>
 #endif<br>
diff --git a/include/erofs/io.h b/include/erofs/io.h<br>
index 10a3681882e1..6f51e06ee7c2 100644<br>
--- a/include/erofs/io.h<br>
+++ b/include/erofs/io.h<br>
@@ -7,7 +7,14 @@<br>
 #ifndef __EROFS_IO_H<br>
 #define __EROFS_IO_H<br>
<br>
+#ifdef __cplusplus<br>
+extern "C"<br>
+{<br>
+#endif<br>
+<br>
+#ifndef _GNU_SOURCE<br>
 #define _GNU_SOURCE<br>
+#endif<br>
 #include <unistd.h><br>
 #include "internal.h"<br>
<br>
@@ -47,4 +54,8 @@ static inline int blk_read(int device_id, void *buf,<br>
                         blknr_to_addr(nblocks));<br>
 }<br>
<br>
+#ifdef __cplusplus<br>
+}<br>
 #endif<br>
+<br>
+#endif // EROFS_IO_H_<br>
diff --git a/include/erofs/list.h b/include/erofs/list.h<br>
index d2bc704ae64b..fd5358d6bd19 100644<br>
--- a/include/erofs/list.h<br>
+++ b/include/erofs/list.h<br>
@@ -7,6 +7,11 @@<br>
 #ifndef __EROFS_LIST_HEAD_H<br>
 #define __EROFS_LIST_HEAD_H<br>
<br>
+#ifdef __cplusplus<br>
+extern "C"<br>
+{<br>
+#endif<br>
+<br>
 #include "defs.h"<br>
<br>
 struct list_head {<br>
@@ -105,4 +110,9 @@ static inline int list_empty(struct list_head *head)<br>
             &pos->member != (head);                                           \<br>
             pos = n, n = list_next_entry(n, member))<br>
<br>
+<br>
+#ifdef __cplusplus<br>
+}<br>
+#endif<br>
+<br>
 #endif<br>
diff --git a/include/erofs/print.h b/include/erofs/print.h<br>
index 91f864bacd55..2213d1d58de5 100644<br>
--- a/include/erofs/print.h<br>
+++ b/include/erofs/print.h<br>
@@ -7,6 +7,11 @@<br>
 #ifndef __EROFS_PRINT_H<br>
 #define __EROFS_PRINT_H<br>
<br>
+#ifdef __cplusplus<br>
+extern "C"<br>
+{<br>
+#endif<br>
+<br>
 #include "config.h"<br>
 #include <stdio.h><br>
<br>
@@ -72,4 +77,8 @@ enum {<br>
<br>
 #define erofs_dump(fmt, ...) fprintf(stderr, fmt, ##__VA_ARGS__)<br>
<br>
+#ifdef __cplusplus<br>
+}<br>
+#endif<br>
+<br>
 #endif<br>
diff --git a/include/erofs/trace.h b/include/erofs/trace.h<br>
index d70d23674c1a..893e16c5d6c1 100644<br>
--- a/include/erofs/trace.h<br>
+++ b/include/erofs/trace.h<br>
@@ -5,7 +5,16 @@<br>
 #ifndef __EROFS_TRACE_H<br>
 #define __EROFS_TRACE_H<br>
<br>
+#ifdef __cplusplus<br>
+extern "C"<br>
+{<br>
+#endif<br>
+<br>
 #define trace_erofs_map_blocks_flatmode_enter(inode, map, flags) ((void)0)<br>
 #define trace_erofs_map_blocks_flatmode_exit(inode, map, flags, ret) ((void)0)<br>
<br>
+#ifdef __cplusplus<br>
+}<br>
+#endif<br>
+<br>
 #endif<br>
diff --git a/include/erofs/xattr.h b/include/erofs/xattr.h<br>
index f0c4c268fecc..8e6881247f42 100644<br>
--- a/include/erofs/xattr.h<br>
+++ b/include/erofs/xattr.h<br>
@@ -7,6 +7,11 @@<br>
 #ifndef __EROFS_XATTR_H<br>
 #define __EROFS_XATTR_H<br>
<br>
+#ifdef __cplusplus<br>
+extern "C"<br>
+{<br>
+#endif<br>
+<br>
 #include "internal.h"<br>
<br>
 #define EROFS_INODE_XATTR_ICOUNT(_size)        ({\<br>
@@ -44,4 +49,8 @@ int erofs_prepare_xattr_ibody(struct erofs_inode *inode);<br>
 char *erofs_export_xattr_ibody(struct list_head *ixattrs, unsigned int size);<br>
 int erofs_build_shared_xattrs_from_path(const char *path);<br>
<br>
+#ifdef __cplusplus<br>
+}<br>
+#endif<br>
+<br>
 #endif<br>
diff --git a/lib/Makefile.am b/lib/Makefile.am<br>
index 395c712811b8..67ba798672b9 100644<br>
--- a/lib/Makefile.am<br>
+++ b/lib/Makefile.am<br>
@@ -21,7 +21,8 @@ noinst_HEADERS = $(top_srcdir)/include/erofs_fs.h \<br>
       $(top_srcdir)/include/erofs/print.h \<br>
       $(top_srcdir)/include/erofs/trace.h \<br>
       $(top_srcdir)/include/erofs/xattr.h \<br>
-      $(top_srcdir)/include/erofs/compress_hints.h<br>
+      $(top_srcdir)/include/erofs/compress_hints.h \<br>
+      $(top_srcdir)/lib/liberofs_private.h<br>
<br>
 noinst_HEADERS += compressor.h<br>
 liberofs_la_SOURCES = config.c io.c cache.c super.c inode.c xattr.c exclude.c \<br>
diff --git a/lib/config.c b/lib/config.c<br>
index 363dcc5a0525..f1c8edfda2dc 100644<br>
--- a/lib/config.c<br>
+++ b/lib/config.c<br>
@@ -8,6 +8,7 @@<br>
 #include <stdlib.h><br>
 #include "erofs/print.h"<br>
 #include "erofs/internal.h"<br>
+#include "liberofs_private.h"<br>
<br>
 struct erofs_configure cfg;<br>
 struct erofs_sb_info sbi;<br>
diff --git a/lib/inode.c b/lib/inode.c<br>
index 2fa74e2686c9..461c7978dbdf 100644<br>
--- a/lib/inode.c<br>
+++ b/lib/inode.c<br>
@@ -25,6 +25,7 @@<br>
 #include "erofs/block_list.h"<br>
 #include "erofs/compress_hints.h"<br>
 #include "erofs/blobchunk.h"<br>
+#include "liberofs_private.h"<br>
<br>
 #define S_SHIFT                 12<br>
 static unsigned char erofs_ftype_by_mode[S_IFMT >> S_SHIFT] = {<br>
diff --git a/lib/liberofs_private.h b/lib/liberofs_private.h<br>
new file mode 100644<br>
index 000000000000..c2312e8e7a31<br>
--- /dev/null<br>
+++ b/lib/liberofs_private.h<br>
@@ -0,0 +1,13 @@<br>
+/* SPDX-License-Identifier: GPL-2.0-only OR Apache-2.0 */<br>
+<br>
+#ifdef HAVE_LIBSELINUX<br>
+#include <selinux/selinux.h><br>
+#include <selinux/label.h><br>
+#endif<br>
+<br>
+#ifdef WITH_ANDROID<br>
+#include <selinux/android.h><br>
+#include <private/android_filesystem_config.h><br>
+#include <private/canned_fs_config.h><br>
+#include <private/fs_config.h><br>
+#endif<br>
diff --git a/lib/xattr.c b/lib/xattr.c<br>
index 196133a1a798..00fb963c68ef 100644<br>
--- a/lib/xattr.c<br>
+++ b/lib/xattr.c<br>
@@ -17,6 +17,7 @@<br>
 #include "erofs/xattr.h"<br>
 #include "erofs/cache.h"<br>
 #include "erofs/io.h"<br>
+#include "liberofs_private.h"<br>
<br>
 #define EA_HASHTABLE_BITS 16<br>
<br>
-- <br>
2.20.1<br>
<br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr">Sincerely,<div><br></div><div>Kelvin Zhang</div></div></div>