jffs2_private.h 1.9 KB

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