1
2
3
4
5
6
7
8
9
10
11
12
13#ifndef JFFS2_SUMMARY_H
14#define JFFS2_SUMMARY_H
15
16
17
18
19
20#define MAX_SUMMARY_SIZE 65536
21
22#include <linux/uio.h>
23#include <linux/jffs2.h>
24
25#define BLK_STATE_ALLFF 0
26#define BLK_STATE_CLEAN 1
27#define BLK_STATE_PARTDIRTY 2
28#define BLK_STATE_CLEANMARKER 3
29#define BLK_STATE_ALLDIRTY 4
30#define BLK_STATE_BADBLOCK 5
31
32#define JFFS2_SUMMARY_NOSUM_SIZE 0xffffffff
33#define JFFS2_SUMMARY_INODE_SIZE (sizeof(struct jffs2_sum_inode_flash))
34#define JFFS2_SUMMARY_DIRENT_SIZE(x) (sizeof(struct jffs2_sum_dirent_flash) + (x))
35#define JFFS2_SUMMARY_XATTR_SIZE (sizeof(struct jffs2_sum_xattr_flash))
36#define JFFS2_SUMMARY_XREF_SIZE (sizeof(struct jffs2_sum_xref_flash))
37
38
39
40struct jffs2_sum_unknown_flash
41{
42 jint16_t nodetype;
43};
44
45struct jffs2_sum_inode_flash
46{
47 jint16_t nodetype;
48 jint32_t inode;
49 jint32_t version;
50 jint32_t offset;
51 jint32_t totlen;
52} __attribute__((packed));
53
54struct jffs2_sum_dirent_flash
55{
56 jint16_t nodetype;
57 jint32_t totlen;
58 jint32_t offset;
59 jint32_t pino;
60 jint32_t version;
61 jint32_t ino;
62 uint8_t nsize;
63 uint8_t type;
64 uint8_t name[0];
65} __attribute__((packed));
66
67struct jffs2_sum_xattr_flash
68{
69 jint16_t nodetype;
70 jint32_t xid;
71 jint32_t version;
72 jint32_t offset;
73 jint32_t totlen;
74} __attribute__((packed));
75
76struct jffs2_sum_xref_flash
77{
78 jint16_t nodetype;
79 jint32_t offset;
80} __attribute__((packed));
81
82union jffs2_sum_flash
83{
84 struct jffs2_sum_unknown_flash u;
85 struct jffs2_sum_inode_flash i;
86 struct jffs2_sum_dirent_flash d;
87 struct jffs2_sum_xattr_flash x;
88 struct jffs2_sum_xref_flash r;
89};
90
91
92
93struct jffs2_sum_unknown_mem
94{
95 union jffs2_sum_mem *next;
96 jint16_t nodetype;
97};
98
99struct jffs2_sum_inode_mem
100{
101 union jffs2_sum_mem *next;
102 jint16_t nodetype;
103 jint32_t inode;
104 jint32_t version;
105 jint32_t offset;
106 jint32_t totlen;
107} __attribute__((packed));
108
109struct jffs2_sum_dirent_mem
110{
111 union jffs2_sum_mem *next;
112 jint16_t nodetype;
113 jint32_t totlen;
114 jint32_t offset;
115 jint32_t pino;
116 jint32_t version;
117 jint32_t ino;
118 uint8_t nsize;
119 uint8_t type;
120 uint8_t name[0];
121} __attribute__((packed));
122
123struct jffs2_sum_xattr_mem
124{
125 union jffs2_sum_mem *next;
126 jint16_t nodetype;
127 jint32_t xid;
128 jint32_t version;
129 jint32_t offset;
130 jint32_t totlen;
131} __attribute__((packed));
132
133struct jffs2_sum_xref_mem
134{
135 union jffs2_sum_mem *next;
136 jint16_t nodetype;
137 jint32_t offset;
138} __attribute__((packed));
139
140union jffs2_sum_mem
141{
142 struct jffs2_sum_unknown_mem u;
143 struct jffs2_sum_inode_mem i;
144 struct jffs2_sum_dirent_mem d;
145 struct jffs2_sum_xattr_mem x;
146 struct jffs2_sum_xref_mem r;
147};
148
149
150
151struct jffs2_summary
152{
153 uint32_t sum_size;
154 uint32_t sum_num;
155 uint32_t sum_padded;
156 union jffs2_sum_mem *sum_list_head;
157 union jffs2_sum_mem *sum_list_tail;
158
159 jint32_t *sum_buf;
160};
161
162
163
164struct jffs2_sum_marker
165{
166 jint32_t offset;
167 jint32_t magic;
168};
169
170#define JFFS2_SUMMARY_FRAME_SIZE (sizeof(struct jffs2_raw_summary) + sizeof(struct jffs2_sum_marker))
171
172#ifdef CONFIG_JFFS2_SUMMARY
173
174#define jffs2_sum_active() (1)
175int jffs2_sum_init(struct jffs2_sb_info *c);
176void jffs2_sum_exit(struct jffs2_sb_info *c);
177void jffs2_sum_disable_collecting(struct jffs2_summary *s);
178int jffs2_sum_is_disabled(struct jffs2_summary *s);
179void jffs2_sum_reset_collected(struct jffs2_summary *s);
180void jffs2_sum_move_collected(struct jffs2_sb_info *c, struct jffs2_summary *s);
181int jffs2_sum_add_kvec(struct jffs2_sb_info *c, const struct kvec *invecs,
182 unsigned long count, uint32_t to);
183int jffs2_sum_write_sumnode(struct jffs2_sb_info *c);
184int jffs2_sum_add_padding_mem(struct jffs2_summary *s, uint32_t size);
185int jffs2_sum_add_inode_mem(struct jffs2_summary *s, struct jffs2_raw_inode *ri, uint32_t ofs);
186int jffs2_sum_add_dirent_mem(struct jffs2_summary *s, struct jffs2_raw_dirent *rd, uint32_t ofs);
187int jffs2_sum_add_xattr_mem(struct jffs2_summary *s, struct jffs2_raw_xattr *rx, uint32_t ofs);
188int jffs2_sum_add_xref_mem(struct jffs2_summary *s, struct jffs2_raw_xref *rr, uint32_t ofs);
189int jffs2_sum_scan_sumnode(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb,
190 struct jffs2_raw_summary *summary, uint32_t sumlen,
191 uint32_t *pseudo_random);
192
193#else
194
195#define jffs2_sum_active() (0)
196#define jffs2_sum_init(a) (0)
197#define jffs2_sum_exit(a)
198#define jffs2_sum_disable_collecting(a)
199#define jffs2_sum_is_disabled(a) (0)
200#define jffs2_sum_reset_collected(a)
201#define jffs2_sum_add_kvec(a,b,c,d) (0)
202#define jffs2_sum_move_collected(a,b)
203#define jffs2_sum_write_sumnode(a) (0)
204#define jffs2_sum_add_padding_mem(a,b)
205#define jffs2_sum_add_inode_mem(a,b,c)
206#define jffs2_sum_add_dirent_mem(a,b,c)
207#define jffs2_sum_add_xattr_mem(a,b,c)
208#define jffs2_sum_add_xref_mem(a,b,c)
209#define jffs2_sum_scan_sumnode(a,b,c,d,e) (0)
210
211#endif
212
213#endif
214