0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef JFFS2_SUMMARY_H
0014 #define JFFS2_SUMMARY_H
0015
0016
0017
0018
0019
0020 #define MAX_SUMMARY_SIZE 65536
0021
0022 #include <linux/uio.h>
0023 #include <linux/jffs2.h>
0024
0025 #define BLK_STATE_ALLFF 0
0026 #define BLK_STATE_CLEAN 1
0027 #define BLK_STATE_PARTDIRTY 2
0028 #define BLK_STATE_CLEANMARKER 3
0029 #define BLK_STATE_ALLDIRTY 4
0030 #define BLK_STATE_BADBLOCK 5
0031
0032 #define JFFS2_SUMMARY_NOSUM_SIZE 0xffffffff
0033 #define JFFS2_SUMMARY_INODE_SIZE (sizeof(struct jffs2_sum_inode_flash))
0034 #define JFFS2_SUMMARY_DIRENT_SIZE(x) (sizeof(struct jffs2_sum_dirent_flash) + (x))
0035 #define JFFS2_SUMMARY_XATTR_SIZE (sizeof(struct jffs2_sum_xattr_flash))
0036 #define JFFS2_SUMMARY_XREF_SIZE (sizeof(struct jffs2_sum_xref_flash))
0037
0038
0039
0040 struct jffs2_sum_unknown_flash
0041 {
0042 jint16_t nodetype;
0043 };
0044
0045 struct jffs2_sum_inode_flash
0046 {
0047 jint16_t nodetype;
0048 jint32_t inode;
0049 jint32_t version;
0050 jint32_t offset;
0051 jint32_t totlen;
0052 } __attribute__((packed));
0053
0054 struct jffs2_sum_dirent_flash
0055 {
0056 jint16_t nodetype;
0057 jint32_t totlen;
0058 jint32_t offset;
0059 jint32_t pino;
0060 jint32_t version;
0061 jint32_t ino;
0062 uint8_t nsize;
0063 uint8_t type;
0064 uint8_t name[];
0065 } __attribute__((packed));
0066
0067 struct jffs2_sum_xattr_flash
0068 {
0069 jint16_t nodetype;
0070 jint32_t xid;
0071 jint32_t version;
0072 jint32_t offset;
0073 jint32_t totlen;
0074 } __attribute__((packed));
0075
0076 struct jffs2_sum_xref_flash
0077 {
0078 jint16_t nodetype;
0079 jint32_t offset;
0080 } __attribute__((packed));
0081
0082 union jffs2_sum_flash
0083 {
0084 struct jffs2_sum_unknown_flash u;
0085 struct jffs2_sum_inode_flash i;
0086 struct jffs2_sum_dirent_flash d;
0087 struct jffs2_sum_xattr_flash x;
0088 struct jffs2_sum_xref_flash r;
0089 };
0090
0091
0092
0093 struct jffs2_sum_unknown_mem
0094 {
0095 union jffs2_sum_mem *next;
0096 jint16_t nodetype;
0097 };
0098
0099 struct jffs2_sum_inode_mem
0100 {
0101 union jffs2_sum_mem *next;
0102 jint16_t nodetype;
0103 jint32_t inode;
0104 jint32_t version;
0105 jint32_t offset;
0106 jint32_t totlen;
0107 } __attribute__((packed));
0108
0109 struct jffs2_sum_dirent_mem
0110 {
0111 union jffs2_sum_mem *next;
0112 jint16_t nodetype;
0113 jint32_t totlen;
0114 jint32_t offset;
0115 jint32_t pino;
0116 jint32_t version;
0117 jint32_t ino;
0118 uint8_t nsize;
0119 uint8_t type;
0120 uint8_t name[];
0121 } __attribute__((packed));
0122
0123 struct jffs2_sum_xattr_mem
0124 {
0125 union jffs2_sum_mem *next;
0126 jint16_t nodetype;
0127 jint32_t xid;
0128 jint32_t version;
0129 jint32_t offset;
0130 jint32_t totlen;
0131 } __attribute__((packed));
0132
0133 struct jffs2_sum_xref_mem
0134 {
0135 union jffs2_sum_mem *next;
0136 jint16_t nodetype;
0137 jint32_t offset;
0138 } __attribute__((packed));
0139
0140 union jffs2_sum_mem
0141 {
0142 struct jffs2_sum_unknown_mem u;
0143 struct jffs2_sum_inode_mem i;
0144 struct jffs2_sum_dirent_mem d;
0145 struct jffs2_sum_xattr_mem x;
0146 struct jffs2_sum_xref_mem r;
0147 };
0148
0149
0150
0151 struct jffs2_summary
0152 {
0153 uint32_t sum_size;
0154 uint32_t sum_num;
0155 uint32_t sum_padded;
0156 union jffs2_sum_mem *sum_list_head;
0157 union jffs2_sum_mem *sum_list_tail;
0158
0159 jint32_t *sum_buf;
0160 };
0161
0162
0163
0164 struct jffs2_sum_marker
0165 {
0166 jint32_t offset;
0167 jint32_t magic;
0168 };
0169
0170 #define JFFS2_SUMMARY_FRAME_SIZE (sizeof(struct jffs2_raw_summary) + sizeof(struct jffs2_sum_marker))
0171
0172 #ifdef CONFIG_JFFS2_SUMMARY
0173
0174 #define jffs2_sum_active() (1)
0175 int jffs2_sum_init(struct jffs2_sb_info *c);
0176 void jffs2_sum_exit(struct jffs2_sb_info *c);
0177 void jffs2_sum_disable_collecting(struct jffs2_summary *s);
0178 int jffs2_sum_is_disabled(struct jffs2_summary *s);
0179 void jffs2_sum_reset_collected(struct jffs2_summary *s);
0180 void jffs2_sum_move_collected(struct jffs2_sb_info *c, struct jffs2_summary *s);
0181 int jffs2_sum_add_kvec(struct jffs2_sb_info *c, const struct kvec *invecs,
0182 unsigned long count, uint32_t to);
0183 int jffs2_sum_write_sumnode(struct jffs2_sb_info *c);
0184 int jffs2_sum_add_padding_mem(struct jffs2_summary *s, uint32_t size);
0185 int jffs2_sum_add_inode_mem(struct jffs2_summary *s, struct jffs2_raw_inode *ri, uint32_t ofs);
0186 int jffs2_sum_add_dirent_mem(struct jffs2_summary *s, struct jffs2_raw_dirent *rd, uint32_t ofs);
0187 int jffs2_sum_add_xattr_mem(struct jffs2_summary *s, struct jffs2_raw_xattr *rx, uint32_t ofs);
0188 int jffs2_sum_add_xref_mem(struct jffs2_summary *s, struct jffs2_raw_xref *rr, uint32_t ofs);
0189 int jffs2_sum_scan_sumnode(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb,
0190 struct jffs2_raw_summary *summary, uint32_t sumlen,
0191 uint32_t *pseudo_random);
0192
0193 #else
0194
0195 #define jffs2_sum_active() (0)
0196 #define jffs2_sum_init(a) (0)
0197 #define jffs2_sum_exit(a) do { } while (0)
0198 #define jffs2_sum_disable_collecting(a)
0199 #define jffs2_sum_is_disabled(a) (0)
0200 #define jffs2_sum_reset_collected(a) do { } while (0)
0201 #define jffs2_sum_add_kvec(a,b,c,d) (0)
0202 #define jffs2_sum_move_collected(a,b) do { } while (0)
0203 #define jffs2_sum_write_sumnode(a) (0)
0204 #define jffs2_sum_add_padding_mem(a,b) do { } while (0)
0205 #define jffs2_sum_add_inode_mem(a,b,c) do { } while (0)
0206 #define jffs2_sum_add_dirent_mem(a,b,c) do { } while (0)
0207 #define jffs2_sum_add_xattr_mem(a,b,c) do { } while (0)
0208 #define jffs2_sum_add_xref_mem(a,b,c) do { } while (0)
0209 #define jffs2_sum_scan_sumnode(a,b,c,d,e) (0)
0210
0211 #endif
0212
0213 #endif