Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add JFFS2_COMPR_RTIME support #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions jffs2extract.c
Original file line number Diff line number Diff line change
Expand Up @@ -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<destlen) {
unsigned char value;
int backoffs;
int repeat;
value = data_in[pos++];
cpage_out[outpos++] = value; /* first the verbatim copied byte */
repeat = data_in[pos++];
backoffs = positions[value];
positions[value]=outpos;
if (repeat) {
if (backoffs + repeat >= 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
Expand Down Expand Up @@ -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:
Expand Down