[WIP] [PATCH 09/12] erofs-utils: fuse: rename ofs_head and outputsize
Gao Xiang
hsiangkao at aol.com
Sat Oct 17 16:16:18 AEDT 2020
[ let's fold in to the original patch. ]
Signed-off-by: Gao Xiang <hsiangkao at aol.com>
---
fuse/decompress.c | 27 +++++++++++++--------------
fuse/decompress.h | 8 ++++++--
fuse/read.c | 4 ++--
3 files changed, 21 insertions(+), 18 deletions(-)
diff --git a/fuse/decompress.c b/fuse/decompress.c
index d3ee3677e9a3..fc12852ac6b7 100644
--- a/fuse/decompress.c
+++ b/fuse/decompress.c
@@ -33,8 +33,8 @@ static int z_erofs_decompress_generic(struct z_erofs_decompress_req *rq)
return -EIO;
}
- if (rq->ofs_head) {
- buff = malloc(rq->outputsize);
+ if (rq->decodedskip) {
+ buff = malloc(rq->decodedlength);
if (!buff)
return -ENOMEM;
dest = buff;
@@ -42,22 +42,21 @@ static int z_erofs_decompress_generic(struct z_erofs_decompress_req *rq)
if (rq->partial_decoding || !support_0padding)
ret = LZ4_decompress_safe_partial(src + inputmargin, dest,
- rq->inputsize - inputmargin,
- rq->outputsize, rq->outputsize);
+ rq->inputsize - inputmargin,
+ rq->decodedlength, rq->decodedlength);
else
ret = LZ4_decompress_safe(src + inputmargin, dest,
rq->inputsize - inputmargin,
- rq->outputsize);
+ rq->decodedlength);
- if (ret != (int)rq->outputsize) {
+ if (ret != (int)rq->decodedlength) {
ret = -EIO;
goto out;
}
- if (rq->ofs_head) {
- src = dest + rq->ofs_head;
- memcpy(rq->out, src, rq->outputsize - rq->ofs_head);
- }
+ if (rq->decodedskip)
+ memcpy(rq->out, dest + rq->decodedskip,
+ rq->decodedlength - rq->decodedskip);
out:
if (buff)
@@ -72,11 +71,11 @@ int z_erofs_decompress(struct z_erofs_decompress_req *rq)
if (rq->inputsize != EROFS_BLKSIZ)
return -EFSCORRUPTED;
- DBG_BUGON(rq->outputsize > EROFS_BLKSIZ);
- DBG_BUGON(rq->outputsize < rq->ofs_head);
+ DBG_BUGON(rq->decodedlength > EROFS_BLKSIZ);
+ DBG_BUGON(rq->decodedlength < rq->decodedskip);
- memcpy(rq->out, rq->in + rq->ofs_head,
- rq->outputsize - rq->ofs_head);
+ memcpy(rq->out, rq->in + rq->decodedskip,
+ rq->decodedlength - rq->decodedskip);
return 0;
}
diff --git a/fuse/decompress.h b/fuse/decompress.h
index 5a3e2356dc1b..7d436f18da86 100644
--- a/fuse/decompress.h
+++ b/fuse/decompress.h
@@ -17,8 +17,12 @@ enum {
struct z_erofs_decompress_req {
char *in, *out;
- size_t ofs_head;
- unsigned int inputsize, outputsize;
+ /*
+ * initial decompressed bytes that need to be skipped
+ * when finally copying to output buffer
+ */
+ unsigned int decodedskip;
+ unsigned int inputsize, decodedlength;
/* indicate the algorithm will be used for decompression */
unsigned int alg;
diff --git a/fuse/read.c b/fuse/read.c
index 06ca08587e7c..46be5cc64a90 100644
--- a/fuse/read.c
+++ b/fuse/read.c
@@ -136,9 +136,9 @@ size_t erofs_read_data_compression(struct erofs_vnode *vnode, char *buffer,
ret = z_erofs_decompress(&(struct z_erofs_decompress_req) {
.in = raw,
.out = buffer + sum,
- .ofs_head = ofs,
+ .decodedskip = ofs,
.inputsize = EROFS_BLKSIZ,
- .outputsize = count,
+ .decodedlength = count,
.alg = algorithmformat,
.partial_decoding = partial
});
--
2.24.0
More information about the Linux-erofs
mailing list