jffs2_private.h 2.0 KB

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