1
2
3
4
5
6
7
8
9
10
11
12
13 #ifndef __LINUX_JFFS2_H__
14 #define __LINUX_JFFS2_H__
15
16 #include <linux/types.h>
17 #include <linux/magic.h>
18
19
20
21
22
23
24 #define JFFS2_OLD_MAGIC_BITMASK 0x1984
25 #define JFFS2_MAGIC_BITMASK 0x1985
26 #define KSAMTIB_CIGAM_2SFFJ 0x8519
27 #define JFFS2_EMPTY_BITMASK 0xffff
28 #define JFFS2_DIRTY_BITMASK 0x0000
29
30
31 #define JFFS2_SUM_MAGIC 0x02851885
32
33
34
35
36 #define JFFS2_MAX_NAME_LEN 254
37
38
39 #define JFFS2_MIN_DATA_LEN 128
40
41 #define JFFS2_COMPR_NONE 0x00
42 #define JFFS2_COMPR_ZERO 0x01
43 #define JFFS2_COMPR_RTIME 0x02
44 #define JFFS2_COMPR_RUBINMIPS 0x03
45 #define JFFS2_COMPR_COPY 0x04
46 #define JFFS2_COMPR_DYNRUBIN 0x05
47 #define JFFS2_COMPR_ZLIB 0x06
48 #define JFFS2_COMPR_LZO 0x07
49
50 #define JFFS2_COMPAT_MASK 0xc000
51 #define JFFS2_NODE_ACCURATE 0x2000
52
53 #define JFFS2_FEATURE_INCOMPAT 0xc000
54
55 #define JFFS2_FEATURE_ROCOMPAT 0x8000
56
57 #define JFFS2_FEATURE_RWCOMPAT_COPY 0x4000
58
59 #define JFFS2_FEATURE_RWCOMPAT_DELETE 0x0000
60
61 #define JFFS2_NODETYPE_DIRENT (JFFS2_FEATURE_INCOMPAT | JFFS2_NODE_ACCURATE | 1)
62 #define JFFS2_NODETYPE_INODE (JFFS2_FEATURE_INCOMPAT | JFFS2_NODE_ACCURATE | 2)
63 #define JFFS2_NODETYPE_CLEANMARKER (JFFS2_FEATURE_RWCOMPAT_DELETE | JFFS2_NODE_ACCURATE | 3)
64 #define JFFS2_NODETYPE_PADDING (JFFS2_FEATURE_RWCOMPAT_DELETE | JFFS2_NODE_ACCURATE | 4)
65
66 #define JFFS2_NODETYPE_SUMMARY (JFFS2_FEATURE_RWCOMPAT_DELETE | JFFS2_NODE_ACCURATE | 6)
67
68 #define JFFS2_NODETYPE_XATTR (JFFS2_FEATURE_INCOMPAT | JFFS2_NODE_ACCURATE | 8)
69 #define JFFS2_NODETYPE_XREF (JFFS2_FEATURE_INCOMPAT | JFFS2_NODE_ACCURATE | 9)
70
71
72 #define JFFS2_XPREFIX_USER 1
73 #define JFFS2_XPREFIX_SECURITY 2
74 #define JFFS2_XPREFIX_ACL_ACCESS 3
75 #define JFFS2_XPREFIX_ACL_DEFAULT 4
76 #define JFFS2_XPREFIX_TRUSTED 5
77
78 #define JFFS2_ACL_VERSION 0x0001
79
80 #define JFFS2_INO_FLAG_PREREAD 1
81
82
83 #define JFFS2_INO_FLAG_USERCOMPR 2
84
85
86
87
88
89
90 typedef struct {
91 __u32 v32;
92 } __attribute__((packed)) jint32_t;
93
94 typedef struct {
95 __u32 m;
96 } __attribute__((packed)) jmode_t;
97
98 typedef struct {
99 __u16 v16;
100 } __attribute__((packed)) jint16_t;
101
102 struct jffs2_unknown_node
103 {
104
105 jint16_t magic;
106 jint16_t nodetype;
107 jint32_t totlen;
108 jint32_t hdr_crc;
109 };
110
111 struct jffs2_raw_dirent
112 {
113 jint16_t magic;
114 jint16_t nodetype;
115 jint32_t totlen;
116 jint32_t hdr_crc;
117 jint32_t pino;
118 jint32_t version;
119 jint32_t ino;
120 jint32_t mctime;
121 __u8 nsize;
122 __u8 type;
123 __u8 unused[2];
124 jint32_t node_crc;
125 jint32_t name_crc;
126 __u8 name[0];
127 };
128
129
130
131
132
133
134
135 struct jffs2_raw_inode
136 {
137 jint16_t magic;
138 jint16_t nodetype;
139 jint32_t totlen;
140 jint32_t hdr_crc;
141 jint32_t ino;
142 jint32_t version;
143 jmode_t mode;
144 jint16_t uid;
145 jint16_t gid;
146 jint32_t isize;
147 jint32_t atime;
148 jint32_t mtime;
149 jint32_t ctime;
150 jint32_t offset;
151 jint32_t csize;
152 jint32_t dsize;
153 __u8 compr;
154 __u8 usercompr;
155 jint16_t flags;
156 jint32_t data_crc;
157 jint32_t node_crc;
158 __u8 data[0];
159 };
160
161 struct jffs2_raw_xattr {
162 jint16_t magic;
163 jint16_t nodetype;
164 jint32_t totlen;
165 jint32_t hdr_crc;
166 jint32_t xid;
167 jint32_t version;
168 __u8 xprefix;
169 __u8 name_len;
170 jint16_t value_len;
171 jint32_t data_crc;
172 jint32_t node_crc;
173 __u8 data[0];
174 } __attribute__((packed));
175
176 struct jffs2_raw_xref
177 {
178 jint16_t magic;
179 jint16_t nodetype;
180 jint32_t totlen;
181 jint32_t hdr_crc;
182 jint32_t ino;
183 jint32_t xid;
184 jint32_t xseqno;
185 jint32_t node_crc;
186 } __attribute__((packed));
187
188 struct jffs2_raw_summary
189 {
190 jint16_t magic;
191 jint16_t nodetype;
192 jint32_t totlen;
193 jint32_t hdr_crc;
194 jint32_t sum_num;
195 jint32_t cln_mkr;
196 jint32_t padded;
197 jint32_t sum_crc;
198 jint32_t node_crc;
199 jint32_t sum[0];
200 };
201
202 union jffs2_node_union
203 {
204 struct jffs2_raw_inode i;
205 struct jffs2_raw_dirent d;
206 struct jffs2_raw_xattr x;
207 struct jffs2_raw_xref r;
208 struct jffs2_raw_summary s;
209 struct jffs2_unknown_node u;
210 };
211
212
213 union jffs2_device_node {
214 jint16_t old_id;
215 jint32_t new_id;
216 };
217
218 #endif