[PATCH] lockdep: locking API self tests
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / fs / jffs2 / summary.h
blob6bf1f6aa45525a81f99bb8b3765e507fa9c9b65b
1 /*
2 * JFFS2 -- Journalling Flash File System, Version 2.
4 * Copyright (C) 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.
11 * $Id: summary.h,v 1.2 2005/09/26 11:37:21 havasi Exp $
15 #ifndef JFFS2_SUMMARY_H
16 #define JFFS2_SUMMARY_H
18 #include <linux/uio.h>
19 #include <linux/jffs2.h>
21 #define BLK_STATE_ALLFF 0
22 #define BLK_STATE_CLEAN 1
23 #define BLK_STATE_PARTDIRTY 2
24 #define BLK_STATE_CLEANMARKER 3
25 #define BLK_STATE_ALLDIRTY 4
26 #define BLK_STATE_BADBLOCK 5
28 #define JFFS2_SUMMARY_NOSUM_SIZE 0xffffffff
29 #define JFFS2_SUMMARY_INODE_SIZE (sizeof(struct jffs2_sum_inode_flash))
30 #define JFFS2_SUMMARY_DIRENT_SIZE(x) (sizeof(struct jffs2_sum_dirent_flash) + (x))
31 #define JFFS2_SUMMARY_XATTR_SIZE (sizeof(struct jffs2_sum_xattr_flash))
32 #define JFFS2_SUMMARY_XREF_SIZE (sizeof(struct jffs2_sum_xref_flash))
34 /* Summary structures used on flash */
36 struct jffs2_sum_unknown_flash
38 jint16_t nodetype; /* node type */
41 struct jffs2_sum_inode_flash
43 jint16_t nodetype; /* node type */
44 jint32_t inode; /* inode number */
45 jint32_t version; /* inode version */
46 jint32_t offset; /* offset on jeb */
47 jint32_t totlen; /* record length */
48 } __attribute__((packed));
50 struct jffs2_sum_dirent_flash
52 jint16_t nodetype; /* == JFFS_NODETYPE_DIRENT */
53 jint32_t totlen; /* record length */
54 jint32_t offset; /* offset on jeb */
55 jint32_t pino; /* parent inode */
56 jint32_t version; /* dirent version */
57 jint32_t ino; /* == zero for unlink */
58 uint8_t nsize; /* dirent name size */
59 uint8_t type; /* dirent type */
60 uint8_t name[0]; /* dirent name */
61 } __attribute__((packed));
63 struct jffs2_sum_xattr_flash
65 jint16_t nodetype; /* == JFFS2_NODETYPE_XATR */
66 jint32_t xid; /* xattr identifier */
67 jint32_t version; /* version number */
68 jint32_t offset; /* offset on jeb */
69 jint32_t totlen; /* node length */
70 } __attribute__((packed));
72 struct jffs2_sum_xref_flash
74 jint16_t nodetype; /* == JFFS2_NODETYPE_XREF */
75 jint32_t offset; /* offset on jeb */
76 } __attribute__((packed));
78 union jffs2_sum_flash
80 struct jffs2_sum_unknown_flash u;
81 struct jffs2_sum_inode_flash i;
82 struct jffs2_sum_dirent_flash d;
83 struct jffs2_sum_xattr_flash x;
84 struct jffs2_sum_xref_flash r;
87 /* Summary structures used in the memory */
89 struct jffs2_sum_unknown_mem
91 union jffs2_sum_mem *next;
92 jint16_t nodetype; /* node type */
95 struct jffs2_sum_inode_mem
97 union jffs2_sum_mem *next;
98 jint16_t nodetype; /* node type */
99 jint32_t inode; /* inode number */
100 jint32_t version; /* inode version */
101 jint32_t offset; /* offset on jeb */
102 jint32_t totlen; /* record length */
103 } __attribute__((packed));
105 struct jffs2_sum_dirent_mem
107 union jffs2_sum_mem *next;
108 jint16_t nodetype; /* == JFFS_NODETYPE_DIRENT */
109 jint32_t totlen; /* record length */
110 jint32_t offset; /* ofset on jeb */
111 jint32_t pino; /* parent inode */
112 jint32_t version; /* dirent version */
113 jint32_t ino; /* == zero for unlink */
114 uint8_t nsize; /* dirent name size */
115 uint8_t type; /* dirent type */
116 uint8_t name[0]; /* dirent name */
117 } __attribute__((packed));
119 struct jffs2_sum_xattr_mem
121 union jffs2_sum_mem *next;
122 jint16_t nodetype;
123 jint32_t xid;
124 jint32_t version;
125 jint32_t offset;
126 jint32_t totlen;
127 } __attribute__((packed));
129 struct jffs2_sum_xref_mem
131 union jffs2_sum_mem *next;
132 jint16_t nodetype;
133 jint32_t offset;
134 } __attribute__((packed));
136 union jffs2_sum_mem
138 struct jffs2_sum_unknown_mem u;
139 struct jffs2_sum_inode_mem i;
140 struct jffs2_sum_dirent_mem d;
141 struct jffs2_sum_xattr_mem x;
142 struct jffs2_sum_xref_mem r;
145 /* Summary related information stored in superblock */
147 struct jffs2_summary
149 uint32_t sum_size; /* collected summary information for nextblock */
150 uint32_t sum_num;
151 uint32_t sum_padded;
152 union jffs2_sum_mem *sum_list_head;
153 union jffs2_sum_mem *sum_list_tail;
155 jint32_t *sum_buf; /* buffer for writing out summary */
158 /* Summary marker is stored at the end of every sumarized erase block */
160 struct jffs2_sum_marker
162 jint32_t offset; /* offset of the summary node in the jeb */
163 jint32_t magic; /* == JFFS2_SUM_MAGIC */
166 #define JFFS2_SUMMARY_FRAME_SIZE (sizeof(struct jffs2_raw_summary) + sizeof(struct jffs2_sum_marker))
168 #ifdef CONFIG_JFFS2_SUMMARY /* SUMMARY SUPPORT ENABLED */
170 #define jffs2_sum_active() (1)
171 int jffs2_sum_init(struct jffs2_sb_info *c);
172 void jffs2_sum_exit(struct jffs2_sb_info *c);
173 void jffs2_sum_disable_collecting(struct jffs2_summary *s);
174 int jffs2_sum_is_disabled(struct jffs2_summary *s);
175 void jffs2_sum_reset_collected(struct jffs2_summary *s);
176 void jffs2_sum_move_collected(struct jffs2_sb_info *c, struct jffs2_summary *s);
177 int jffs2_sum_add_kvec(struct jffs2_sb_info *c, const struct kvec *invecs,
178 unsigned long count, uint32_t to);
179 int jffs2_sum_write_sumnode(struct jffs2_sb_info *c);
180 int jffs2_sum_add_padding_mem(struct jffs2_summary *s, uint32_t size);
181 int jffs2_sum_add_inode_mem(struct jffs2_summary *s, struct jffs2_raw_inode *ri, uint32_t ofs);
182 int jffs2_sum_add_dirent_mem(struct jffs2_summary *s, struct jffs2_raw_dirent *rd, uint32_t ofs);
183 int jffs2_sum_add_xattr_mem(struct jffs2_summary *s, struct jffs2_raw_xattr *rx, uint32_t ofs);
184 int jffs2_sum_add_xref_mem(struct jffs2_summary *s, struct jffs2_raw_xref *rr, uint32_t ofs);
185 int jffs2_sum_scan_sumnode(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb,
186 struct jffs2_raw_summary *summary, uint32_t sumlen,
187 uint32_t *pseudo_random);
189 #else /* SUMMARY DISABLED */
191 #define jffs2_sum_active() (0)
192 #define jffs2_sum_init(a) (0)
193 #define jffs2_sum_exit(a)
194 #define jffs2_sum_disable_collecting(a)
195 #define jffs2_sum_is_disabled(a) (0)
196 #define jffs2_sum_reset_collected(a)
197 #define jffs2_sum_add_kvec(a,b,c,d) (0)
198 #define jffs2_sum_move_collected(a,b)
199 #define jffs2_sum_write_sumnode(a) (0)
200 #define jffs2_sum_add_padding_mem(a,b)
201 #define jffs2_sum_add_inode_mem(a,b,c)
202 #define jffs2_sum_add_dirent_mem(a,b,c)
203 #define jffs2_sum_add_xattr_mem(a,b,c)
204 #define jffs2_sum_add_xref_mem(a,b,c)
205 #define jffs2_sum_scan_sumnode(a,b,c,d,e) (0)
207 #endif /* CONFIG_JFFS2_SUMMARY */
209 #endif /* JFFS2_SUMMARY_H */