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 | |
wdenk | 6b58f33 | 2003-03-14 20:47:52 +0000 | [diff] [blame] | 6 | |
wdenk | 5a2543c | 2002-02-17 23:36:36 +0000 | [diff] [blame] | 7 | struct b_node { |
| 8 | u32 offset; |
| 9 | struct b_node *next; |
| 10 | }; |
| 11 | |
wdenk | 6b58f33 | 2003-03-14 20:47:52 +0000 | [diff] [blame] | 12 | struct b_list { |
| 13 | struct b_node *listTail; |
| 14 | struct b_node *listHead; |
| 15 | #ifdef CFG_JFFS2_SORT_FRAGMENTS |
| 16 | struct b_node *listLast; |
| 17 | int (*listCompare)(struct b_node *new, struct b_node *node); |
| 18 | u32 listLoops; |
| 19 | #endif |
| 20 | u32 listCount; |
| 21 | struct mem_block *listMemBase; |
| 22 | }; |
| 23 | |
wdenk | 5a2543c | 2002-02-17 23:36:36 +0000 | [diff] [blame] | 24 | struct b_lists { |
wdenk | 6b58f33 | 2003-03-14 20:47:52 +0000 | [diff] [blame] | 25 | struct b_list dir; |
| 26 | struct b_list frag; |
wdenk | 5a2543c | 2002-02-17 23:36:36 +0000 | [diff] [blame] | 27 | |
| 28 | }; |
wdenk | 6b58f33 | 2003-03-14 20:47:52 +0000 | [diff] [blame] | 29 | |
wdenk | 5a2543c | 2002-02-17 23:36:36 +0000 | [diff] [blame] | 30 | struct b_compr_info { |
| 31 | u32 num_frags; |
| 32 | u32 compr_sum; |
| 33 | u32 decompr_sum; |
| 34 | }; |
| 35 | |
| 36 | struct b_jffs2_info { |
| 37 | struct b_compr_info compr_info[JFFS2_NUM_COMPR]; |
| 38 | }; |
| 39 | |
| 40 | static inline int |
| 41 | hdr_crc(struct jffs2_unknown_node *node) |
| 42 | { |
wdenk | 6b58f33 | 2003-03-14 20:47:52 +0000 | [diff] [blame] | 43 | #if 1 |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 44 | u32 crc = crc32_no_comp(0, (unsigned char *)node, sizeof(struct jffs2_unknown_node) - 4); |
wdenk | 6b58f33 | 2003-03-14 20:47:52 +0000 | [diff] [blame] | 45 | #else |
| 46 | /* what's the semantics of this? why is this here? */ |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 47 | u32 crc = crc32_no_comp(~0, (unsigned char *)node, sizeof(struct jffs2_unknown_node) - 4); |
wdenk | 5a2543c | 2002-02-17 23:36:36 +0000 | [diff] [blame] | 48 | |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 49 | crc ^= ~0; |
wdenk | 6b58f33 | 2003-03-14 20:47:52 +0000 | [diff] [blame] | 50 | #endif |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 51 | if (node->hdr_crc != crc) { |
| 52 | return 0; |
| 53 | } else { |
| 54 | return 1; |
| 55 | } |
wdenk | 5a2543c | 2002-02-17 23:36:36 +0000 | [diff] [blame] | 56 | } |
| 57 | |
| 58 | static inline int |
| 59 | dirent_crc(struct jffs2_raw_dirent *node) |
| 60 | { |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 61 | if (node->node_crc != crc32_no_comp(0, (unsigned char *)node, sizeof(struct jffs2_raw_dirent) - 8)) { |
| 62 | return 0; |
| 63 | } else { |
| 64 | return 1; |
| 65 | } |
wdenk | 5a2543c | 2002-02-17 23:36:36 +0000 | [diff] [blame] | 66 | } |
| 67 | |
| 68 | static inline int |
| 69 | dirent_name_crc(struct jffs2_raw_dirent *node) |
| 70 | { |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 71 | if (node->name_crc != crc32_no_comp(0, (unsigned char *)&(node->name), node->nsize)) { |
| 72 | return 0; |
| 73 | } else { |
| 74 | return 1; |
| 75 | } |
wdenk | 5a2543c | 2002-02-17 23:36:36 +0000 | [diff] [blame] | 76 | } |
| 77 | |
| 78 | static inline int |
| 79 | inode_crc(struct jffs2_raw_inode *node) |
| 80 | { |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 81 | if (node->node_crc != crc32_no_comp(0, (unsigned char *)node, sizeof(struct jffs2_raw_inode) - 8)) { |
| 82 | return 0; |
| 83 | } else { |
| 84 | return 1; |
| 85 | } |
wdenk | 5a2543c | 2002-02-17 23:36:36 +0000 | [diff] [blame] | 86 | } |
| 87 | |
Wolfgang Denk | dd7e866 | 2006-03-12 16:05:05 +0100 | [diff] [blame] | 88 | static inline int |
| 89 | data_crc(struct jffs2_raw_inode *node) |
| 90 | { |
| 91 | if (node->data_crc != crc32_no_comp(0, (unsigned char *) |
Wolfgang Denk | 315b46a | 2006-03-17 11:42:53 +0100 | [diff] [blame] | 92 | ((int) &node->node_crc + sizeof (node->node_crc)), |
| 93 | node->csize)) { |
Wolfgang Denk | dd7e866 | 2006-03-12 16:05:05 +0100 | [diff] [blame] | 94 | return 0; |
| 95 | } else { |
| 96 | return 1; |
| 97 | } |
| 98 | } |
| 99 | |
wdenk | 5a2543c | 2002-02-17 23:36:36 +0000 | [diff] [blame] | 100 | #endif /* jffs2_private.h */ |