1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38#ifndef __LINUX_JFFS2_H__
39#define __LINUX_JFFS2_H__
40
41#include <asm/types.h>
42#include <jffs2/load_kernel.h>
43
44#define JFFS2_SUPER_MAGIC 0x72b6
45
46
47#define JFFS2_OLD_MAGIC_BITMASK 0x1984
48#define JFFS2_MAGIC_BITMASK 0x1985
49#define KSAMTIB_CIGAM_2SFFJ 0x5981
50#define JFFS2_EMPTY_BITMASK 0xffff
51#define JFFS2_DIRTY_BITMASK 0x0000
52
53
54#define JFFS2_SUM_MAGIC 0x02851885
55
56
57
58
59#define JFFS2_MAX_NAME_LEN 254
60
61
62#define JFFS2_MIN_DATA_LEN 128
63
64#define JFFS2_COMPR_NONE 0x00
65#define JFFS2_COMPR_ZERO 0x01
66#define JFFS2_COMPR_RTIME 0x02
67#define JFFS2_COMPR_RUBINMIPS 0x03
68#define JFFS2_COMPR_COPY 0x04
69#define JFFS2_COMPR_DYNRUBIN 0x05
70#define JFFS2_COMPR_ZLIB 0x06
71#if defined(CONFIG_JFFS2_LZO)
72#define JFFS2_COMPR_LZO 0x07
73#define JFFS2_NUM_COMPR 8
74#else
75#define JFFS2_NUM_COMPR 7
76#endif
77
78
79#define JFFS2_COMPAT_MASK 0xc000
80#define JFFS2_NODE_ACCURATE 0x2000
81
82#define JFFS2_FEATURE_INCOMPAT 0xc000
83
84#define JFFS2_FEATURE_ROCOMPAT 0x8000
85
86#define JFFS2_FEATURE_RWCOMPAT_COPY 0x4000
87
88#define JFFS2_FEATURE_RWCOMPAT_DELETE 0x0000
89
90#define JFFS2_NODETYPE_DIRENT (JFFS2_FEATURE_INCOMPAT | JFFS2_NODE_ACCURATE | 1)
91#define JFFS2_NODETYPE_INODE (JFFS2_FEATURE_INCOMPAT | JFFS2_NODE_ACCURATE | 2)
92#define JFFS2_NODETYPE_CLEANMARKER (JFFS2_FEATURE_RWCOMPAT_DELETE | JFFS2_NODE_ACCURATE | 3)
93#define JFFS2_NODETYPE_PADDING (JFFS2_FEATURE_RWCOMPAT_DELETE | JFFS2_NODE_ACCURATE | 4)
94#define JFFS2_NODETYPE_SUMMARY (JFFS2_FEATURE_RWCOMPAT_DELETE | JFFS2_NODE_ACCURATE | 6)
95
96
97
98
99
100
101
102
103
104
105
106#define JFFS2_INO_FLAG_PREREAD 1
107
108
109#define JFFS2_INO_FLAG_USERCOMPR 2
110
111
112
113struct jffs2_unknown_node
114{
115
116 __u16 magic;
117 __u16 nodetype;
118 __u32 totlen;
119 __u32 hdr_crc;
120} __attribute__((packed));
121
122struct jffs2_raw_dirent
123{
124 __u16 magic;
125 __u16 nodetype;
126 __u32 totlen;
127 __u32 hdr_crc;
128 __u32 pino;
129 __u32 version;
130 __u32 ino;
131 __u32 mctime;
132 __u8 nsize;
133 __u8 type;
134 __u8 unused[2];
135 __u32 node_crc;
136 __u32 name_crc;
137 __u8 name[0];
138} __attribute__((packed));
139
140
141
142
143
144
145
146struct jffs2_raw_inode
147{
148 __u16 magic;
149 __u16 nodetype;
150 __u32 totlen;
151 __u32 hdr_crc;
152 __u32 ino;
153 __u32 version;
154 __u32 mode;
155 __u16 uid;
156 __u16 gid;
157 __u32 isize;
158 __u32 atime;
159 __u32 mtime;
160 __u32 ctime;
161 __u32 offset;
162 __u32 csize;
163 __u32 dsize;
164 __u8 compr;
165 __u8 usercompr;
166 __u16 flags;
167 __u32 data_crc;
168 __u32 node_crc;
169
170} __attribute__((packed));
171
172struct jffs2_raw_summary
173{
174 __u16 magic;
175 __u16 nodetype;
176 __u32 totlen;
177 __u32 hdr_crc;
178 __u32 sum_num;
179 __u32 cln_mkr;
180 __u32 padded;
181 __u32 sum_crc;
182 __u32 node_crc;
183 __u32 sum[0];
184};
185
186union jffs2_node_union {
187 struct jffs2_raw_inode i;
188 struct jffs2_raw_dirent d;
189 struct jffs2_raw_summary s;
190 struct jffs2_unknown_node u;
191} __attribute__((packed));
192
193enum
194 {
195 DT_UNKNOWN = 0,
196# define DT_UNKNOWN DT_UNKNOWN
197 DT_FIFO = 1,
198# define DT_FIFO DT_FIFO
199 DT_CHR = 2,
200# define DT_CHR DT_CHR
201 DT_DIR = 4,
202# define DT_DIR DT_DIR
203 DT_BLK = 6,
204# define DT_BLK DT_BLK
205 DT_REG = 8,
206# define DT_REG DT_REG
207 DT_LNK = 10,
208# define DT_LNK DT_LNK
209 DT_SOCK = 12,
210# define DT_SOCK DT_SOCK
211 DT_WHT = 14
212# define DT_WHT DT_WHT
213 };
214
215
216u32 jffs2_1pass_ls(struct part_info *part,const char *fname);
217u32 jffs2_1pass_load(char *dest, struct part_info *part,const char *fname);
218u32 jffs2_1pass_info(struct part_info *part);
219
220void rtime_decompress(unsigned char *data_in, unsigned char *cpage_out,
221 u32 srclen, u32 destlen);
222void rubin_do_decompress(unsigned char *bits, unsigned char *in,
223 unsigned char *page_out, __u32 destlen);
224void dynrubin_decompress(unsigned char *data_in, unsigned char *cpage_out,
225 unsigned long sourcelen, unsigned long dstlen);
226long zlib_decompress(unsigned char *data_in, unsigned char *cpage_out,
227 __u32 srclen, __u32 destlen);
228#if defined(CONFIG_JFFS2_LZO)
229int lzo_decompress(unsigned char *data_in, unsigned char *cpage_out,
230 u32 srclen, u32 destlen);
231#endif
232
233char *mkmodestr(unsigned long mode, char *str);
234#endif
235