[PATCH 3/7] erofs-utils: lib: unexport "erofs/fragments.h"

Gao Xiang hsiangkao at linux.alibaba.com
Thu Oct 16 13:48:11 AEDT 2025


Disallow external users to use those internal APIs.

Signed-off-by: Gao Xiang <hsiangkao at linux.alibaba.com>
---
 dump/main.c                                   |  1 -
 fsck/main.c                                   |  1 -
 fuse/main.c                                   |  1 -
 include/erofs/internal.h                      | 14 +++++++++
 lib/Makefile.am                               |  2 +-
 lib/compress.c                                |  2 +-
 lib/data.c                                    |  2 +-
 lib/fragments.c                               |  2 +-
 lib/importer.c                                |  2 +-
 lib/inode.c                                   |  4 +--
 .../fragments.h => lib/liberofs_fragments.h   | 30 +++----------------
 lib/xattr.c                                   |  2 +-
 mkfs/main.c                                   |  1 -
 13 files changed, 26 insertions(+), 38 deletions(-)
 rename include/erofs/fragments.h => lib/liberofs_fragments.h (50%)

diff --git a/dump/main.c b/dump/main.c
index 4ad3f7b..57ec3b7 100644
--- a/dump/main.c
+++ b/dump/main.c
@@ -13,7 +13,6 @@
 #include "erofs/print.h"
 #include "erofs/inode.h"
 #include "erofs/dir.h"
-#include "erofs/fragments.h"
 #include "../lib/liberofs_compress.h"
 #include "../lib/liberofs_private.h"
 #include "../lib/liberofs_uuid.h"
diff --git a/fsck/main.c b/fsck/main.c
index a1cb0cd..8aba964 100644
--- a/fsck/main.c
+++ b/fsck/main.c
@@ -16,7 +16,6 @@
 #include "erofs/xattr.h"
 #include "../lib/compressor.h"
 #include "../lib/liberofs_compress.h"
-#include "erofs/fragments.h"
 
 static int erofsfsck_check_inode(erofs_nid_t pnid, erofs_nid_t nid);
 
diff --git a/fuse/main.c b/fuse/main.c
index c129a0c..82aca8c 100644
--- a/fuse/main.c
+++ b/fuse/main.c
@@ -12,7 +12,6 @@
 #include "erofs/print.h"
 #include "erofs/dir.h"
 #include "erofs/inode.h"
-#include "erofs/fragments.h"
 
 #include <float.h>
 #include <fuse.h>
diff --git a/include/erofs/internal.h b/include/erofs/internal.h
index 4de6563..6106501 100644
--- a/include/erofs/internal.h
+++ b/include/erofs/internal.h
@@ -535,6 +535,20 @@ 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);
 
+extern const char *erofs_frags_packedname;
+#define EROFS_PACKED_INODE	erofs_frags_packedname
+
+static inline bool erofs_is_packed_inode(struct erofs_inode *inode)
+{
+	return inode->i_srcpath == EROFS_PACKED_INODE;
+}
+
+int erofs_packedfile_init(struct erofs_sb_info *sbi, bool fragments_mkfs);
+void erofs_packedfile_exit(struct erofs_sb_info *sbi);
+
+int erofs_packedfile_read(struct erofs_sb_info *sbi,
+			  void *buf, erofs_off_t len, erofs_off_t pos);
+
 /* XXX: will find a better way later */
 erofs_blk_t erofs_total_metablocks(struct erofs_bufmgr *bmgr);
 
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 9991119..286932d 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -22,11 +22,11 @@ noinst_HEADERS = $(top_srcdir)/include/erofs_fs.h \
       $(top_srcdir)/include/erofs/trace.h \
       $(top_srcdir)/include/erofs/xattr.h \
       $(top_srcdir)/include/erofs/compress_hints.h \
-      $(top_srcdir)/include/erofs/fragments.h \
       $(top_srcdir)/include/erofs/importer.h \
       $(top_srcdir)/lib/liberofs_base64.h \
       $(top_srcdir)/lib/liberofs_cache.h \
       $(top_srcdir)/lib/liberofs_compress.h \
+      $(top_srcdir)/lib/liberofs_fragments.h \
       $(top_srcdir)/lib/liberofs_private.h \
       $(top_srcdir)/lib/liberofs_rebuild.h \
       $(top_srcdir)/lib/liberofs_xxhash.h \
diff --git a/lib/compress.c b/lib/compress.c
index 7f34b66..20f511e 100644
--- a/lib/compress.c
+++ b/lib/compress.c
@@ -19,12 +19,12 @@
 #include "compressor.h"
 #include "erofs/block_list.h"
 #include "erofs/compress_hints.h"
-#include "erofs/fragments.h"
 #ifdef EROFS_MT_ENABLED
 #include "erofs/workqueue.h"
 #endif
 #include "liberofs_cache.h"
 #include "liberofs_compress.h"
+#include "liberofs_fragments.h"
 #include "liberofs_metabox.h"
 
 #define Z_EROFS_DESTBUF_SZ	(Z_EROFS_PCLUSTER_MAX_SIZE + EROFS_MAX_BLOCK_SIZE * 2)
diff --git a/lib/data.c b/lib/data.c
index 6791fda..1e51134 100644
--- a/lib/data.c
+++ b/lib/data.c
@@ -8,7 +8,7 @@
 #include "erofs/internal.h"
 #include "erofs/trace.h"
 #include "erofs/decompress.h"
-#include "erofs/fragments.h"
+#include "liberofs_fragments.h"
 
 void *erofs_bread(struct erofs_buf *buf, erofs_off_t offset, bool need_kmap)
 {
diff --git a/lib/fragments.c b/lib/fragments.c
index 6a30785..244608f 100644
--- a/lib/fragments.c
+++ b/lib/fragments.c
@@ -16,11 +16,11 @@
 #include "erofs/inode.h"
 #include "erofs/print.h"
 #include "erofs/internal.h"
-#include "erofs/fragments.h"
 #include "erofs/bitops.h"
 #include "erofs/lock.h"
 #include "erofs/importer.h"
 #include "liberofs_compress.h"
+#include "liberofs_fragments.h"
 #include "liberofs_private.h"
 #ifdef HAVE_SYS_SENDFILE_H
 #include <sys/sendfile.h>
diff --git a/lib/importer.c b/lib/importer.c
index fed7bab..ad4bed8 100644
--- a/lib/importer.c
+++ b/lib/importer.c
@@ -2,7 +2,6 @@
 /*
  * Copyright (C) 2025 Alibaba Cloud
  */
-#include "erofs/fragments.h"
 #include "erofs/importer.h"
 #include "erofs/config.h"
 #include "erofs/dedupe.h"
@@ -12,6 +11,7 @@
 #include "erofs/xattr.h"
 #include "liberofs_cache.h"
 #include "liberofs_compress.h"
+#include "liberofs_fragments.h"
 #include "liberofs_metabox.h"
 
 static EROFS_DEFINE_MUTEX(erofs_importer_global_mutex);
diff --git a/lib/inode.c b/lib/inode.c
index d16468d..14a65af 100644
--- a/lib/inode.c
+++ b/lib/inode.c
@@ -24,12 +24,12 @@
 #include "erofs/block_list.h"
 #include "erofs/compress_hints.h"
 #include "erofs/blobchunk.h"
-#include "erofs/fragments.h"
 #include "erofs/importer.h"
 #include "liberofs_cache.h"
 #include "liberofs_compress.h"
-#include "liberofs_private.h"
+#include "liberofs_fragments.h"
 #include "liberofs_metabox.h"
+#include "liberofs_private.h"
 #include "liberofs_rebuild.h"
 
 static inline bool erofs_is_special_identifier(const char *path)
diff --git a/include/erofs/fragments.h b/lib/liberofs_fragments.h
similarity index 50%
rename from include/erofs/fragments.h
rename to lib/liberofs_fragments.h
index 00e1e46..ca71e52 100644
--- a/include/erofs/fragments.h
+++ b/lib/liberofs_fragments.h
@@ -1,25 +1,13 @@
 /* SPDX-License-Identifier: GPL-2.0+ OR Apache-2.0 */
 /*
- * Copyright (C), 2022, Coolpad Group Limited.
+ * Copyright (C) 2022, Coolpad Group Limited.
+ * Copyright (C) 2025 Alibaba Cloud
  */
-#ifndef __EROFS_FRAGMENTS_H
-#define __EROFS_FRAGMENTS_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
+#ifndef __EROFS_LIB_LIBEROFS_FRAGMENTS_H
+#define __EROFS_LIB_LIBEROFS_FRAGMENTS_H
 
 #include "erofs/internal.h"
 
-extern const char *erofs_frags_packedname;
-#define EROFS_PACKED_INODE	erofs_frags_packedname
-
-static inline bool erofs_is_packed_inode(struct erofs_inode *inode)
-{
-	return inode->i_srcpath == EROFS_PACKED_INODE;
-}
-
 struct erofs_importer;
 
 u32 z_erofs_fragments_tofh(struct erofs_inode *inode, int fd, erofs_off_t fpos);
@@ -32,14 +20,4 @@ int erofs_fragment_commit(struct erofs_inode *inode, u32 tofh);
 int erofs_flush_packed_inode(struct erofs_importer *im);
 int erofs_packedfile(struct erofs_sb_info *sbi);
 
-int erofs_packedfile_init(struct erofs_sb_info *sbi, bool fragments_mkfs);
-void erofs_packedfile_exit(struct erofs_sb_info *sbi);
-
-int erofs_packedfile_read(struct erofs_sb_info *sbi,
-			  void *buf, erofs_off_t len, erofs_off_t pos);
-
-#ifdef __cplusplus
-}
-#endif
-
 #endif
diff --git a/lib/xattr.c b/lib/xattr.c
index e02e8cb..fc22c81 100644
--- a/lib/xattr.c
+++ b/lib/xattr.c
@@ -15,9 +15,9 @@
 #include "erofs/print.h"
 #include "erofs/list.h"
 #include "erofs/xattr.h"
-#include "erofs/fragments.h"
 #include "erofs/importer.h"
 #include "liberofs_cache.h"
+#include "liberofs_fragments.h"
 #include "liberofs_metabox.h"
 #include "liberofs_xxhash.h"
 #include "liberofs_private.h"
diff --git a/mkfs/main.c b/mkfs/main.c
index 5657b1d..11e3032 100644
--- a/mkfs/main.c
+++ b/mkfs/main.c
@@ -25,7 +25,6 @@
 #include "erofs/block_list.h"
 #include "erofs/compress_hints.h"
 #include "erofs/blobchunk.h"
-#include "erofs/fragments.h"
 #include "../lib/compressor.h"
 #include "../lib/liberofs_gzran.h"
 #include "../lib/liberofs_metabox.h"
-- 
2.43.5



More information about the Linux-erofs mailing list