24 #include <linux/kernel.h>
25 #include <linux/types.h>
26 #include <linux/errno.h>
27 #include <linux/string.h>
32 static int jffs2_rtime_compress(
unsigned char *data_in,
33 unsigned char *cpage_out,
40 memset(positions,0,
sizeof(positions));
42 while (pos < (*sourcelen) && outpos <= (*dstlen)-2) {
43 int backpos, runlen=0;
48 cpage_out[outpos++] = data_in[pos++];
50 backpos = positions[
value];
53 while ((backpos < pos) && (pos < (*sourcelen)) &&
54 (data_in[pos]==data_in[backpos++]) && (runlen<255)) {
58 cpage_out[outpos++] = runlen;
73 static int jffs2_rtime_decompress(
unsigned char *data_in,
74 unsigned char *cpage_out,
81 memset(positions,0,
sizeof(positions));
83 while (outpos<destlen) {
88 value = data_in[pos++];
89 cpage_out[outpos++] =
value;
90 repeat = data_in[pos++];
91 backoffs = positions[
value];
93 positions[
value]=outpos;
95 if (backoffs + repeat >= outpos) {
97 cpage_out[outpos++] = cpage_out[backoffs++];
101 memcpy(&cpage_out[outpos],&cpage_out[backoffs],repeat);
113 .compress = &jffs2_rtime_compress,
114 .decompress = &jffs2_rtime_decompress,
115 #ifdef JFFS2_RTIME_DISABLED