]> git.ipfire.org Git - people/ms/u-boot.git/blame - fs/jffs2/jffs2_private.h
arc: add stubs for map_physmem() and unmap_physmem()
[people/ms/u-boot.git] / fs / jffs2 / jffs2_private.h
CommitLineData
5a2543c9
WD
1#ifndef jffs2_private_h
2#define jffs2_private_h
3
4#include <jffs2/jffs2.h>
5
06d01dbe 6
5a2543c9
WD
7struct b_node {
8 u32 offset;
9 struct b_node *next;
142a80ff 10 enum { CRC_UNKNOWN = 0, CRC_OK, CRC_BAD } datacrc;
5a2543c9
WD
11};
12
06d01dbe
WD
13struct b_list {
14 struct b_node *listTail;
15 struct b_node *listHead;
6d0f6bcf 16#ifdef CONFIG_SYS_JFFS2_SORT_FRAGMENTS
06d01dbe
WD
17 struct b_node *listLast;
18 int (*listCompare)(struct b_node *new, struct b_node *node);
19 u32 listLoops;
20#endif
21 u32 listCount;
22 struct mem_block *listMemBase;
23};
24
5a2543c9 25struct b_lists {
06d01dbe
WD
26 struct b_list dir;
27 struct b_list frag;
70741004 28 void *readbuf;
5a2543c9 29};
06d01dbe 30
5a2543c9
WD
31struct b_compr_info {
32 u32 num_frags;
33 u32 compr_sum;
34 u32 decompr_sum;
35};
36
37struct b_jffs2_info {
38 struct b_compr_info compr_info[JFFS2_NUM_COMPR];
39};
40
41static inline int
42hdr_crc(struct jffs2_unknown_node *node)
43{
06d01dbe 44#if 1
8bde7f77 45 u32 crc = crc32_no_comp(0, (unsigned char *)node, sizeof(struct jffs2_unknown_node) - 4);
06d01dbe
WD
46#else
47 /* what's the semantics of this? why is this here? */
8bde7f77 48 u32 crc = crc32_no_comp(~0, (unsigned char *)node, sizeof(struct jffs2_unknown_node) - 4);
5a2543c9 49
8bde7f77 50 crc ^= ~0;
06d01dbe 51#endif
8bde7f77
WD
52 if (node->hdr_crc != crc) {
53 return 0;
54 } else {
55 return 1;
56 }
5a2543c9
WD
57}
58
59static inline int
60dirent_crc(struct jffs2_raw_dirent *node)
61{
8bde7f77
WD
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 }
5a2543c9
WD
67}
68
69static inline int
70dirent_name_crc(struct jffs2_raw_dirent *node)
71{
8bde7f77
WD
72 if (node->name_crc != crc32_no_comp(0, (unsigned char *)&(node->name), node->nsize)) {
73 return 0;
74 } else {
75 return 1;
76 }
5a2543c9
WD
77}
78
79static inline int
80inode_crc(struct jffs2_raw_inode *node)
81{
8bde7f77
WD
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 }
5a2543c9
WD
87}
88
74f92e6a
WD
89static inline int
90data_crc(struct jffs2_raw_inode *node)
91{
92 if (node->data_crc != crc32_no_comp(0, (unsigned char *)
09e4b0c5
WD
93 ((int) &node->node_crc + sizeof (node->node_crc)),
94 node->csize)) {
74f92e6a
WD
95 return 0;
96 } else {
97 return 1;
98 }
99}
100
10d3ac34
MT
101#if defined(CONFIG_SYS_JFFS2_SORT_FRAGMENTS)
102/* External merge sort. */
103int sort_list(struct b_list *list);
104#endif
5a2543c9 105#endif /* jffs2_private.h */