From a0002acc9ca88481c4f8c9a44b76c28b1220c1bf Mon Sep 17 00:00:00 2001 From: xiaoming <2014500726@smail.xtu.edu.cn> Date: Tue, 1 Aug 2023 23:14:18 +0800 Subject: [PATCH] Add JFFS2_COMPR_RTIME support Signed-off-by: xiaoming <2014500726@smail.xtu.edu.cn> --- jffs2extract.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/jffs2extract.c b/jffs2extract.c index 8fadca5..1f9ea3f 100644 --- a/jffs2extract.c +++ b/jffs2extract.c @@ -92,6 +92,38 @@ void visit(char *o, size_t size, const char *path, int verbose, visitor visitor) /* writes file node into buffer, to the proper position. */ /* reading all valid nodes in version order reconstructs the file. */ +static int jffs2_rtime_decompress(unsigned char *data_in, + unsigned char *cpage_out, + uint32_t srclen, uint32_t destlen) +{ + short positions[256]; + int outpos = 0; + int pos=0; + memset(positions,0,sizeof(positions)); + while (outpos= outpos) { + while(repeat) { + cpage_out[outpos++] = cpage_out[backoffs++]; + repeat--; + } + } else { + memcpy(&cpage_out[outpos],&cpage_out[backoffs],repeat); + outpos+=repeat; + } + } + } + return 0; +} + /* b - buffer bsize - buffer size @@ -126,6 +158,12 @@ void putblock(char *b, size_t bsize, size_t * rsize, bzero(b + je32_to_cpu(n->offset), dlen); break; + case JFFS2_COMPR_RTIME: + jffs2_rtime_decompress((unsigned char *) ((char *) n) + sizeof(struct jffs2_raw_inode), + (unsigned char *) (b + je32_to_cpu(n->offset)), + je32_to_cpu(n->csize), je32_to_cpu(n->dsize)); + break; + /* [DYN]RUBIN support required! */ default: