[JFFS2][XATTR] XATTR support on JFFS2 (version. 5)
[deliverable/linux.git] / fs / jffs2 / summary.h
1 /*
2 * JFFS2 -- Journalling Flash File System, Version 2.
3 *
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
8 *
9 * For licensing information, see the file 'LICENCE' in this directory.
10 *
11 * $Id: summary.h,v 1.2 2005/09/26 11:37:21 havasi Exp $
12 *
13 */
14
15 #ifndef JFFS2_SUMMARY_H
16 #define JFFS2_SUMMARY_H
17
18 #include <linux/uio.h>
19 #include <linux/jffs2.h>
20
21 #define DIRTY_SPACE(x) do { typeof(x) _x = (x); \
22 c->free_size -= _x; c->dirty_size += _x; \
23 jeb->free_size -= _x ; jeb->dirty_size += _x; \
24 }while(0)
25 #define USED_SPACE(x) do { typeof(x) _x = (x); \
26 c->free_size -= _x; c->used_size += _x; \
27 jeb->free_size -= _x ; jeb->used_size += _x; \
28 }while(0)
29 #define WASTED_SPACE(x) do { typeof(x) _x = (x); \
30 c->free_size -= _x; c->wasted_size += _x; \
31 jeb->free_size -= _x ; jeb->wasted_size += _x; \
32 }while(0)
33 #define UNCHECKED_SPACE(x) do { typeof(x) _x = (x); \
34 c->free_size -= _x; c->unchecked_size += _x; \
35 jeb->free_size -= _x ; jeb->unchecked_size += _x; \
36 }while(0)
37
38 #define BLK_STATE_ALLFF 0
39 #define BLK_STATE_CLEAN 1
40 #define BLK_STATE_PARTDIRTY 2
41 #define BLK_STATE_CLEANMARKER 3
42 #define BLK_STATE_ALLDIRTY 4
43 #define BLK_STATE_BADBLOCK 5
44
45 #define JFFS2_SUMMARY_NOSUM_SIZE 0xffffffff
46 #define JFFS2_SUMMARY_INODE_SIZE (sizeof(struct jffs2_sum_inode_flash))
47 #define JFFS2_SUMMARY_DIRENT_SIZE(x) (sizeof(struct jffs2_sum_dirent_flash) + (x))
48 #define JFFS2_SUMMARY_XATTR_SIZE (sizeof(struct jffs2_sum_xattr_flash))
49 #define JFFS2_SUMMARY_XREF_SIZE (sizeof(struct jffs2_sum_xref_flash))
50
51 /* Summary structures used on flash */
52
53 struct jffs2_sum_unknown_flash
54 {
55 jint16_t nodetype; /* node type */
56 };
57
58 struct jffs2_sum_inode_flash
59 {
60 jint16_t nodetype; /* node type */
61 jint32_t inode; /* inode number */
62 jint32_t version; /* inode version */
63 jint32_t offset; /* offset on jeb */
64 jint32_t totlen; /* record length */
65 } __attribute__((packed));
66
67 struct jffs2_sum_dirent_flash
68 {
69 jint16_t nodetype; /* == JFFS_NODETYPE_DIRENT */
70 jint32_t totlen; /* record length */
71 jint32_t offset; /* offset on jeb */
72 jint32_t pino; /* parent inode */
73 jint32_t version; /* dirent version */
74 jint32_t ino; /* == zero for unlink */
75 uint8_t nsize; /* dirent name size */
76 uint8_t type; /* dirent type */
77 uint8_t name[0]; /* dirent name */
78 } __attribute__((packed));
79
80 struct jffs2_sum_xattr_flash
81 {
82 jint16_t nodetype; /* == JFFS2_NODETYPE_XATR */
83 jint32_t xid; /* xattr identifier */
84 jint32_t version; /* version number */
85 jint32_t offset; /* offset on jeb */
86 jint32_t totlen; /* node length */
87 } __attribute__((packed));
88
89 struct jffs2_sum_xref_flash
90 {
91 jint16_t nodetype; /* == JFFS2_NODETYPE_XREF */
92 jint32_t offset; /* offset on jeb */
93 } __attribute__((packed));
94
95 union jffs2_sum_flash
96 {
97 struct jffs2_sum_unknown_flash u;
98 struct jffs2_sum_inode_flash i;
99 struct jffs2_sum_dirent_flash d;
100 struct jffs2_sum_xattr_flash x;
101 struct jffs2_sum_xref_flash r;
102 };
103
104 /* Summary structures used in the memory */
105
106 struct jffs2_sum_unknown_mem
107 {
108 union jffs2_sum_mem *next;
109 jint16_t nodetype; /* node type */
110 };
111
112 struct jffs2_sum_inode_mem
113 {
114 union jffs2_sum_mem *next;
115 jint16_t nodetype; /* node type */
116 jint32_t inode; /* inode number */
117 jint32_t version; /* inode version */
118 jint32_t offset; /* offset on jeb */
119 jint32_t totlen; /* record length */
120 } __attribute__((packed));
121
122 struct jffs2_sum_dirent_mem
123 {
124 union jffs2_sum_mem *next;
125 jint16_t nodetype; /* == JFFS_NODETYPE_DIRENT */
126 jint32_t totlen; /* record length */
127 jint32_t offset; /* ofset on jeb */
128 jint32_t pino; /* parent inode */
129 jint32_t version; /* dirent version */
130 jint32_t ino; /* == zero for unlink */
131 uint8_t nsize; /* dirent name size */
132 uint8_t type; /* dirent type */
133 uint8_t name[0]; /* dirent name */
134 } __attribute__((packed));
135
136 struct jffs2_sum_xattr_mem
137 {
138 union jffs2_sum_mem *next;
139 jint16_t nodetype;
140 jint32_t xid;
141 jint32_t version;
142 jint32_t offset;
143 jint32_t totlen;
144 } __attribute__((packed));
145
146 struct jffs2_sum_xref_mem
147 {
148 union jffs2_sum_mem *next;
149 jint16_t nodetype;
150 jint32_t offset;
151 } __attribute__((packed));
152
153 union jffs2_sum_mem
154 {
155 struct jffs2_sum_unknown_mem u;
156 struct jffs2_sum_inode_mem i;
157 struct jffs2_sum_dirent_mem d;
158 struct jffs2_sum_xattr_mem x;
159 struct jffs2_sum_xref_mem r;
160 };
161
162 /* Summary related information stored in superblock */
163
164 struct jffs2_summary
165 {
166 uint32_t sum_size; /* collected summary information for nextblock */
167 uint32_t sum_num;
168 uint32_t sum_padded;
169 union jffs2_sum_mem *sum_list_head;
170 union jffs2_sum_mem *sum_list_tail;
171
172 jint32_t *sum_buf; /* buffer for writing out summary */
173 };
174
175 /* Summary marker is stored at the end of every sumarized erase block */
176
177 struct jffs2_sum_marker
178 {
179 jint32_t offset; /* offset of the summary node in the jeb */
180 jint32_t magic; /* == JFFS2_SUM_MAGIC */
181 };
182
183 #define JFFS2_SUMMARY_FRAME_SIZE (sizeof(struct jffs2_raw_summary) + sizeof(struct jffs2_sum_marker))
184
185 #ifdef CONFIG_JFFS2_SUMMARY /* SUMMARY SUPPORT ENABLED */
186
187 #define jffs2_sum_active() (1)
188 int jffs2_sum_init(struct jffs2_sb_info *c);
189 void jffs2_sum_exit(struct jffs2_sb_info *c);
190 void jffs2_sum_disable_collecting(struct jffs2_summary *s);
191 int jffs2_sum_is_disabled(struct jffs2_summary *s);
192 void jffs2_sum_reset_collected(struct jffs2_summary *s);
193 void jffs2_sum_move_collected(struct jffs2_sb_info *c, struct jffs2_summary *s);
194 int jffs2_sum_add_kvec(struct jffs2_sb_info *c, const struct kvec *invecs,
195 unsigned long count, uint32_t to);
196 int jffs2_sum_write_sumnode(struct jffs2_sb_info *c);
197 int jffs2_sum_add_padding_mem(struct jffs2_summary *s, uint32_t size);
198 int jffs2_sum_add_inode_mem(struct jffs2_summary *s, struct jffs2_raw_inode *ri, uint32_t ofs);
199 int jffs2_sum_add_dirent_mem(struct jffs2_summary *s, struct jffs2_raw_dirent *rd, uint32_t ofs);
200 int jffs2_sum_add_xattr_mem(struct jffs2_summary *s, struct jffs2_raw_xattr *rx, uint32_t ofs);
201 int jffs2_sum_add_xref_mem(struct jffs2_summary *s, struct jffs2_raw_xref *rr, uint32_t ofs);
202 int jffs2_sum_scan_sumnode(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb,
203 uint32_t ofs, uint32_t *pseudo_random);
204
205 #else /* SUMMARY DISABLED */
206
207 #define jffs2_sum_active() (0)
208 #define jffs2_sum_init(a) (0)
209 #define jffs2_sum_exit(a)
210 #define jffs2_sum_disable_collecting(a)
211 #define jffs2_sum_is_disabled(a) (0)
212 #define jffs2_sum_reset_collected(a)
213 #define jffs2_sum_add_kvec(a,b,c,d) (0)
214 #define jffs2_sum_move_collected(a,b)
215 #define jffs2_sum_write_sumnode(a) (0)
216 #define jffs2_sum_add_padding_mem(a,b)
217 #define jffs2_sum_add_inode_mem(a,b,c)
218 #define jffs2_sum_add_dirent_mem(a,b,c)
219 #define jffs2_sum_add_xattr_mem(a,b,c)
220 #define jffs2_sum_add_xref_mem(a,b,c)
221 #define jffs2_sum_scan_sumnode(a,b,c,d) (0)
222
223 #endif /* CONFIG_JFFS2_SUMMARY */
224
225 #endif /* JFFS2_SUMMARY_H */
This page took 0.03627 seconds and 5 git commands to generate.