[WIP] [PATCH 8/5] erofs-utils: fuse: move decompress backend to lib
Gao Xiang
hsiangkao at aol.com
Sun Oct 25 02:27:20 AEDT 2020
[ will be folded to the original patch. ]
Signed-off-by: Gao Xiang <hsiangkao at aol.com>
---
fuse/Makefile.am | 3 ---
fuse/read.c | 2 +-
{fuse => include/erofs}/decompress.h | 11 ++---------
lib/Makefile.am | 4 ++--
{fuse => lib}/decompress.c | 16 ++++++++++------
5 files changed, 15 insertions(+), 21 deletions(-)
rename {fuse => include/erofs}/decompress.h (80%)
rename {fuse => lib}/decompress.c (84%)
diff --git a/fuse/Makefile.am b/fuse/Makefile.am
index dc8839c84d73..2b2608f57b03 100644
--- a/fuse/Makefile.am
+++ b/fuse/Makefile.am
@@ -4,9 +4,6 @@
AUTOMAKE_OPTIONS = foreign
bin_PROGRAMS = erofsfuse
erofsfuse_SOURCES = main.c dentry.c getattr.c namei.c read.c init.c open.c readir.c zmap.c
-if ENABLE_LZ4
-erofsfuse_SOURCES += decompress.c
-endif
erofsfuse_CFLAGS = -Wall -Werror \
-I$(top_srcdir)/include \
$(shell pkg-config fuse --cflags) \
diff --git a/fuse/read.c b/fuse/read.c
index 8e332e89478f..11f7e6161f8f 100644
--- a/fuse/read.c
+++ b/fuse/read.c
@@ -17,7 +17,7 @@
#include "namei.h"
#include "erofs/io.h"
#include "init.h"
-#include "decompress.h"
+#include "erofs/decompress.h"
size_t erofs_read_data(struct erofs_vnode *vnode, char *buffer,
size_t size, off_t offset)
diff --git a/fuse/decompress.h b/include/erofs/decompress.h
similarity index 80%
rename from fuse/decompress.h
rename to include/erofs/decompress.h
index 508aabab1664..beaac359b21f 100644
--- a/fuse/decompress.h
+++ b/include/erofs/decompress.h
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: GPL-2.0+ */
/*
- * erofs-utils/fuse/decompress.h
+ * erofs-utils/include/erofs/decompress.h
*
* Copyright (C), 2008-2020, OPPO Mobile Comm Corp., Ltd.
* Created by Huang Jianan <huangjianan at oppo.com>
@@ -8,7 +8,7 @@
#ifndef __EROFS_DECOMPRESS_H
#define __EROFS_DECOMPRESS_H
-#include "erofs/internal.h"
+#include "internal.h"
enum {
Z_EROFS_COMPRESSION_SHIFTED = Z_EROFS_COMPRESSION_MAX,
@@ -30,13 +30,6 @@ struct z_erofs_decompress_req {
bool partial_decoding;
};
-#ifdef LZ4_ENABLED
int z_erofs_decompress(struct z_erofs_decompress_req *rq);
-#else
-int z_erofs_decompress(struct z_erofs_decompress_req *rq)
-{
- return -EOPNOTSUPP;
-}
-#endif
#endif
diff --git a/lib/Makefile.am b/lib/Makefile.am
index e4b51e65f053..c921a62a8b23 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -2,8 +2,8 @@
# Makefile.am
noinst_LTLIBRARIES = liberofs.la
-liberofs_la_SOURCES = config.c io.c cache.c inode.c xattr.c \
- compress.c compressor.c exclude.c
+liberofs_la_SOURCES = config.c io.c cache.c inode.c xattr.c exclude.c \
+ compress.c compressor.c decompress.c
liberofs_la_CFLAGS = -Wall -Werror -I$(top_srcdir)/include
if ENABLE_LZ4
liberofs_la_CFLAGS += ${LZ4_CFLAGS}
diff --git a/fuse/decompress.c b/lib/decompress.c
similarity index 84%
rename from fuse/decompress.c
rename to lib/decompress.c
index 766e6639aa68..870b85430dd1 100644
--- a/fuse/decompress.c
+++ b/lib/decompress.c
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0+
/*
- * erofs-utils/fuse/decompress.c
+ * erofs-utils/lib/decompress.c
*
* Copyright (C), 2008-2020, OPPO Mobile Comm Corp., Ltd.
* Created by Huang Jianan <huangjianan at oppo.com>
@@ -8,12 +8,11 @@
#include <stdlib.h>
#include <lz4.h>
-#include "erofs/internal.h"
+#include "erofs/decompress.h"
#include "erofs/err.h"
-#include "decompress.h"
-#include "init.h"
-static int z_erofs_decompress_generic(struct z_erofs_decompress_req *rq)
+#ifdef LZ4_ENABLED
+static int z_erofs_decompress_lz4(struct z_erofs_decompress_req *rq)
{
int ret = 0;
char *dest = rq->out;
@@ -64,6 +63,7 @@ out:
return ret;
}
+#endif
int z_erofs_decompress(struct z_erofs_decompress_req *rq)
{
@@ -79,5 +79,9 @@ int z_erofs_decompress(struct z_erofs_decompress_req *rq)
return 0;
}
- return z_erofs_decompress_generic(rq);
+#ifdef LZ4_ENABLED
+ if (rq->alg == Z_EROFS_COMPRESSION_LZ4)
+ return z_erofs_decompress_lz4(rq);
+#endif
+ return -EOPNOTSUPP;
}
--
2.24.0
More information about the Linux-erofs
mailing list