[RFC PATCH 2/5] erofs-utils: lib: add manifest loader interface

adigitX adityakammati.workspace at gmail.com
Sun Mar 22 02:28:29 AEDT 2026


---
 include/erofs/manifest.h | 26 ++++++++++++++++++++++++++
 lib/Makefile.am          |  3 ++-
 lib/manifest.c           | 16 ++++++++++++++++
 mkfs/main.c              | 17 +++++++----------
 4 files changed, 51 insertions(+), 11 deletions(-)
 create mode 100644 include/erofs/manifest.h
 create mode 100644 lib/manifest.c

diff --git a/include/erofs/manifest.h b/include/erofs/manifest.h
new file mode 100644
index 0000000..c8a04ec
--- /dev/null
+++ b/include/erofs/manifest.h
@@ -0,0 +1,26 @@
+/* SPDX-License-Identifier: GPL-2.0+ OR Apache-2.0 */
+#ifndef __EROFS_MANIFEST_H
+#define __EROFS_MANIFEST_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#include "importer.h"
+
+enum erofs_manifest_format {
+	EROFS_MANIFEST_FORMAT_AUTO,
+	EROFS_MANIFEST_FORMAT_COMPOSEFS,
+	EROFS_MANIFEST_FORMAT_PROTO,
+};
+
+int erofs_manifest_load(struct erofs_importer *im,
+			enum erofs_manifest_format format,
+			const char *source);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 77f6fd8..42c56dc 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -16,6 +16,7 @@ noinst_HEADERS = $(top_srcdir)/include/erofs_fs.h \
       $(top_srcdir)/include/erofs/internal.h \
       $(top_srcdir)/include/erofs/io.h \
       $(top_srcdir)/include/erofs/list.h \
+      $(top_srcdir)/include/erofs/manifest.h \
       $(top_srcdir)/include/erofs/print.h \
       $(top_srcdir)/include/erofs/bitops.h \
       $(top_srcdir)/include/erofs/tar.h \
@@ -40,7 +41,7 @@ liberofs_la_SOURCES = config.c io.c cache.c super.c inode.c xattr.c exclude.c \
 		      namei.c data.c compress.c compressor.c zmap.c decompress.c \
 		      compress_hints.c hashmap.c sha256.c blobchunk.c dir.c \
 		      fragments.c dedupe.c uuid_unparse.c uuid.c tar.c \
-		      block_list.c rebuild.c diskbuf.c bitops.c dedupe_ext.c \
+		      block_list.c rebuild.c diskbuf.c manifest.c bitops.c dedupe_ext.c \
 		      vmdk.c metabox.c global.c importer.c base64.c
 
 liberofs_la_CFLAGS = -Wall ${libuuid_CFLAGS} -I$(top_srcdir)/include
diff --git a/lib/manifest.c b/lib/manifest.c
new file mode 100644
index 0000000..d7bbd5d
--- /dev/null
+++ b/lib/manifest.c
@@ -0,0 +1,16 @@
+// SPDX-License-Identifier: GPL-2.0+ OR Apache-2.0
+#include <errno.h>
+#include "erofs/manifest.h"
+#include "erofs/print.h"
+
+int erofs_manifest_load(struct erofs_importer *im,
+			enum erofs_manifest_format format,
+			const char *source)
+{
+	if (!im || !im->root || !source)
+		return -EINVAL;
+
+	(void)format;
+	erofs_err("manifest input support is not implemented yet");
+	return -EOPNOTSUPP;
+}
diff --git a/mkfs/main.c b/mkfs/main.c
index 9641f2f..cb2cdca 100644
--- a/mkfs/main.c
+++ b/mkfs/main.c
@@ -16,6 +16,7 @@
 #include "erofs/config.h"
 #include "erofs/print.h"
 #include "erofs/importer.h"
+#include "erofs/manifest.h"
 #include "erofs/diskbuf.h"
 #include "erofs/inode.h"
 #include "erofs/tar.h"
@@ -326,11 +327,7 @@ static enum {
 	EROFS_MKFS_SOURCE_REBUILD,
 } source_mode;
 
-static enum {
-	EROFS_MKFS_MANIFEST_AUTO,
-	EROFS_MKFS_MANIFEST_COMPOSEFS,
-	EROFS_MKFS_MANIFEST_PROTO,
-} manifest_format;
+static enum erofs_manifest_format manifest_format;
 
 static unsigned int rebuild_src_count;
 static LIST_HEAD(rebuild_src_list);
@@ -349,18 +346,18 @@ static int mkfs_parse_manifest_cfg(const char *arg)
 	}
 
 	source_mode = EROFS_MKFS_SOURCE_MANIFEST;
-	manifest_format = EROFS_MKFS_MANIFEST_AUTO;
+	manifest_format = EROFS_MANIFEST_FORMAT_AUTO;
 
 	if (!arg || !*arg)
 		return 0;
 	if (!strcmp(arg, "auto"))
 		return 0;
 	if (!strcmp(arg, "composefs")) {
-		manifest_format = EROFS_MKFS_MANIFEST_COMPOSEFS;
+		manifest_format = EROFS_MANIFEST_FORMAT_COMPOSEFS;
 		return 0;
 	}
 	if (!strcmp(arg, "proto")) {
-		manifest_format = EROFS_MKFS_MANIFEST_PROTO;
+		manifest_format = EROFS_MANIFEST_FORMAT_PROTO;
 		return 0;
 	}
 
@@ -2089,8 +2086,8 @@ int main(int argc, char **argv)
 		while (!(err = tarerofs_parse_tar(&importer, &erofstar)))
 			;
 	} else if (source_mode == EROFS_MKFS_SOURCE_MANIFEST) {
-		erofs_err("manifest input support is not implemented yet");
-		err = -EOPNOTSUPP;
+		err = erofs_manifest_load(&importer, manifest_format,
+					  cfg.c_src_path);
 	} else if (source_mode == EROFS_MKFS_SOURCE_REBUILD) {
 		err = erofs_mkfs_rebuild_load_trees(root);
 #ifdef S3EROFS_ENABLED
-- 
2.51.0



More information about the Linux-erofs mailing list