generic: add __FINITDATA
[wrt350n-kernel.git] / fs / jffs2 / summary.h
blob8bf34f2fa5ce30b6f50f9d16de3ad5b9df31195e
1 /*
2 * JFFS2 -- Journalling Flash File System, Version 2.
4 * Copyright © 2004 Ferenc Havasi <havasi@inf.u-szeged.hu>,
5 * Zoltan Sogor <weth@inf.u-szeged.hu>,
6 * Patrik Kluba <pajko@halom.u-szeged.hu>,
7 * University of Szeged, Hungary
9 * For licensing information, see the file 'LICENCE' in this directory.
13 #ifndef JFFS2_SUMMARY_H
14 #define JFFS2_SUMMARY_H
16 #include <linux/uio.h>
17 #include <linux/jffs2.h>
19 #define BLK_STATE_ALLFF 0
20 #define BLK_STATE_CLEAN 1
21 #define BLK_STATE_PARTDIRTY 2
22 #define BLK_STATE_CLEANMARKER 3
23 #define BLK_STATE_ALLDIRTY 4
24 #define BLK_STATE_BADBLOCK 5
26 #define JFFS2_SUMMARY_NOSUM_SIZE 0xffffffff
27 #define JFFS2_SUMMARY_INODE_SIZE (sizeof(struct jffs2_sum_inode_flash))
28 #define JFFS2_SUMMARY_DIRENT_SIZE(x) (sizeof(struct jffs2_sum_dirent_flash) + (x))
29 #define JFFS2_SUMMARY_XATTR_SIZE (sizeof(struct jffs2_sum_xattr_flash))
30 #define JFFS2_SUMMARY_XREF_SIZE (sizeof(struct jffs2_sum_xref_flash))
32 /* Summary structures used on flash */
34 struct jffs2_sum_unknown_flash
36 jint16_t nodetype; /* node type */
39 struct jffs2_sum_inode_flash
41 jint16_t nodetype; /* node type */
42 jint32_t inode; /* inode number */
43 jint32_t version; /* inode version */
44 jint32_t offset; /* offset on jeb */
45 jint32_t totlen; /* record length */
46 } __attribute__((packed));
48 struct jffs2_sum_dirent_flash
50 jint16_t nodetype; /* == JFFS_NODETYPE_DIRENT */
51 jint32_t totlen; /* record length */
52 jint32_t offset; /* offset on jeb */
53 jint32_t pino; /* parent inode */
54 jint32_t version; /* dirent version */
55 jint32_t ino; /* == zero for unlink */
56 uint8_t nsize; /* dirent name size */
57 uint8_t type; /* dirent type */
58 uint8_t name[0]; /* dirent name */
59 } __attribute__((packed));
61 struct jffs2_sum_xattr_flash
63 jint16_t nodetype; /* == JFFS2_NODETYPE_XATR */
64 jint32_t xid; /* xattr identifier */
65 jint32_t version; /* version number */
66 jint32_t offset; /* offset on jeb */
67 jint32_t totlen; /* node length */
68 } __attribute__((packed));
70 struct jffs2_sum_xref_flash
72 jint16_t nodetype; /* == JFFS2_NODETYPE_XREF */
73 jint32_t offset; /* offset on jeb */
74 } __attribute__((packed));
76 union jffs2_sum_flash
78 struct jffs2_sum_unknown_flash u;
79 struct jffs2_sum_inode_flash i;
80 struct jffs2_sum_dirent_flash d;
81 struct jffs2_sum_xattr_flash x;
82 struct jffs2_sum_xref_flash r;
85 /* Summary structures used in the memory */
87 struct jffs2_sum_unknown_mem
89 union jffs2_sum_mem *next;
90 jint16_t nodetype; /* node type */
93 struct jffs2_sum_inode_mem
95 union jffs2_sum_mem *next;
96 jint16_t nodetype; /* node type */
97 jint32_t inode; /* inode number */
98 jint32_t version; /* inode version */
99 jint32_t offset; /* offset on jeb */
100 jint32_t totlen; /* record length */
101 } __attribute__((packed));
103 struct jffs2_sum_dirent_mem
105 union jffs2_sum_mem *next;
106 jint16_t nodetype; /* == JFFS_NODETYPE_DIRENT */
107 jint32_t totlen; /* record length */
108 jint32_t offset; /* ofset on jeb */
109 jint32_t pino; /* parent inode */
110 jint32_t version; /* dirent version */
111 jint32_t ino; /* == zero for unlink */
112 uint8_t nsize; /* dirent name size */
113 uint8_t type; /* dirent type */
114 uint8_t name[0]; /* dirent name */
115 } __attribute__((packed));
117 struct jffs2_sum_xattr_mem
119 union jffs2_sum_mem *next;
120 jint16_t nodetype;
121 jint32_t xid;
122 jint32_t version;
123 jint32_t offset;
124 jint32_t totlen;
125 } __attribute__((packed));
127 struct jffs2_sum_xref_mem
129 union jffs2_sum_mem *next;
130 jint16_t nodetype;
131 jint32_t offset;
132 } __attribute__((packed));
134 union jffs2_sum_mem
136 struct jffs2_sum_unknown_mem u;
137 struct jffs2_sum_inode_mem i;
138 struct jffs2_sum_dirent_mem d;
139 struct jffs2_sum_xattr_mem x;
140 struct jffs2_sum_xref_mem r;
143 /* Summary related information stored in superblock */
145 struct jffs2_summary
147 uint32_t sum_size; /* collected summary information for nextblock */
148 uint32_t sum_num;
149 uint32_t sum_padded;
150 union jffs2_sum_mem *sum_list_head;
151 union jffs2_sum_mem *sum_list_tail;
153 jint32_t *sum_buf; /* buffer for writing out summary */
156 /* Summary marker is stored at the end of every sumarized erase block */
158 struct jffs2_sum_marker
160 jint32_t offset; /* offset of the summary node in the jeb */
161 jint32_t magic; /* == JFFS2_SUM_MAGIC */
164 #define JFFS2_SUMMARY_FRAME_SIZE (sizeof(struct jffs2_raw_summary) + sizeof(struct jffs2_sum_marker))
166 #ifdef CONFIG_JFFS2_SUMMARY /* SUMMARY SUPPORT ENABLED */
168 #define jffs2_sum_active() (1)
169 int jffs2_sum_init(struct jffs2_sb_info *c);
170 void jffs2_sum_exit(struct jffs2_sb_info *c);
171 void jffs2_sum_disable_collecting(struct jffs2_summary *s);
172 int jffs2_sum_is_disabled(struct jffs2_summary *s);
173 void jffs2_sum_reset_collected(struct jffs2_summary *s);
174 void jffs2_sum_move_collected(struct jffs2_sb_info *c, struct jffs2_summary *s);
175 int jffs2_sum_add_kvec(struct jffs2_sb_info *c, const struct kvec *invecs,
176 unsigned long count, uint32_t to);
177 int jffs2_sum_write_sumnode(struct jffs2_sb_info *c);
178 int jffs2_sum_add_padding_mem(struct jffs2_summary *s, uint32_t size);
179 int jffs2_sum_add_inode_mem(struct jffs2_summary *s, struct jffs2_raw_inode *ri, uint32_t ofs);
180 int jffs2_sum_add_dirent_mem(struct jffs2_summary *s, struct jffs2_raw_dirent *rd, uint32_t ofs);
181 int jffs2_sum_add_xattr_mem(struct jffs2_summary *s, struct jffs2_raw_xattr *rx, uint32_t ofs);
182 int jffs2_sum_add_xref_mem(struct jffs2_summary *s, struct jffs2_raw_xref *rr, uint32_t ofs);
183 int jffs2_sum_scan_sumnode(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb,
184 struct jffs2_raw_summary *summary, uint32_t sumlen,
185 uint32_t *pseudo_random);
187 #else /* SUMMARY DISABLED */
189 #define jffs2_sum_active() (0)
190 #define jffs2_sum_init(a) (0)
191 #define jffs2_sum_exit(a)
192 #define jffs2_sum_disable_collecting(a)
193 #define jffs2_sum_is_disabled(a) (0)
194 #define jffs2_sum_reset_collected(a)
195 #define jffs2_sum_add_kvec(a,b,c,d) (0)
196 #define jffs2_sum_move_collected(a,b)
197 #define jffs2_sum_write_sumnode(a) (0)
198 #define jffs2_sum_add_padding_mem(a,b)
199 #define jffs2_sum_add_inode_mem(a,b,c)
200 #define jffs2_sum_add_dirent_mem(a,b,c)
201 #define jffs2_sum_add_xattr_mem(a,b,c)
202 #define jffs2_sum_add_xref_mem(a,b,c)
203 #define jffs2_sum_scan_sumnode(a,b,c,d,e) (0)
205 #endif /* CONFIG_JFFS2_SUMMARY */
207 #endif /* JFFS2_SUMMARY_H */