1
0

532-jffs2_eofdetect.patch 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. --- a/fs/jffs2/build.c
  2. +++ b/fs/jffs2/build.c
  3. @@ -116,6 +116,16 @@ static int jffs2_build_filesystem(struct
  4. dbg_fsbuild("scanned flash completely\n");
  5. jffs2_dbg_dump_block_lists_nolock(c);
  6. + if (c->flags & (1 << 7)) {
  7. + printk("%s(): unlocking the mtd device... ", __func__);
  8. + mtd_unlock(c->mtd, 0, c->mtd->size);
  9. + printk("done.\n");
  10. +
  11. + printk("%s(): erasing all blocks after the end marker... ", __func__);
  12. + jffs2_erase_pending_blocks(c, -1);
  13. + printk("done.\n");
  14. + }
  15. +
  16. dbg_fsbuild("pass 1 starting\n");
  17. c->flags |= JFFS2_SB_FLAG_BUILDING;
  18. /* Now scan the directory tree, increasing nlink according to every dirent found. */
  19. --- a/fs/jffs2/scan.c
  20. +++ b/fs/jffs2/scan.c
  21. @@ -148,8 +148,14 @@ int jffs2_scan_medium(struct jffs2_sb_in
  22. /* reset summary info for next eraseblock scan */
  23. jffs2_sum_reset_collected(s);
  24. - ret = jffs2_scan_eraseblock(c, jeb, buf_size?flashbuf:(flashbuf+jeb->offset),
  25. - buf_size, s);
  26. + if (c->flags & (1 << 7)) {
  27. + if (mtd_block_isbad(c->mtd, jeb->offset))
  28. + ret = BLK_STATE_BADBLOCK;
  29. + else
  30. + ret = BLK_STATE_ALLFF;
  31. + } else
  32. + ret = jffs2_scan_eraseblock(c, jeb, buf_size?flashbuf:(flashbuf+jeb->offset),
  33. + buf_size, s);
  34. if (ret < 0)
  35. goto out;
  36. @@ -561,6 +567,17 @@ full_scan:
  37. return err;
  38. }
  39. + if ((buf[0] == 0xde) &&
  40. + (buf[1] == 0xad) &&
  41. + (buf[2] == 0xc0) &&
  42. + (buf[3] == 0xde)) {
  43. + /* end of filesystem. erase everything after this point */
  44. + printk("%s(): End of filesystem marker found at 0x%x\n", __func__, jeb->offset);
  45. + c->flags |= (1 << 7);
  46. +
  47. + return BLK_STATE_ALLFF;
  48. + }
  49. +
  50. /* We temporarily use 'ofs' as a pointer into the buffer/jeb */
  51. ofs = 0;
  52. max_ofs = EMPTY_SCAN_SIZE(c->sector_size);