glamo-regs.patch
[u-boot-openmoko/mini2440.git] / fs / jffs2 / jffs2_nand_private.h
blob18cca8d076e440f998939cb6b40c8c39b4b090ae
1 #ifndef jffs2_private_h
2 #define jffs2_private_h
4 #include <jffs2/jffs2.h>
6 struct b_node {
7 struct b_node *next;
8 };
10 struct b_inode {
11 struct b_inode *next;
12 u32 offset; /* physical offset to beginning of real inode */
13 u32 version;
14 u32 ino;
15 u32 isize;
16 u32 csize;
19 struct b_dirent {
20 struct b_dirent *next;
21 u32 offset; /* physical offset to beginning of real dirent */
22 u32 version;
23 u32 pino;
24 u32 ino;
25 unsigned int nhash;
26 unsigned char nsize;
27 unsigned char type;
30 struct b_list {
31 struct b_node *listTail;
32 struct b_node *listHead;
33 unsigned int listCount;
34 struct mem_block *listMemBase;
37 struct b_lists {
38 char *partOffset;
39 struct b_list dir;
40 struct b_list frag;
43 struct b_compr_info {
44 u32 num_frags;
45 u32 compr_sum;
46 u32 decompr_sum;
49 struct b_jffs2_info {
50 struct b_compr_info compr_info[JFFS2_NUM_COMPR];
53 static inline int
54 hdr_crc(struct jffs2_unknown_node *node)
56 #if 1
57 u32 crc = crc32_no_comp(0, (unsigned char *)node, sizeof(struct jffs2_unknown_node) - 4);
58 #else
59 /* what's the semantics of this? why is this here? */
60 u32 crc = crc32_no_comp(~0, (unsigned char *)node, sizeof(struct jffs2_unknown_node) - 4);
62 crc ^= ~0;
63 #endif
64 if (node->hdr_crc != crc) {
65 return 0;
66 } else {
67 return 1;
71 static inline int
72 dirent_crc(struct jffs2_raw_dirent *node)
74 if (node->node_crc != crc32_no_comp(0, (unsigned char *)node, sizeof(struct jffs2_raw_dirent) - 8)) {
75 return 0;
76 } else {
77 return 1;
81 static inline int
82 dirent_name_crc(struct jffs2_raw_dirent *node)
84 if (node->name_crc != crc32_no_comp(0, (unsigned char *)&(node->name), node->nsize)) {
85 return 0;
86 } else {
87 return 1;
91 static inline int
92 inode_crc(struct jffs2_raw_inode *node)
94 if (node->node_crc != crc32_no_comp(0, (unsigned char *)node, sizeof(struct jffs2_raw_inode) - 8)) {
95 return 0;
96 } else {
97 return 1;
101 /* Borrowed from include/linux/dcache.h */
103 /* Name hashing routines. Initial hash value */
104 /* Hash courtesy of the R5 hash in reiserfs modulo sign bits */
105 #define init_name_hash() 0
107 /* partial hash update function. Assume roughly 4 bits per character */
108 static inline unsigned long
109 partial_name_hash(unsigned long c, unsigned long prevhash)
111 return (prevhash + (c << 4) + (c >> 4)) * 11;
115 * Finally: cut down the number of bits to a int value (and try to avoid
116 * losing bits)
118 static inline unsigned long end_name_hash(unsigned long hash)
120 return (unsigned int) hash;
123 /* Compute the hash for a name string. */
124 static inline unsigned int
125 full_name_hash(const unsigned char *name, unsigned int len)
127 unsigned long hash = init_name_hash();
128 while (len--)
129 hash = partial_name_hash(*name++, hash);
130 return end_name_hash(hash);
133 #endif /* jffs2_private.h */