xref: /openbmc/u-boot/fs/jffs2/summary.h (revision 9017d932)
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 #define BLK_STATE_ALLFF		0
17 #define BLK_STATE_CLEAN		1
18 #define BLK_STATE_PARTDIRTY	2
19 #define BLK_STATE_CLEANMARKER	3
20 #define BLK_STATE_ALLDIRTY	4
21 #define BLK_STATE_BADBLOCK	5
22 
23 #define JFFS2_SUMMARY_NOSUM_SIZE 0xffffffff
24 #define JFFS2_SUMMARY_INODE_SIZE (sizeof(struct jffs2_sum_inode_flash))
25 #define JFFS2_SUMMARY_DIRENT_SIZE(x) (sizeof(struct jffs2_sum_dirent_flash) + (x))
26 #define JFFS2_SUMMARY_XATTR_SIZE (sizeof(struct jffs2_sum_xattr_flash))
27 #define JFFS2_SUMMARY_XREF_SIZE (sizeof(struct jffs2_sum_xref_flash))
28 
29 /* Summary structures used on flash */
30 
31 struct jffs2_sum_unknown_flash
32 {
33 	__u16 nodetype;	/* node type */
34 };
35 
36 struct jffs2_sum_inode_flash
37 {
38 	__u16 nodetype;	/* node type */
39 	__u32 inode;		/* inode number */
40 	__u32 version;	/* inode version */
41 	__u32 offset;	/* offset on jeb */
42 	__u32 totlen; 	/* record length */
43 } __attribute__((packed));
44 
45 struct jffs2_sum_dirent_flash
46 {
47 	__u16 nodetype;	/* == JFFS_NODETYPE_DIRENT */
48 	__u32 totlen;	/* record length */
49 	__u32 offset;	/* offset on jeb */
50 	__u32 pino;		/* parent inode */
51 	__u32 version;	/* dirent version */
52 	__u32 ino; 		/* == zero for unlink */
53 	uint8_t nsize;		/* dirent name size */
54 	uint8_t type;		/* dirent type */
55 	uint8_t name[0];	/* dirent name */
56 } __attribute__((packed));
57 
58 struct jffs2_sum_xattr_flash
59 {
60 	__u16 nodetype;	/* == JFFS2_NODETYPE_XATR */
61 	__u32 xid;		/* xattr identifier */
62 	__u32 version;	/* version number */
63 	__u32 offset;	/* offset on jeb */
64 	__u32 totlen;	/* node length */
65 } __attribute__((packed));
66 
67 struct jffs2_sum_xref_flash
68 {
69 	__u16 nodetype;	/* == JFFS2_NODETYPE_XREF */
70 	__u32 offset;	/* offset on jeb */
71 } __attribute__((packed));
72 
73 union jffs2_sum_flash
74 {
75 	struct jffs2_sum_unknown_flash u;
76 	struct jffs2_sum_inode_flash i;
77 	struct jffs2_sum_dirent_flash d;
78 	struct jffs2_sum_xattr_flash x;
79 	struct jffs2_sum_xref_flash r;
80 };
81 
82 /* Summary structures used in the memory */
83 
84 struct jffs2_sum_unknown_mem
85 {
86 	union jffs2_sum_mem *next;
87 	__u16 nodetype;	/* node type */
88 };
89 
90 struct jffs2_sum_inode_mem
91 {
92 	union jffs2_sum_mem *next;
93 	__u16 nodetype;	/* node type */
94 	__u32 inode;		/* inode number */
95 	__u32 version;	/* inode version */
96 	__u32 offset;	/* offset on jeb */
97 	__u32 totlen; 	/* record length */
98 } __attribute__((packed));
99 
100 struct jffs2_sum_dirent_mem
101 {
102 	union jffs2_sum_mem *next;
103 	__u16 nodetype;	/* == JFFS_NODETYPE_DIRENT */
104 	__u32 totlen;	/* record length */
105 	__u32 offset;	/* ofset on jeb */
106 	__u32 pino;		/* parent inode */
107 	__u32 version;	/* dirent version */
108 	__u32 ino; 		/* == zero for unlink */
109 	uint8_t nsize;		/* dirent name size */
110 	uint8_t type;		/* dirent type */
111 	uint8_t name[0];	/* dirent name */
112 } __attribute__((packed));
113 
114 struct jffs2_sum_xattr_mem
115 {
116 	union jffs2_sum_mem *next;
117 	__u16 nodetype;
118 	__u32 xid;
119 	__u32 version;
120 	__u32 offset;
121 	__u32 totlen;
122 } __attribute__((packed));
123 
124 struct jffs2_sum_xref_mem
125 {
126 	union jffs2_sum_mem *next;
127 	__u16 nodetype;
128 	__u32 offset;
129 } __attribute__((packed));
130 
131 union jffs2_sum_mem
132 {
133 	struct jffs2_sum_unknown_mem u;
134 	struct jffs2_sum_inode_mem i;
135 	struct jffs2_sum_dirent_mem d;
136 	struct jffs2_sum_xattr_mem x;
137 	struct jffs2_sum_xref_mem r;
138 };
139 
140 /* Summary related information stored in superblock */
141 
142 struct jffs2_summary
143 {
144 	uint32_t sum_size;      /* collected summary information for nextblock */
145 	uint32_t sum_num;
146 	uint32_t sum_padded;
147 	union jffs2_sum_mem *sum_list_head;
148 	union jffs2_sum_mem *sum_list_tail;
149 
150 	__u32 *sum_buf;	/* buffer for writing out summary */
151 };
152 
153 /* Summary marker is stored at the end of every sumarized erase block */
154 
155 struct jffs2_sum_marker
156 {
157 	__u32 offset;	/* offset of the summary node in the jeb */
158 	__u32 magic; 	/* == JFFS2_SUM_MAGIC */
159 };
160 
161 #define JFFS2_SUMMARY_FRAME_SIZE (sizeof(struct jffs2_raw_summary) + sizeof(struct jffs2_sum_marker))
162 
163 #endif /* JFFS2_SUMMARY_H */
164