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 support for compression type 0x15 #19

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
7 changes: 7 additions & 0 deletions jefferson/compression/jffs2_lzma_0x15.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import lzma

def decompress(data, outlen):
lzma_header = data[0:5]
lzma_data = data[0:5] + outlen.to_bytes(8, "little") + data[5:]
decompressed = lzma.decompress(lzma_data)
return decompressed
4 changes: 4 additions & 0 deletions jefferson/jffs2.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from lzallright import LZOCompressor as lzo

import jefferson.compression.jffs2_lzma as jffs2_lzma
import jefferson.compression.jffs2_lzma_0x15 as jffs2_lzma_0x15
import jefferson.compression.rtime as rtime


Expand All @@ -30,6 +31,7 @@ def PAD(x):
JFFS2_COMPR_ZLIB = 0x06
JFFS2_COMPR_LZO = 0x07
JFFS2_COMPR_LZMA = 0x08
JFFS2_COMPR_0x15_LZMA = 0x15

# /* Compatibility flags. */
JFFS2_COMPAT_MASK = 0xC000 # /* What do to if an unknown nodetype is found */
Expand Down Expand Up @@ -181,6 +183,8 @@ def unpack(self, data):
self.data = jffs2_lzma.decompress(node_data, self.dsize)
elif self.compr == JFFS2_COMPR_LZO:
self.data = lzo.decompress(node_data)
elif self.compr == JFFS2_COMPR_0x15_LZMA:
self.data = jffs2_lzma_0x15.decompress(node_data, self.dsize)
else:
print("compression not implemented", self)
print(node_data.hex()[:20])
Expand Down