Re: [U-Boot] [PATCH 5/6] jffs2: summary support

2008-12-09 Thread Wolfgang Denk
Dear Ilya Yanok,

In message [EMAIL PROTECTED] you wrote:
 This patch adds support for reading fs information from summary
 node instead of scanning full eraseblock.
 
 Signed-off-by: Ilya Yanok [EMAIL PROTECTED]
 ---
  fs/jffs2/jffs2_1pass.c |  187 
 +++-
  fs/jffs2/summary.h |  163 +
  include/jffs2/jffs2.h  |   19 +
  3 files changed, 368 insertions(+), 1 deletions(-)
  create mode 100644 fs/jffs2/summary.h

Applied, thanks.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH, MD: Wolfgang Denk  Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: [EMAIL PROTECTED]
Humans do claim a great deal for that particular emotion (love).
-- Spock, The Lights of Zetar, stardate 5725.6
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 5/6] jffs2: summary support

2008-11-13 Thread Ilya Yanok
This patch adds support for reading fs information from summary
node instead of scanning full eraseblock.

Signed-off-by: Ilya Yanok [EMAIL PROTECTED]
---
 fs/jffs2/jffs2_1pass.c |  187 +++-
 fs/jffs2/summary.h |  163 +
 include/jffs2/jffs2.h  |   19 +
 3 files changed, 368 insertions(+), 1 deletions(-)
 create mode 100644 fs/jffs2/summary.h

diff --git a/fs/jffs2/jffs2_1pass.c b/fs/jffs2/jffs2_1pass.c
index 73d3ddc..4e49a05 100644
--- a/fs/jffs2/jffs2_1pass.c
+++ b/fs/jffs2/jffs2_1pass.c
@@ -138,6 +138,8 @@
 # define DEBUGF(fmt,args...)
 #endif
 
+#include summary.h
+
 /* keeps pointer to currentlu processed partition */
 static struct part_info *current_part;
 
@@ -1214,6 +1216,132 @@ jffs2_1pass_rescan_needed(struct part_info *part)
return 0;
 }
 
+#define dbg_summary(...) do {} while (0);
+/* Process the stored summary information - helper function for
+ * jffs2_sum_scan_sumnode()
+ */
+
+static int jffs2_sum_process_sum_data(struct part_info *part, uint32_t offset,
+   struct jffs2_raw_summary *summary,
+   struct b_lists *pL)
+{
+   void *sp;
+   int i;
+
+   sp = summary-sum;
+
+   for (i = 0; i  summary-sum_num; i++) {
+   dbg_summary(processing summary index %d\n, i);
+
+   switch (((struct jffs2_sum_unknown_flash *)sp)-nodetype) {
+   case JFFS2_NODETYPE_INODE: {
+   struct jffs2_sum_inode_flash *spi;
+   spi = sp;
+
+   dbg_summary(Inode at 0x%08x-0x%08x\n,
+   offset + spi-offset,
+   offset + spi-offset + spi-totlen);
+
+   if (insert_node(pL-frag, (u32) part-offset +
+   offset + spi-offset) == NULL)
+   return -1;
+
+   sp += JFFS2_SUMMARY_INODE_SIZE;
+
+   break;
+   }
+
+   case JFFS2_NODETYPE_DIRENT: {
+   struct jffs2_sum_dirent_flash *spd;
+   spd = sp;
+
+   dbg_summary(Dirent at 0x%08x-0x%08x\n,
+   offset + spd-offset,
+   offset + spd-offset + spd-totlen);
+
+   if (insert_node(pL-dir, (u32) part-offset +
+   offset + spd-offset) == NULL)
+   return -1;
+
+   sp += JFFS2_SUMMARY_DIRENT_SIZE(spd-nsize);
+
+   break;
+   }
+   default : {
+   uint16_t nodetype =
+   ((struct jffs2_sum_unknown_flash *)
+sp)-nodetype;
+   printf(Unsupported node type %x found in 
+   summary!\n, nodetype);
+   break;
+   }
+   }
+   }
+   return 0;
+}
+
+/* Process the summary node - called from jffs2_scan_eraseblock() */
+int jffs2_sum_scan_sumnode(struct part_info *part, uint32_t offset,
+  struct jffs2_raw_summary *summary, uint32_t sumsize,
+  struct b_lists *pL)
+{
+   struct jffs2_unknown_node crcnode;
+   int ret, ofs;
+   uint32_t crc;
+
+   ofs = part-sector_size - sumsize;
+
+   dbg_summary(summary found for 0x%08x at 0x%08x (0x%x bytes)\n,
+   offset, offset + ofs, sumsize);
+
+   /* OK, now check for node validity and CRC */
+   crcnode.magic = JFFS2_MAGIC_BITMASK;
+   crcnode.nodetype = JFFS2_NODETYPE_SUMMARY;
+   crcnode.totlen = summary-totlen;
+   crc = crc32_no_comp(0, (uchar *)crcnode, sizeof(crcnode)-4);
+
+   if (summary-hdr_crc != crc) {
+   dbg_summary(Summary node header is corrupt (bad CRC or 
+   no summary at all)\n);
+   goto crc_err;
+   }
+
+   if (summary-totlen != sumsize) {
+   dbg_summary(Summary node is corrupt (wrong erasesize?)\n);
+   goto crc_err;
+   }
+
+   crc = crc32_no_comp(0, (uchar *)summary,
+   sizeof(struct jffs2_raw_summary)-8);
+
+   if (summary-node_crc != crc) {
+   dbg_summary(Summary node is corrupt (bad CRC)\n);
+   goto crc_err;
+   }
+
+   crc = crc32_no_comp(0, (uchar *)summary-sum,
+   sumsize - sizeof(struct jffs2_raw_summary));
+
+   if (summary-sum_crc != crc) {
+