Skip to contentSkip to conversation

erofs-utils: add a dedicated mount helper

PATCH Superseded Gao Xiang 1 participant 2 messages Aug 21, 2025 Kbuild

lore
Share & tools
lore

Gao Xiang

author
#0 lore raw

PATCH 1/1 erofs-utils: add a dedicated mount helper

Currently, kernel and FUSE mounts are supported for local images. Support for remote images will be added later.

---
 Makefile.am              |   2 +-
 configure.ac             |   2 +
 include/erofs/err.h      |  10 ++
 include/erofs/internal.h |  11 --
 mount/Makefile.am        |  11 ++
 mount/main.c             | 287 +++++++++++++++++++++++++++++++++++++++
 6 files changed, 311 insertions(+), 12 deletions(-)
 create mode 100644 mount/Makefile.am
 create mode 100644 mount/main.c
Makefile.am +1 -1
index f8a967f..7cb93a6 100644
@@ -6,4 +6,4 @@ SUBDIRS = man lib mkfs dump fsck
 if ENABLE_FUSE
 SUBDIRS += fuse
 endif
-SUBDIRS += contrib
+SUBDIRS += mount contrib
configure.ac +2 -0
index 1efb57a..c0174ce 100644
@@ -217,6 +217,7 @@ AC_CHECK_HEADERS(m4_flatten([
 	linux/aufs_type.h
 	linux/falloc.h
 	linux/fs.h
+	linux/loop.h
 	linux/types.h
 	linux/xattr.h
 	limits.h
@@ -799,5 +800,6 @@ AC_CONFIG_FILES([Makefile
 		 dump/Makefile
 		 fuse/Makefile
 		 fsck/Makefile
+		 mount/Makefile
 		 contrib/Makefile])
 AC_OUTPUT
include/erofs/err.h +10 -0
index 2ae9e21..ff488dd 100644
@@ -13,6 +13,16 @@ extern "C"
 #endif
 
 #include <errno.h>
+#include <string.h>
+#include <stdio.h>
+
+static inline const char *erofs_strerror(int err)
+{
+	static char msg[256];
+
+	sprintf(msg, "[Error %d] %s", -err, strerror(-err));
+	return msg;
+}
 
 #define MAX_ERRNO (4095)
 #define IS_ERR_VALUE(x)                                                        \
include/erofs/internal.h +0 -11
index ea58584..9a82e06 100644
@@ -362,17 +362,6 @@ static inline bool is_dot_dotdot(const char *name)
 	return name[1] == '\0' || (name[1] == '.' && name[2] == '\0');
 }
 
-#include <stdio.h>
-#include <string.h>
-
-static inline const char *erofs_strerror(int err)
-{
-	static char msg[256];
-
-	sprintf(msg, "[Error %d] %s", -err, strerror(-err));
-	return msg;
-}
-
 enum {
 	BH_Meta,
 	BH_Mapped,
mount/Makefile.am new file +11 -0
new file mode 100644
index 0000000..d901c20
@@ -0,0 +1,11 @@
+# SPDX-License-Identifier: GPL-2.0+
+# Makefile.am
+
+AUTOMAKE_OPTIONS = foreign
+sbin_PROGRAMS    = mount.erofs
+AM_CPPFLAGS = ${libuuid_CFLAGS}
+mount_erofs_SOURCES = main.c
+mount_erofs_CFLAGS = -Wall -I$(top_srcdir)/include
+mount_erofs_LDADD = $(top_builddir)/lib/liberofs.la ${libselinux_LIBS} \
+	${liblz4_LIBS} ${liblzma_LIBS} ${zlib_LIBS} ${libdeflate_LIBS} \
+	${libzstd_LIBS} ${libqpl_LIBS} ${libxxhash_LIBS}
mount/main.c new file +287 -0

287 lines not on this page · raw message

Signature · 1 line
2.43.0
author
#1 lore raw

PATCH v2 1/1 erofs-utils: add a dedicated mount helper

Currently, kernel and FUSE mounts are supported for local images. Support for remote images will be added later.

---
v2:
- fix missing <fcntl.h>

 Makefile.am              |   2 +-
 configure.ac             |   2 +
 include/erofs/err.h      |  10 ++
 include/erofs/internal.h |  11 --
 mount/Makefile.am        |  11 ++
 mount/main.c             | 289 +++++++++++++++++++++++++++++++++++++++
 6 files changed, 313 insertions(+), 12 deletions(-)
 create mode 100644 mount/Makefile.am
 create mode 100644 mount/main.c
Makefile.am +1 -1
index f8a967f..7cb93a6 100644
@@ -6,4 +6,4 @@ SUBDIRS = man lib mkfs dump fsck
 if ENABLE_FUSE
 SUBDIRS += fuse
 endif
-SUBDIRS += contrib
+SUBDIRS += mount contrib
configure.ac +2 -0
index 1efb57a..c0174ce 100644
@@ -217,6 +217,7 @@ AC_CHECK_HEADERS(m4_flatten([
 	linux/aufs_type.h
 	linux/falloc.h
 	linux/fs.h
+	linux/loop.h
 	linux/types.h
 	linux/xattr.h
 	limits.h
@@ -799,5 +800,6 @@ AC_CONFIG_FILES([Makefile
 		 dump/Makefile
 		 fuse/Makefile
 		 fsck/Makefile
+		 mount/Makefile
 		 contrib/Makefile])
 AC_OUTPUT
include/erofs/err.h +10 -0
index 2ae9e21..ff488dd 100644
@@ -13,6 +13,16 @@ extern "C"
 #endif
 
 #include <errno.h>
+#include <string.h>
+#include <stdio.h>
+
+static inline const char *erofs_strerror(int err)
+{
+	static char msg[256];
+
+	sprintf(msg, "[Error %d] %s", -err, strerror(-err));
+	return msg;
+}
 
 #define MAX_ERRNO (4095)
 #define IS_ERR_VALUE(x)                                                        \
include/erofs/internal.h +0 -11
index ea58584..9a82e06 100644
@@ -362,17 +362,6 @@ static inline bool is_dot_dotdot(const char *name)
 	return name[1] == '\0' || (name[1] == '.' && name[2] == '\0');
 }
 
-#include <stdio.h>
-#include <string.h>
-
-static inline const char *erofs_strerror(int err)
-{
-	static char msg[256];
-
-	sprintf(msg, "[Error %d] %s", -err, strerror(-err));
-	return msg;
-}
-
 enum {
 	BH_Meta,
 	BH_Mapped,
mount/Makefile.am new file +11 -0
new file mode 100644
index 0000000..d901c20
@@ -0,0 +1,11 @@
+# SPDX-License-Identifier: GPL-2.0+
+# Makefile.am
+
+AUTOMAKE_OPTIONS = foreign
+sbin_PROGRAMS    = mount.erofs
+AM_CPPFLAGS = ${libuuid_CFLAGS}
+mount_erofs_SOURCES = main.c
+mount_erofs_CFLAGS = -Wall -I$(top_srcdir)/include
+mount_erofs_LDADD = $(top_builddir)/lib/liberofs.la ${libselinux_LIBS} \
+	${liblz4_LIBS} ${liblzma_LIBS} ${zlib_LIBS} ${libdeflate_LIBS} \
+	${libzstd_LIBS} ${libqpl_LIBS} ${libxxhash_LIBS}
mount/main.c new file +289 -0

289 lines not on this page · raw message

Signature · 1 line
2.43.5