[PATCH 3/3] erofs-utils: lib: unexport `erofs/cache.h`

Gao Xiang hsiangkao at linux.alibaba.com
Wed Aug 20 15:38:06 AEST 2025


It shouldn't be used by external users.

Signed-off-by: Gao Xiang <hsiangkao at linux.alibaba.com>
---
 include/erofs/internal.h                      |  3 +++
 lib/Makefile.am                               |  2 +-
 lib/blobchunk.c                               |  2 +-
 lib/cache.c                                   |  2 +-
 lib/compress.c                                |  2 +-
 lib/importer.c                                |  2 +-
 lib/inode.c                                   |  2 +-
 include/erofs/cache.h => lib/liberofs_cache.h | 12 +++++-------
 lib/metabox.c                                 |  2 +-
 lib/super.c                                   |  2 +-
 lib/tar.c                                     |  2 +-
 lib/xattr.c                                   |  2 +-
 mkfs/main.c                                   |  1 -
 13 files changed, 18 insertions(+), 18 deletions(-)
 rename include/erofs/cache.h => lib/liberofs_cache.h (92%)

diff --git a/include/erofs/internal.h b/include/erofs/internal.h
index a609fbd..ea58584 100644
--- a/include/erofs/internal.h
+++ b/include/erofs/internal.h
@@ -537,6 +537,9 @@ static inline int erofs_blk_read(struct erofs_sb_info *sbi, int device_id,
 /* vmdk.c */
 int erofs_dump_vmdk_desc(FILE *f, struct erofs_sb_info *sbi);
 
+/* XXX: will find a better way later */
+erofs_blk_t erofs_total_metablocks(struct erofs_bufmgr *bmgr);
+
 #ifdef EUCLEAN
 #define EFSCORRUPTED	EUCLEAN		/* Filesystem is corrupted */
 #else
diff --git a/lib/Makefile.am b/lib/Makefile.am
index f485440..955495d 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -4,7 +4,6 @@ noinst_LTLIBRARIES = liberofs.la
 noinst_HEADERS = $(top_srcdir)/include/erofs_fs.h \
       $(top_srcdir)/include/erofs/blobchunk.h \
       $(top_srcdir)/include/erofs/block_list.h \
-      $(top_srcdir)/include/erofs/cache.h \
       $(top_srcdir)/include/erofs/compress.h \
       $(top_srcdir)/include/erofs/config.h \
       $(top_srcdir)/include/erofs/decompress.h \
@@ -28,6 +27,7 @@ noinst_HEADERS = $(top_srcdir)/include/erofs_fs.h \
       $(top_srcdir)/include/erofs/fragments.h \
       $(top_srcdir)/include/erofs/rebuild.h \
       $(top_srcdir)/include/erofs/importer.h \
+      $(top_srcdir)/lib/liberofs_cache.h \
       $(top_srcdir)/lib/liberofs_private.h \
       $(top_srcdir)/lib/liberofs_xxhash.h \
       $(top_srcdir)/lib/liberofs_metabox.h \
diff --git a/lib/blobchunk.c b/lib/blobchunk.c
index 157b9a9..af6ddd7 100644
--- a/lib/blobchunk.c
+++ b/lib/blobchunk.c
@@ -8,7 +8,7 @@
 #include "erofs/hashmap.h"
 #include "erofs/blobchunk.h"
 #include "erofs/block_list.h"
-#include "erofs/cache.h"
+#include "liberofs_cache.h"
 #include "liberofs_private.h"
 #include "sha256.h"
 #include <unistd.h>
diff --git a/lib/cache.c b/lib/cache.c
index cd11737..24449f2 100644
--- a/lib/cache.c
+++ b/lib/cache.c
@@ -6,9 +6,9 @@
  * with heavy changes by Gao Xiang <xiang at kernel.org>
  */
 #include <stdlib.h>
-#include <erofs/cache.h>
 #include <erofs/bitops.h>
 #include "erofs/print.h"
+#include "liberofs_cache.h"
 
 static int erofs_bh_flush_drop_directly(struct erofs_buffer_head *bh)
 {
diff --git a/lib/compress.c b/lib/compress.c
index 0049199..622a205 100644
--- a/lib/compress.c
+++ b/lib/compress.c
@@ -15,7 +15,6 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include "erofs/print.h"
-#include "erofs/cache.h"
 #include "erofs/compress.h"
 #include "erofs/dedupe.h"
 #include "compressor.h"
@@ -25,6 +24,7 @@
 #ifdef EROFS_MT_ENABLED
 #include "erofs/workqueue.h"
 #endif
+#include "liberofs_cache.h"
 #include "liberofs_metabox.h"
 
 #define Z_EROFS_DESTBUF_SZ	(Z_EROFS_PCLUSTER_MAX_SIZE + EROFS_MAX_BLOCK_SIZE * 2)
diff --git a/lib/importer.c b/lib/importer.c
index 95f006d..9c57c07 100644
--- a/lib/importer.c
+++ b/lib/importer.c
@@ -4,12 +4,12 @@
  */
 #include "erofs/fragments.h"
 #include "erofs/importer.h"
-#include "erofs/cache.h"
 #include "erofs/config.h"
 #include "erofs/dedupe.h"
 #include "erofs/inode.h"
 #include "erofs/print.h"
 #include "erofs/lock.h"
+#include "liberofs_cache.h"
 #include "liberofs_metabox.h"
 
 static EROFS_DEFINE_MUTEX(erofs_importer_global_mutex);
diff --git a/lib/inode.c b/lib/inode.c
index 302492c..7ee6b3d 100644
--- a/lib/inode.c
+++ b/lib/inode.c
@@ -19,7 +19,6 @@
 #include "erofs/lock.h"
 #include "erofs/diskbuf.h"
 #include "erofs/inode.h"
-#include "erofs/cache.h"
 #include "erofs/compress.h"
 #include "erofs/xattr.h"
 #include "erofs/exclude.h"
@@ -28,6 +27,7 @@
 #include "erofs/blobchunk.h"
 #include "erofs/fragments.h"
 #include "erofs/importer.h"
+#include "liberofs_cache.h"
 #include "liberofs_private.h"
 #include "liberofs_metabox.h"
 
diff --git a/include/erofs/cache.h b/lib/liberofs_cache.h
similarity index 92%
rename from include/erofs/cache.h
rename to lib/liberofs_cache.h
index c248b73..215b320 100644
--- a/include/erofs/cache.h
+++ b/lib/liberofs_cache.h
@@ -1,12 +1,11 @@
 /* SPDX-License-Identifier: GPL-2.0+ OR Apache-2.0 */
 /*
  * Copyright (C) 2018 HUAWEI, Inc.
- *             http://www.huawei.com/
- * Created by Miao Xie <miaoxie at huawei.com>
- * with heavy changes by Gao Xiang <xiang at kernel.org>
+ *             http://www.huawei.com
+ * Copyright (C) 2025 Alibaba Cloud
  */
-#ifndef __EROFS_CACHE_H
-#define __EROFS_CACHE_H
+#ifndef __EROFS_LIB_LIBEROFS_CACHE_H
+#define __EROFS_LIB_LIBEROFS_CACHE_H
 
 #ifdef __cplusplus
 extern "C"
@@ -14,7 +13,7 @@ extern "C"
 #endif
 
 #include <stdlib.h>
-#include "internal.h"
+#include "erofs/internal.h"
 
 struct erofs_buffer_head;
 struct erofs_buffer_block;
@@ -139,7 +138,6 @@ int erofs_bflush(struct erofs_bufmgr *bmgr,
 		 struct erofs_buffer_block *bb);
 
 void erofs_bdrop(struct erofs_buffer_head *bh, bool tryrevoke);
-erofs_blk_t erofs_total_metablocks(struct erofs_bufmgr *bmgr);
 void erofs_buffer_exit(struct erofs_bufmgr *bmgr);
 
 #ifdef __cplusplus
diff --git a/lib/metabox.c b/lib/metabox.c
index c9db9ac..fdc46eb 100644
--- a/lib/metabox.c
+++ b/lib/metabox.c
@@ -1,8 +1,8 @@
 // SPDX-License-Identifier: GPL-2.0+ OR Apache-2.0
 #include <stdlib.h>
-#include "erofs/cache.h"
 #include "erofs/inode.h"
 #include "erofs/importer.h"
+#include "liberofs_cache.h"
 #include "liberofs_private.h"
 #include "liberofs_metabox.h"
 
diff --git a/lib/super.c b/lib/super.c
index 97d955f..a9ec3aa 100644
--- a/lib/super.c
+++ b/lib/super.c
@@ -6,7 +6,7 @@
 #include <stdlib.h>
 #include "erofs/print.h"
 #include "erofs/xattr.h"
-#include "erofs/cache.h"
+#include "liberofs_cache.h"
 
 static bool check_layout_compatibility(struct erofs_sb_info *sbi,
 				       struct erofs_super_block *dsb)
diff --git a/lib/tar.c b/lib/tar.c
index 95129b3..fe801e2 100644
--- a/lib/tar.c
+++ b/lib/tar.c
@@ -4,7 +4,6 @@
 #include <string.h>
 #include <sys/stat.h>
 #include "erofs/print.h"
-#include "erofs/cache.h"
 #include "erofs/diskbuf.h"
 #include "erofs/inode.h"
 #include "erofs/list.h"
@@ -16,6 +15,7 @@
 #if defined(HAVE_ZLIB)
 #include <zlib.h>
 #endif
+#include "liberofs_cache.h"
 
 /* This file is a tape/volume header.  Ignore it on extraction.  */
 #define GNUTYPE_VOLHDR 'V'
diff --git a/lib/xattr.c b/lib/xattr.c
index 1f6a83f..114e2bb 100644
--- a/lib/xattr.c
+++ b/lib/xattr.c
@@ -15,8 +15,8 @@
 #include "erofs/print.h"
 #include "erofs/hashtable.h"
 #include "erofs/xattr.h"
-#include "erofs/cache.h"
 #include "erofs/fragments.h"
+#include "liberofs_cache.h"
 #include "liberofs_xxhash.h"
 #include "liberofs_private.h"
 
diff --git a/mkfs/main.c b/mkfs/main.c
index d2950b7..e0ba55d 100644
--- a/mkfs/main.c
+++ b/mkfs/main.c
@@ -15,7 +15,6 @@
 #include <getopt.h>
 #include "erofs/config.h"
 #include "erofs/print.h"
-#include "erofs/cache.h"
 #include "erofs/importer.h"
 #include "erofs/diskbuf.h"
 #include "erofs/inode.h"
-- 
2.43.5



More information about the Linux-erofs mailing list