RTEMS 6.2
Loading...
Searching...
No Matches
summary.h
1/*
2 * JFFS2 -- Journalling Flash File System, Version 2.
3 *
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
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#ifndef __rtems__
17/* Limit summary size to 64KiB so that we can kmalloc it. If the summary
18 is larger than that, we have to just ditch it and avoid using summary
19 for the eraseblock in question... and it probably doesn't hurt us much
20 anyway. */
21#define MAX_SUMMARY_SIZE 65536
22#else /* __rtems__ */
23/*
24 * RTEMS uses a flat memory space with no virtual addressing, so allocation for
25 * DMA purposes does not require the special consideration that the Linux kernel
26 * requires. Allow summary nodes to consume up to a sector.
27 */
28#define MAX_SUMMARY_SIZE c->sector_size
29#endif /* __rtems__ */
30
31#include <linux/uio.h>
32#include <linux/jffs2.h>
33
34#define BLK_STATE_ALLFF 0
35#define BLK_STATE_CLEAN 1
36#define BLK_STATE_PARTDIRTY 2
37#define BLK_STATE_CLEANMARKER 3
38#define BLK_STATE_ALLDIRTY 4
39#define BLK_STATE_BADBLOCK 5
40
41#define JFFS2_SUMMARY_NOSUM_SIZE 0xffffffff
42#define JFFS2_SUMMARY_INODE_SIZE (sizeof(struct jffs2_sum_inode_flash))
43#define JFFS2_SUMMARY_DIRENT_SIZE(x) (sizeof(struct jffs2_sum_dirent_flash) + (x))
44#define JFFS2_SUMMARY_XATTR_SIZE (sizeof(struct jffs2_sum_xattr_flash))
45#define JFFS2_SUMMARY_XREF_SIZE (sizeof(struct jffs2_sum_xref_flash))
46
47/* Summary structures used on flash */
48
50{
51 jint16_t nodetype; /* node type */
52};
53
55{
56 jint16_t nodetype; /* node type */
57 jint32_t inode; /* inode number */
58 jint32_t version; /* inode version */
59 jint32_t offset; /* offset on jeb */
60 jint32_t totlen; /* record length */
61} __attribute__((packed));
62
64{
65 jint16_t nodetype; /* == JFFS_NODETYPE_DIRENT */
66 jint32_t totlen; /* record length */
67 jint32_t offset; /* offset on jeb */
68 jint32_t pino; /* parent inode */
69 jint32_t version; /* dirent version */
70 jint32_t ino; /* == zero for unlink */
71 uint8_t nsize; /* dirent name size */
72 uint8_t type; /* dirent type */
73 uint8_t name[]; /* dirent name */
74} __attribute__((packed));
75
77{
78 jint16_t nodetype; /* == JFFS2_NODETYPE_XATR */
79 jint32_t xid; /* xattr identifier */
80 jint32_t version; /* version number */
81 jint32_t offset; /* offset on jeb */
82 jint32_t totlen; /* node length */
83} __attribute__((packed));
84
86{
87 jint16_t nodetype; /* == JFFS2_NODETYPE_XREF */
88 jint32_t offset; /* offset on jeb */
89} __attribute__((packed));
90
92{
94 struct jffs2_sum_inode_flash i;
96 struct jffs2_sum_xattr_flash x;
97 struct jffs2_sum_xref_flash r;
98};
99
100/* Summary structures used in the memory */
101
103{
104 union jffs2_sum_mem *next;
105 jint16_t nodetype; /* node type */
106};
107
109{
110 union jffs2_sum_mem *next;
111 jint16_t nodetype; /* node type */
112 jint32_t inode; /* inode number */
113 jint32_t version; /* inode version */
114 jint32_t offset; /* offset on jeb */
115 jint32_t totlen; /* record length */
116} __attribute__((packed));
117
119{
120 union jffs2_sum_mem *next;
121 jint16_t nodetype; /* == JFFS_NODETYPE_DIRENT */
122 jint32_t totlen; /* record length */
123 jint32_t offset; /* ofset on jeb */
124 jint32_t pino; /* parent inode */
125 jint32_t version; /* dirent version */
126 jint32_t ino; /* == zero for unlink */
127 uint8_t nsize; /* dirent name size */
128 uint8_t type; /* dirent type */
129 uint8_t name[]; /* dirent name */
130} __attribute__((packed));
131
133{
134 union jffs2_sum_mem *next;
135 jint16_t nodetype;
136 jint32_t xid;
137 jint32_t version;
138 jint32_t offset;
139 jint32_t totlen;
140} __attribute__((packed));
141
143{
144 union jffs2_sum_mem *next;
145 jint16_t nodetype;
146 jint32_t offset;
147} __attribute__((packed));
148
150{
151 struct jffs2_sum_unknown_mem u;
152 struct jffs2_sum_inode_mem i;
153 struct jffs2_sum_dirent_mem d;
154 struct jffs2_sum_xattr_mem x;
155 struct jffs2_sum_xref_mem r;
156};
157
158/* Summary related information stored in superblock */
159
161{
162 uint32_t sum_size; /* collected summary information for nextblock */
163 uint32_t sum_num;
164 uint32_t sum_padded;
165 union jffs2_sum_mem *sum_list_head;
166 union jffs2_sum_mem *sum_list_tail;
167
168 jint32_t *sum_buf; /* buffer for writing out summary */
169};
170
171/* Summary marker is stored at the end of every sumarized erase block */
172
174{
175 jint32_t offset; /* offset of the summary node in the jeb */
176 jint32_t magic; /* == JFFS2_SUM_MAGIC */
177};
178
179#define JFFS2_SUMMARY_FRAME_SIZE (sizeof(struct jffs2_raw_summary) + sizeof(struct jffs2_sum_marker))
180
181#ifdef CONFIG_JFFS2_SUMMARY /* SUMMARY SUPPORT ENABLED */
182
183#define jffs2_sum_active() (1)
184int jffs2_sum_init(struct jffs2_sb_info *c);
185void jffs2_sum_exit(struct jffs2_sb_info *c);
186void jffs2_sum_disable_collecting(struct jffs2_summary *s);
187int jffs2_sum_is_disabled(struct jffs2_summary *s);
188void jffs2_sum_reset_collected(struct jffs2_summary *s);
189void jffs2_sum_move_collected(struct jffs2_sb_info *c, struct jffs2_summary *s);
190int jffs2_sum_add_kvec(struct jffs2_sb_info *c, const struct kvec *invecs,
191 unsigned long count, uint32_t to);
192int jffs2_sum_write_sumnode(struct jffs2_sb_info *c);
193int jffs2_sum_add_padding_mem(struct jffs2_summary *s, uint32_t size);
194int jffs2_sum_add_inode_mem(struct jffs2_summary *s, struct jffs2_raw_inode *ri, uint32_t ofs);
195int jffs2_sum_add_dirent_mem(struct jffs2_summary *s, struct jffs2_raw_dirent *rd, uint32_t ofs);
196int jffs2_sum_add_xattr_mem(struct jffs2_summary *s, struct jffs2_raw_xattr *rx, uint32_t ofs);
197int jffs2_sum_add_xref_mem(struct jffs2_summary *s, struct jffs2_raw_xref *rr, uint32_t ofs);
198int jffs2_sum_scan_sumnode(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb,
199 struct jffs2_raw_summary *summary, uint32_t sumlen,
200 uint32_t *pseudo_random);
201
202#else /* SUMMARY DISABLED */
203
204#define jffs2_sum_active() (0)
205#define jffs2_sum_init(a) (0)
206#define jffs2_sum_exit(a) do { } while (0)
207#define jffs2_sum_disable_collecting(a)
208#define jffs2_sum_is_disabled(a) (0)
209#define jffs2_sum_reset_collected(a) do { } while (0)
210#ifndef __rtems__
211#define jffs2_sum_add_kvec(a,b,c,d) (0)
212#else
213#define jffs2_sum_add_kvec(a,b,c,d) \
214 ({ \
215 (void)a; \
216 (void)b; \
217 (void)c; \
218 (void)d; \
219 0; \
220 })
221#endif
222#define jffs2_sum_move_collected(a,b) do { } while (0)
223#define jffs2_sum_write_sumnode(a) (0)
224#define jffs2_sum_add_padding_mem(a,b) do { } while (0)
225#define jffs2_sum_add_inode_mem(a,b,c) do { } while (0)
226#define jffs2_sum_add_dirent_mem(a,b,c) do { } while (0)
227#define jffs2_sum_add_xattr_mem(a,b,c) do { } while (0)
228#define jffs2_sum_add_xref_mem(a,b,c) do { } while (0)
229#define jffs2_sum_scan_sumnode(a,b,c,d,e) (0)
230
231#endif /* CONFIG_JFFS2_SUMMARY */
232
233#endif /* JFFS2_SUMMARY_H */
Definition: xnandpsu_onfi.h:185
Definition: nodelist.h:278
Definition: jffs2.h:109
Definition: jffs2.h:133
Definition: jffs2.h:186
Definition: jffs2.h:158
Definition: jffs2.h:174
Definition: jffs2_fs_sb.h:51
Definition: summary.h:64
Definition: summary.h:119
Definition: summary.h:55
Definition: summary.h:109
Definition: summary.h:174
Definition: summary.h:50
Definition: summary.h:103
Definition: summary.h:77
Definition: summary.h:133
Definition: summary.h:86
Definition: summary.h:143
Definition: summary.h:161
Definition: summary.h:92
Definition: summary.h:150