jffs2_private.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. #ifndef jffs2_private_h
  2. #define jffs2_private_h
  3. #include <jffs2/jffs2.h>
  4. struct b_node {
  5. u32 offset;
  6. struct b_node *next;
  7. enum { CRC_UNKNOWN = 0, CRC_OK, CRC_BAD } datacrc;
  8. u32 version;
  9. union {
  10. u32 ino; /* for inodes */
  11. u32 pino; /* for dirents */
  12. };
  13. };
  14. struct b_list {
  15. struct b_node *listTail;
  16. struct b_node *listHead;
  17. #ifdef CONFIG_SYS_JFFS2_SORT_FRAGMENTS
  18. struct b_node *listLast;
  19. int (*listCompare)(struct b_node *new, struct b_node *node);
  20. u32 listLoops;
  21. #endif
  22. u32 listCount;
  23. struct mem_block *listMemBase;
  24. };
  25. struct b_lists {
  26. struct b_list dir;
  27. struct b_list frag;
  28. void *readbuf;
  29. };
  30. struct b_compr_info {
  31. u32 num_frags;
  32. u32 compr_sum;
  33. u32 decompr_sum;
  34. };
  35. struct b_jffs2_info {
  36. struct b_compr_info compr_info[JFFS2_NUM_COMPR];
  37. };
  38. static inline int
  39. hdr_crc(struct jffs2_unknown_node *node)
  40. {
  41. #if 1
  42. u32 crc = crc32_no_comp(0, (unsigned char *)node, sizeof(struct jffs2_unknown_node) - 4);
  43. #else
  44. /* what's the semantics of this? why is this here? */
  45. u32 crc = crc32_no_comp(~0, (unsigned char *)node, sizeof(struct jffs2_unknown_node) - 4);
  46. crc ^= ~0;
  47. #endif
  48. if (node->hdr_crc != crc) {
  49. return 0;
  50. } else {
  51. return 1;
  52. }
  53. }
  54. static inline int
  55. dirent_crc(struct jffs2_raw_dirent *node)
  56. {
  57. if (node->node_crc != crc32_no_comp(0, (unsigned char *)node, sizeof(struct jffs2_raw_dirent) - 8)) {
  58. return 0;
  59. } else {
  60. return 1;
  61. }
  62. }
  63. static inline int
  64. dirent_name_crc(struct jffs2_raw_dirent *node)
  65. {
  66. if (node->name_crc != crc32_no_comp(0, (unsigned char *)&(node->name), node->nsize)) {
  67. return 0;
  68. } else {
  69. return 1;
  70. }
  71. }
  72. static inline int
  73. inode_crc(struct jffs2_raw_inode *node)
  74. {
  75. if (node->node_crc != crc32_no_comp(0, (unsigned char *)node, sizeof(struct jffs2_raw_inode) - 8)) {
  76. return 0;
  77. } else {
  78. return 1;
  79. }
  80. }
  81. static inline int
  82. data_crc(struct jffs2_raw_inode *node)
  83. {
  84. if (node->data_crc != crc32_no_comp(0, (unsigned char *)
  85. ((int) &node->node_crc + sizeof (node->node_crc)),
  86. node->csize)) {
  87. return 0;
  88. } else {
  89. return 1;
  90. }
  91. }
  92. #if defined(CONFIG_SYS_JFFS2_SORT_FRAGMENTS)
  93. /* External merge sort. */
  94. int sort_list(struct b_list *list);
  95. #endif
  96. #endif /* jffs2_private.h */