uboot/fs/jffs2/jffs2_nand_private.h
<<
>>
Prefs
   1#ifndef jffs2_private_h
   2#define jffs2_private_h
   3
   4#include <jffs2/jffs2.h>
   5
   6struct b_node {
   7        struct b_node *next;
   8};
   9
  10struct 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;
  17};
  18
  19struct 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;
  28};
  29
  30struct b_list {
  31        struct b_node *listTail;
  32        struct b_node *listHead;
  33        unsigned int listCount;
  34        struct mem_block *listMemBase;
  35};
  36
  37struct b_lists {
  38        char *partOffset;
  39        struct b_list dir;
  40        struct b_list frag;
  41};
  42
  43struct b_compr_info {
  44        u32 num_frags;
  45        u32 compr_sum;
  46        u32 decompr_sum;
  47};
  48
  49struct b_jffs2_info {
  50        struct b_compr_info compr_info[JFFS2_NUM_COMPR];
  51};
  52
  53static inline int
  54hdr_crc(struct jffs2_unknown_node *node)
  55{
  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);
  61
  62        crc ^= ~0;
  63#endif
  64        if (node->hdr_crc != crc) {
  65                return 0;
  66        } else {
  67                return 1;
  68        }
  69}
  70
  71static inline int
  72dirent_crc(struct jffs2_raw_dirent *node)
  73{
  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;
  78        }
  79}
  80
  81static inline int
  82dirent_name_crc(struct jffs2_raw_dirent *node)
  83{
  84        if (node->name_crc != crc32_no_comp(0, (unsigned char *)&(node->name), node->nsize)) {
  85                return 0;
  86        } else {
  87                return 1;
  88        }
  89}
  90
  91static inline int
  92inode_crc(struct jffs2_raw_inode *node)
  93{
  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;
  98        }
  99}
 100
 101/* Borrowed from include/linux/dcache.h */
 102
 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
 106
 107/* partial hash update function. Assume roughly 4 bits per character */
 108static inline unsigned long
 109partial_name_hash(unsigned long c, unsigned long prevhash)
 110{
 111        return (prevhash + (c << 4) + (c >> 4)) * 11;
 112}
 113
 114/*
 115 * Finally: cut down the number of bits to a int value (and try to avoid
 116 * losing bits)
 117 */
 118static inline unsigned long end_name_hash(unsigned long hash)
 119{
 120        return (unsigned int) hash;
 121}
 122
 123/* Compute the hash for a name string. */
 124static inline unsigned int
 125full_name_hash(const unsigned char *name, unsigned int len)
 126{
 127        unsigned long hash = init_name_hash();
 128        while (len--)
 129                hash = partial_name_hash(*name++, hash);
 130        return end_name_hash(hash);
 131}
 132
 133#endif /* jffs2_private.h */
 134