Skip to content

Commit

Permalink
Merge pull request #44 from sviehb/fix-inode-versioning
Browse files Browse the repository at this point in the history
Fix extraction of files with size greater than one erase block.
  • Loading branch information
qkaiser authored Jun 23, 2022
2 parents ddbc592 + 5d8e2f0 commit 361c6e3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from distutils.core import setup

version = "0.3"
version = "0.4"

setup(
name="jefferson",
Expand Down
13 changes: 7 additions & 6 deletions src/scripts/jefferson
Original file line number Diff line number Diff line change
Expand Up @@ -318,10 +318,9 @@ def scan_fs(content, endianness, verbose=False):
inode.unpack(content_mv[0 + offset :])

if inode.ino in fs[JFFS2_NODETYPE_INODE]:
if inode.version > fs[JFFS2_NODETYPE_INODE][inode.ino].version:
fs[JFFS2_NODETYPE_INODE][inode.ino] = inode
fs[JFFS2_NODETYPE_INODE][inode.ino].append(inode)
else:
fs[JFFS2_NODETYPE_INODE][inode.ino] = inode
fs[JFFS2_NODETYPE_INODE][inode.ino] = [inode]
if verbose:
print("0x%08X:" % (offset), inode)
elif unknown_node.nodetype == JFFS2_NODETYPE_CLEANMARKER:
Expand Down Expand Up @@ -358,15 +357,17 @@ def get_device(inode):
return os.makedev((node.old_id >> 8) & 0xFF, node.old_id & 0xFF)
return None

def sort_version(item):
return item.version

def dump_fs(fs, target):
node_dict = {}

for dirent in fs[JFFS2_NODETYPE_DIRENT].values():
dirent.inodes = []
for inode in fs[JFFS2_NODETYPE_INODE].values():
if inode.ino == dirent.ino:
dirent.inodes.append(inode)
for ino, inodes in fs[JFFS2_NODETYPE_INODE].items():
if ino == dirent.ino:
dirent.inodes = sorted(inodes, key=sort_version)
node_dict[dirent.ino] = dirent

for dirent in fs[JFFS2_NODETYPE_DIRENT].values():
Expand Down

0 comments on commit 361c6e3

Please sign in to comment.