jffs2_private.h 1.8 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 CFG_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. };
  23. struct b_compr_info {
  24. u32 num_frags;
  25. u32 compr_sum;
  26. u32 decompr_sum;
  27. };
  28. struct b_jffs2_info {
  29. struct b_compr_info compr_info[JFFS2_NUM_COMPR];
  30. };
  31. static inline int
  32. hdr_crc(struct jffs2_unknown_node *node)
  33. {
  34. #if 1
  35. u32 crc = crc32_no_comp(0, (unsigned char *)node, sizeof(struct jffs2_unknown_node) - 4);
  36. #else
  37. /* what's the semantics of this? why is this here? */
  38. u32 crc = crc32_no_comp(~0, (unsigned char *)node, sizeof(struct jffs2_unknown_node) - 4);
  39. crc ^= ~0;
  40. #endif
  41. if (node->hdr_crc != crc) {
  42. return 0;
  43. } else {
  44. return 1;
  45. }
  46. }
  47. static inline int
  48. dirent_crc(struct jffs2_raw_dirent *node)
  49. {
  50. if (node->node_crc != crc32_no_comp(0, (unsigned char *)node, sizeof(struct jffs2_raw_dirent) - 8)) {
  51. return 0;
  52. } else {
  53. return 1;
  54. }
  55. }
  56. static inline int
  57. dirent_name_crc(struct jffs2_raw_dirent *node)
  58. {
  59. if (node->name_crc != crc32_no_comp(0, (unsigned char *)&(node->name), node->nsize)) {
  60. return 0;
  61. } else {
  62. return 1;
  63. }
  64. }
  65. static inline int
  66. inode_crc(struct jffs2_raw_inode *node)
  67. {
  68. if (node->node_crc != crc32_no_comp(0, (unsigned char *)node, sizeof(struct jffs2_raw_inode) - 8)) {
  69. return 0;
  70. } else {
  71. return 1;
  72. }
  73. }
  74. static inline int
  75. data_crc(struct jffs2_raw_inode *node)
  76. {
  77. if (node->data_crc != crc32_no_comp(0, (unsigned char *)
  78. ((int) &node->node_crc + sizeof (node->node_crc)),
  79. node->csize)) {
  80. return 0;
  81. } else {
  82. return 1;
  83. }
  84. }
  85. #endif /* jffs2_private.h */