wdenk | 5a2543c | 2002-02-17 23:36:36 +0000 | [diff] [blame^] | 1 | #ifndef jffs2_private_h |
| 2 | #define jffs2_private_h |
| 3 | |
| 4 | #include <jffs2/jffs2.h> |
| 5 | |
| 6 | struct b_node { |
| 7 | u32 offset; |
| 8 | struct b_node *next; |
| 9 | }; |
| 10 | |
| 11 | struct b_lists { |
| 12 | char *partOffset; |
| 13 | struct b_node *dirListTail; |
| 14 | struct b_node *dirListHead; |
| 15 | u32 dirListCount; |
| 16 | u32 dirListMemBase; |
| 17 | struct b_node *fragListTail; |
| 18 | struct b_node *fragListHead; |
| 19 | u32 fragListCount; |
| 20 | u32 fragListMemBase; |
| 21 | |
| 22 | }; |
| 23 | struct b_compr_info { |
| 24 | u32 num_frags; |
| 25 | u32 compr_sum; |
| 26 | u32 decompr_sum; |
| 27 | }; |
| 28 | |
| 29 | struct b_jffs2_info { |
| 30 | struct b_compr_info compr_info[JFFS2_NUM_COMPR]; |
| 31 | }; |
| 32 | |
| 33 | static inline int |
| 34 | hdr_crc(struct jffs2_unknown_node *node) |
| 35 | { |
| 36 | u32 crc = crc32_no_comp(0, (unsigned char *)node, sizeof(struct jffs2_unknown_node) - 4); |
| 37 | u32 crc_blah = crc32_no_comp(~0, (unsigned char *)node, sizeof(struct jffs2_unknown_node) - 4); |
| 38 | |
| 39 | crc_blah ^= ~0; |
| 40 | |
| 41 | if (node->hdr_crc != crc) { |
| 42 | return 0; |
| 43 | } else { |
| 44 | return 1; |
| 45 | } |
| 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 | |
| 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 | |
| 68 | static inline int |
| 69 | inode_crc(struct jffs2_raw_inode *node) |
| 70 | { |
| 71 | if (node->node_crc != crc32_no_comp(0, (unsigned char *)node, sizeof(struct jffs2_raw_inode) - 8)) { |
| 72 | return 0; |
| 73 | } else { |
| 74 | return 1; |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | #endif /* jffs2_private.h */ |