jffs2_private.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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_lists {
  9. char *partOffset;
  10. struct b_node *dirListTail;
  11. struct b_node *dirListHead;
  12. u32 dirListCount;
  13. u32 dirListMemBase;
  14. struct b_node *fragListTail;
  15. struct b_node *fragListHead;
  16. u32 fragListCount;
  17. u32 fragListMemBase;
  18. };
  19. struct b_compr_info {
  20. u32 num_frags;
  21. u32 compr_sum;
  22. u32 decompr_sum;
  23. };
  24. struct b_jffs2_info {
  25. struct b_compr_info compr_info[JFFS2_NUM_COMPR];
  26. };
  27. static inline int
  28. hdr_crc(struct jffs2_unknown_node *node)
  29. {
  30. u32 crc = crc32_no_comp(0, (unsigned char *)node, sizeof(struct jffs2_unknown_node) - 4);
  31. u32 crc_blah = crc32_no_comp(~0, (unsigned char *)node, sizeof(struct jffs2_unknown_node) - 4);
  32. crc_blah ^= ~0;
  33. if (node->hdr_crc != crc) {
  34. return 0;
  35. } else {
  36. return 1;
  37. }
  38. }
  39. static inline int
  40. dirent_crc(struct jffs2_raw_dirent *node)
  41. {
  42. if (node->node_crc != crc32_no_comp(0, (unsigned char *)node, sizeof(struct jffs2_raw_dirent) - 8)) {
  43. return 0;
  44. } else {
  45. return 1;
  46. }
  47. }
  48. static inline int
  49. dirent_name_crc(struct jffs2_raw_dirent *node)
  50. {
  51. if (node->name_crc != crc32_no_comp(0, (unsigned char *)&(node->name), node->nsize)) {
  52. return 0;
  53. } else {
  54. return 1;
  55. }
  56. }
  57. static inline int
  58. inode_crc(struct jffs2_raw_inode *node)
  59. {
  60. if (node->node_crc != crc32_no_comp(0, (unsigned char *)node, sizeof(struct jffs2_raw_inode) - 8)) {
  61. return 0;
  62. } else {
  63. return 1;
  64. }
  65. }
  66. #endif /* jffs2_private.h */