Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
summary.h
Go to the documentation of this file.
1 /*
2  * JFFS2 -- Journalling Flash File System, Version 2.
3  *
4  * Copyright © 2004 Ferenc Havasi <[email protected]>,
5  * Zoltan Sogor <[email protected]>,
6  * Patrik Kluba <[email protected]>,
7  * University of Szeged, Hungary
8  *
9  * For licensing information, see the file 'LICENCE' in this directory.
10  *
11  */
12 
13 #ifndef JFFS2_SUMMARY_H
14 #define JFFS2_SUMMARY_H
15 
16 /* Limit summary size to 64KiB so that we can kmalloc it. If the summary
17  is larger than that, we have to just ditch it and avoid using summary
18  for the eraseblock in question... and it probably doesn't hurt us much
19  anyway. */
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 /* Summary structures used on flash */
39 
41 {
42  jint16_t nodetype; /* node type */
43 };
44 
46 {
47  jint16_t nodetype; /* node type */
48  jint32_t inode; /* inode number */
49  jint32_t version; /* inode version */
50  jint32_t offset; /* offset on jeb */
51  jint32_t totlen; /* record length */
52 } __attribute__((packed));
53 
55 {
56  jint16_t nodetype; /* == JFFS_NODETYPE_DIRENT */
57  jint32_t totlen; /* record length */
58  jint32_t offset; /* offset on jeb */
59  jint32_t pino; /* parent inode */
60  jint32_t version; /* dirent version */
61  jint32_t ino; /* == zero for unlink */
62  uint8_t nsize; /* dirent name size */
63  uint8_t type; /* dirent type */
64  uint8_t name[0]; /* dirent name */
65 } __attribute__((packed));
66 
68 {
69  jint16_t nodetype; /* == JFFS2_NODETYPE_XATR */
70  jint32_t xid; /* xattr identifier */
71  jint32_t version; /* version number */
72  jint32_t offset; /* offset on jeb */
73  jint32_t totlen; /* node length */
74 } __attribute__((packed));
75 
77 {
78  jint16_t nodetype; /* == JFFS2_NODETYPE_XREF */
79  jint32_t offset; /* offset on jeb */
80 } __attribute__((packed));
81 
83 {
89 };
90 
91 /* Summary structures used in the memory */
92 
94 {
96  jint16_t nodetype; /* node type */
97 };
98 
100 {
102  jint16_t nodetype; /* node type */
103  jint32_t inode; /* inode number */
104  jint32_t version; /* inode version */
105  jint32_t offset; /* offset on jeb */
106  jint32_t totlen; /* record length */
107 } __attribute__((packed));
110 {
112  jint16_t nodetype; /* == JFFS_NODETYPE_DIRENT */
113  jint32_t totlen; /* record length */
114  jint32_t offset; /* ofset on jeb */
115  jint32_t pino; /* parent inode */
116  jint32_t version; /* dirent version */
117  jint32_t ino; /* == zero for unlink */
118  uint8_t nsize; /* dirent name size */
119  uint8_t type; /* dirent type */
120  uint8_t name[0]; /* dirent name */
121 } __attribute__((packed));
122 
124 {
126  jint16_t nodetype;
127  jint32_t xid;
128  jint32_t version;
129  jint32_t offset;
130  jint32_t totlen;
131 } __attribute__((packed));
132 
134 {
136  jint16_t nodetype;
137  jint32_t offset;
138 } __attribute__((packed));
139 
141 {
147 };
148 
149 /* Summary related information stored in superblock */
150 
152 {
153  uint32_t sum_size; /* collected summary information for nextblock */
158 
159  jint32_t *sum_buf; /* buffer for writing out summary */
160 };
161 
162 /* Summary marker is stored at the end of every sumarized erase block */
163 
165 {
166  jint32_t offset; /* offset of the summary node in the jeb */
167  jint32_t magic; /* == JFFS2_SUM_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 /* SUMMARY SUPPORT ENABLED */
173 
174 #define jffs2_sum_active() (1)
175 int jffs2_sum_init(struct jffs2_sb_info *c);
176 void jffs2_sum_exit(struct jffs2_sb_info *c);
181 int jffs2_sum_add_kvec(struct jffs2_sb_info *c, const struct kvec *invecs,
182  unsigned long count, uint32_t to);
185 int jffs2_sum_add_inode_mem(struct jffs2_summary *s, struct jffs2_raw_inode *ri, uint32_t ofs);
188 int jffs2_sum_add_xref_mem(struct jffs2_summary *s, struct jffs2_raw_xref *rr, uint32_t ofs);
189 int 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 /* SUMMARY DISABLED */
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 /* CONFIG_JFFS2_SUMMARY */
212 
213 #endif /* JFFS2_SUMMARY_H */