2002-02-18 07:36:36 +08:00
|
|
|
#ifndef jffs2_private_h
|
|
|
|
#define jffs2_private_h
|
|
|
|
|
|
|
|
#include <jffs2/jffs2.h>
|
|
|
|
|
2003-03-15 04:47:52 +08:00
|
|
|
|
2002-02-18 07:36:36 +08:00
|
|
|
struct b_node {
|
|
|
|
u32 offset;
|
|
|
|
struct b_node *next;
|
2008-11-14 00:49:36 +08:00
|
|
|
enum { CRC_UNKNOWN = 0, CRC_OK, CRC_BAD } datacrc;
|
2002-02-18 07:36:36 +08:00
|
|
|
};
|
|
|
|
|
2003-03-15 04:47:52 +08:00
|
|
|
struct b_list {
|
|
|
|
struct b_node *listTail;
|
|
|
|
struct b_node *listHead;
|
2008-10-16 21:01:15 +08:00
|
|
|
#ifdef CONFIG_SYS_JFFS2_SORT_FRAGMENTS
|
2003-03-15 04:47:52 +08:00
|
|
|
struct b_node *listLast;
|
|
|
|
int (*listCompare)(struct b_node *new, struct b_node *node);
|
|
|
|
u32 listLoops;
|
|
|
|
#endif
|
|
|
|
u32 listCount;
|
|
|
|
struct mem_block *listMemBase;
|
|
|
|
};
|
|
|
|
|
2002-02-18 07:36:36 +08:00
|
|
|
struct b_lists {
|
2003-03-15 04:47:52 +08:00
|
|
|
struct b_list dir;
|
|
|
|
struct b_list frag;
|
2008-11-14 00:49:34 +08:00
|
|
|
void *readbuf;
|
2002-02-18 07:36:36 +08:00
|
|
|
};
|
2003-03-15 04:47:52 +08:00
|
|
|
|
2002-02-18 07:36:36 +08:00
|
|
|
struct b_compr_info {
|
|
|
|
u32 num_frags;
|
|
|
|
u32 compr_sum;
|
|
|
|
u32 decompr_sum;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct b_jffs2_info {
|
|
|
|
struct b_compr_info compr_info[JFFS2_NUM_COMPR];
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline int
|
|
|
|
hdr_crc(struct jffs2_unknown_node *node)
|
|
|
|
{
|
2003-03-15 04:47:52 +08:00
|
|
|
#if 1
|
2003-06-28 05:31:46 +08:00
|
|
|
u32 crc = crc32_no_comp(0, (unsigned char *)node, sizeof(struct jffs2_unknown_node) - 4);
|
2003-03-15 04:47:52 +08:00
|
|
|
#else
|
|
|
|
/* what's the semantics of this? why is this here? */
|
2003-06-28 05:31:46 +08:00
|
|
|
u32 crc = crc32_no_comp(~0, (unsigned char *)node, sizeof(struct jffs2_unknown_node) - 4);
|
2002-02-18 07:36:36 +08:00
|
|
|
|
2003-06-28 05:31:46 +08:00
|
|
|
crc ^= ~0;
|
2003-03-15 04:47:52 +08:00
|
|
|
#endif
|
2003-06-28 05:31:46 +08:00
|
|
|
if (node->hdr_crc != crc) {
|
|
|
|
return 0;
|
|
|
|
} else {
|
|
|
|
return 1;
|
|
|
|
}
|
2002-02-18 07:36:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline int
|
|
|
|
dirent_crc(struct jffs2_raw_dirent *node)
|
|
|
|
{
|
2003-06-28 05:31:46 +08:00
|
|
|
if (node->node_crc != crc32_no_comp(0, (unsigned char *)node, sizeof(struct jffs2_raw_dirent) - 8)) {
|
|
|
|
return 0;
|
|
|
|
} else {
|
|
|
|
return 1;
|
|
|
|
}
|
2002-02-18 07:36:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline int
|
|
|
|
dirent_name_crc(struct jffs2_raw_dirent *node)
|
|
|
|
{
|
2003-06-28 05:31:46 +08:00
|
|
|
if (node->name_crc != crc32_no_comp(0, (unsigned char *)&(node->name), node->nsize)) {
|
|
|
|
return 0;
|
|
|
|
} else {
|
|
|
|
return 1;
|
|
|
|
}
|
2002-02-18 07:36:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline int
|
|
|
|
inode_crc(struct jffs2_raw_inode *node)
|
|
|
|
{
|
2003-06-28 05:31:46 +08:00
|
|
|
if (node->node_crc != crc32_no_comp(0, (unsigned char *)node, sizeof(struct jffs2_raw_inode) - 8)) {
|
|
|
|
return 0;
|
|
|
|
} else {
|
|
|
|
return 1;
|
|
|
|
}
|
2002-02-18 07:36:36 +08:00
|
|
|
}
|
|
|
|
|
2006-03-12 23:05:05 +08:00
|
|
|
static inline int
|
|
|
|
data_crc(struct jffs2_raw_inode *node)
|
|
|
|
{
|
|
|
|
if (node->data_crc != crc32_no_comp(0, (unsigned char *)
|
2006-03-17 18:42:53 +08:00
|
|
|
((int) &node->node_crc + sizeof (node->node_crc)),
|
|
|
|
node->csize)) {
|
2006-03-12 23:05:05 +08:00
|
|
|
return 0;
|
|
|
|
} else {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-02-18 07:36:36 +08:00
|
|
|
#endif /* jffs2_private.h */
|