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