blob: 46ed644e4d4a6dd795ae70a639484447f660751c [file] [log] [blame]
wdenk5a2543c2002-02-17 23:36:36 +00001#ifndef jffs2_private_h
2#define jffs2_private_h
3
4#include <jffs2/jffs2.h>
5
wdenk6b58f332003-03-14 20:47:52 +00006
wdenk5a2543c2002-02-17 23:36:36 +00007struct b_node {
8 u32 offset;
9 struct b_node *next;
10};
11
wdenk6b58f332003-03-14 20:47:52 +000012struct 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
wdenk5a2543c2002-02-17 23:36:36 +000024struct b_lists {
wdenk6b58f332003-03-14 20:47:52 +000025 struct b_list dir;
26 struct b_list frag;
wdenk5a2543c2002-02-17 23:36:36 +000027
28};
wdenk6b58f332003-03-14 20:47:52 +000029
wdenk5a2543c2002-02-17 23:36:36 +000030struct b_compr_info {
31 u32 num_frags;
32 u32 compr_sum;
33 u32 decompr_sum;
34};
35
36struct b_jffs2_info {
37 struct b_compr_info compr_info[JFFS2_NUM_COMPR];
38};
39
40static inline int
41hdr_crc(struct jffs2_unknown_node *node)
42{
wdenk6b58f332003-03-14 20:47:52 +000043#if 1
wdenk57b2d802003-06-27 21:31:46 +000044 u32 crc = crc32_no_comp(0, (unsigned char *)node, sizeof(struct jffs2_unknown_node) - 4);
wdenk6b58f332003-03-14 20:47:52 +000045#else
46 /* what's the semantics of this? why is this here? */
wdenk57b2d802003-06-27 21:31:46 +000047 u32 crc = crc32_no_comp(~0, (unsigned char *)node, sizeof(struct jffs2_unknown_node) - 4);
wdenk5a2543c2002-02-17 23:36:36 +000048
wdenk57b2d802003-06-27 21:31:46 +000049 crc ^= ~0;
wdenk6b58f332003-03-14 20:47:52 +000050#endif
wdenk57b2d802003-06-27 21:31:46 +000051 if (node->hdr_crc != crc) {
52 return 0;
53 } else {
54 return 1;
55 }
wdenk5a2543c2002-02-17 23:36:36 +000056}
57
58static inline int
59dirent_crc(struct jffs2_raw_dirent *node)
60{
wdenk57b2d802003-06-27 21:31:46 +000061 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 }
wdenk5a2543c2002-02-17 23:36:36 +000066}
67
68static inline int
69dirent_name_crc(struct jffs2_raw_dirent *node)
70{
wdenk57b2d802003-06-27 21:31:46 +000071 if (node->name_crc != crc32_no_comp(0, (unsigned char *)&(node->name), node->nsize)) {
72 return 0;
73 } else {
74 return 1;
75 }
wdenk5a2543c2002-02-17 23:36:36 +000076}
77
78static inline int
79inode_crc(struct jffs2_raw_inode *node)
80{
wdenk57b2d802003-06-27 21:31:46 +000081 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 }
wdenk5a2543c2002-02-17 23:36:36 +000086}
87
Wolfgang Denkdd7e8662006-03-12 16:05:05 +010088static inline int
89data_crc(struct jffs2_raw_inode *node)
90{
91 if (node->data_crc != crc32_no_comp(0, (unsigned char *)
Wolfgang Denk315b46a2006-03-17 11:42:53 +010092 ((int) &node->node_crc + sizeof (node->node_crc)),
93 node->csize)) {
Wolfgang Denkdd7e8662006-03-12 16:05:05 +010094 return 0;
95 } else {
96 return 1;
97 }
98}
99
wdenk5a2543c2002-02-17 23:36:36 +0000100#endif /* jffs2_private.h */