summaryrefslogtreecommitdiff
path: root/jffs2dump.c
diff options
context:
space:
mode:
authorTimo Warns <timo.warns@gmail.com>2014-10-15 21:12:03 +0200
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>2014-11-05 14:57:16 +0200
commit51c918e149ee18399d58add66222cf94dd25d3e8 (patch)
tree8a1f9dad08eec0aab31939a08444dd444a1327ed /jffs2dump.c
parent6eb466a4f34808d29e3a704f6cabc7f70beebdc8 (diff)
mtd-utils: jffs2dump: XATTR and XREF support for content dump
Add support for XATTR and XREF nodes to "dump image content" action of jffs2dump. Signed-off-by: Timo Warns <timo.warns@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Diffstat (limited to 'jffs2dump.c')
-rw-r--r--jffs2dump.c64
1 files changed, 64 insertions, 0 deletions
diff --git a/jffs2dump.c b/jffs2dump.c
index 9e13e98..edac2b2 100644
--- a/jffs2dump.c
+++ b/jffs2dump.c
@@ -285,6 +285,47 @@ void do_dumpcontent (void)
p += PAD(je32_to_cpu (node->d.totlen));
break;
+ case JFFS2_NODETYPE_XATTR:
+ memcpy(name, node->x.data, node->x.name_len);
+ name[node->x.name_len] = '\x00';
+ printf ("%8s Xattr node at 0x%08zx, totlen 0x%08x, xid %5d, version %5d, name_len %3d, name %s\n",
+ obsolete ? "Obsolete" : "",
+ p - data,
+ je32_to_cpu (node->x.totlen),
+ je32_to_cpu (node->x.xid),
+ je32_to_cpu (node->x.version),
+ node->x.name_len,
+ name);
+
+ crc = mtd_crc32 (0, node, sizeof (struct jffs2_raw_xattr) - sizeof (node->x.node_crc));
+ if (crc != je32_to_cpu (node->x.node_crc)) {
+ printf ("Wrong node_crc at 0x%08zx, 0x%08x instead of 0x%08x\n", p - data, je32_to_cpu (node->x.node_crc), crc);
+ p += PAD(je32_to_cpu (node->x.totlen));
+ dirty += PAD(je32_to_cpu (node->x.totlen));
+ continue;
+ }
+
+ crc = mtd_crc32 (0, p + sizeof (struct jffs2_raw_xattr), node->x.name_len + je16_to_cpu (node->x.value_len) + 1);
+ if (crc != je32_to_cpu (node->x.data_crc)) {
+ printf ("Wrong data_crc at 0x%08zx, 0x%08x instead of 0x%08x\n", p - data, je32_to_cpu (node->x.data_crc), crc);
+ p += PAD(je32_to_cpu (node->x.totlen));
+ dirty += PAD(je32_to_cpu (node->x.totlen));
+ continue;
+ }
+ p += PAD(je32_to_cpu (node->x.totlen));
+ break;
+
+ case JFFS2_NODETYPE_XREF:
+ printf ("%8s Xref node at 0x%08zx, totlen 0x%08x, xid %5d, xseqno %5d, #ino %8d\n",
+ obsolete ? "Obsolete" : "",
+ p - data,
+ je32_to_cpu (node->r.totlen),
+ je32_to_cpu (node->r.xid),
+ je32_to_cpu (node->r.xseqno),
+ je32_to_cpu (node->r.ino));
+ p += PAD(je32_to_cpu (node->r.totlen));
+ break;
+
case JFFS2_NODETYPE_SUMMARY: {
int i;
@@ -359,6 +400,29 @@ void do_dumpcontent (void)
break;
}
+ case JFFS2_NODETYPE_XATTR : {
+ struct jffs2_sum_xattr_flash *spx;
+ spx = sp;
+ printf ("%14s Xattr offset 0x%08x, totlen 0x%08x, version %5d, #xid %8d\n",
+ "",
+ je32_to_cpu (spx->offset),
+ je32_to_cpu (spx->totlen),
+ je32_to_cpu (spx->version),
+ je32_to_cpu (spx->xid));
+ sp += JFFS2_SUMMARY_XATTR_SIZE;
+ break;
+ }
+
+ case JFFS2_NODETYPE_XREF : {
+ struct jffs2_sum_xref_flash *spr;
+ spr = sp;
+ printf ("%14s Xref offset 0x%08x\n",
+ "",
+ je32_to_cpu (spr->offset));
+ sp += JFFS2_SUMMARY_XREF_SIZE;
+ break;
+ }
+
default :
printf("Unknown summary node!\n");
break;