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_LZARI)
72#define JFFS2_COMPR_LZO 0x07
73#define JFFS2_COMPR_LZARI 0x08
74#define JFFS2_NUM_COMPR 9
75#else
76#define JFFS2_NUM_COMPR 7
77#endif
78
79
80#define JFFS2_COMPAT_MASK 0xc000
81#define JFFS2_NODE_ACCURATE 0x2000
82
83#define JFFS2_FEATURE_INCOMPAT 0xc000
84
85#define JFFS2_FEATURE_ROCOMPAT 0x8000
86
87#define JFFS2_FEATURE_RWCOMPAT_COPY 0x4000
88
89#define JFFS2_FEATURE_RWCOMPAT_DELETE 0x0000
90
91#define JFFS2_NODETYPE_DIRENT (JFFS2_FEATURE_INCOMPAT | JFFS2_NODE_ACCURATE | 1)
92#define JFFS2_NODETYPE_INODE (JFFS2_FEATURE_INCOMPAT | JFFS2_NODE_ACCURATE | 2)
93#define JFFS2_NODETYPE_CLEANMARKER (JFFS2_FEATURE_RWCOMPAT_DELETE | JFFS2_NODE_ACCURATE | 3)
94#define JFFS2_NODETYPE_PADDING (JFFS2_FEATURE_RWCOMPAT_DELETE | JFFS2_NODE_ACCURATE | 4)
95#define JFFS2_NODETYPE_SUMMARY (JFFS2_FEATURE_RWCOMPAT_DELETE | JFFS2_NODE_ACCURATE | 6)
96
97
98
99
100
101
102
103
104
105
106
107#define JFFS2_INO_FLAG_PREREAD 1
108
109
110#define JFFS2_INO_FLAG_USERCOMPR 2
111
112
113
114struct jffs2_unknown_node
115{
116
117 __u16 magic;
118 __u16 nodetype;
119 __u32 totlen;
120 __u32 hdr_crc;
121} __attribute__((packed));
122
123struct jffs2_raw_dirent
124{
125 __u16 magic;
126 __u16 nodetype;
127 __u32 totlen;
128 __u32 hdr_crc;
129 __u32 pino;
130 __u32 version;
131 __u32 ino;
132 __u32 mctime;
133 __u8 nsize;
134 __u8 type;
135 __u8 unused[2];
136 __u32 node_crc;
137 __u32 name_crc;
138 __u8 name[0];
139} __attribute__((packed));
140
141
142
143
144
145
146
147struct jffs2_raw_inode
148{
149 __u16 magic;
150 __u16 nodetype;
151 __u32 totlen;
152 __u32 hdr_crc;
153 __u32 ino;
154 __u32 version;
155 __u32 mode;
156 __u16 uid;
157 __u16 gid;
158 __u32 isize;
159 __u32 atime;
160 __u32 mtime;
161 __u32 ctime;
162 __u32 offset;
163 __u32 csize;
164 __u32 dsize;
165 __u8 compr;
166 __u8 usercompr;
167 __u16 flags;
168 __u32 data_crc;
169 __u32 node_crc;
170
171} __attribute__((packed));
172
173struct jffs2_raw_summary
174{
175 __u16 magic;
176 __u16 nodetype;
177 __u32 totlen;
178 __u32 hdr_crc;
179 __u32 sum_num;
180 __u32 cln_mkr;
181 __u32 padded;
182 __u32 sum_crc;
183 __u32 node_crc;
184 __u32 sum[0];
185};
186
187union jffs2_node_union {
188 struct jffs2_raw_inode i;
189 struct jffs2_raw_dirent d;
190 struct jffs2_raw_summary s;
191 struct jffs2_unknown_node u;
192} __attribute__((packed));
193
194enum
195 {
196 DT_UNKNOWN = 0,
197# define DT_UNKNOWN DT_UNKNOWN
198 DT_FIFO = 1,
199# define DT_FIFO DT_FIFO
200 DT_CHR = 2,
201# define DT_CHR DT_CHR
202 DT_DIR = 4,
203# define DT_DIR DT_DIR
204 DT_BLK = 6,
205# define DT_BLK DT_BLK
206 DT_REG = 8,
207# define DT_REG DT_REG
208 DT_LNK = 10,
209# define DT_LNK DT_LNK
210 DT_SOCK = 12,
211# define DT_SOCK DT_SOCK
212 DT_WHT = 14
213# define DT_WHT DT_WHT
214 };
215
216
217u32 jffs2_1pass_ls(struct part_info *part,const char *fname);
218u32 jffs2_1pass_load(char *dest, struct part_info *part,const char *fname);
219u32 jffs2_1pass_info(struct part_info *part);
220
221void rtime_decompress(unsigned char *data_in, unsigned char *cpage_out,
222 u32 srclen, u32 destlen);
223void rubin_do_decompress(unsigned char *bits, unsigned char *in,
224 unsigned char *page_out, __u32 destlen);
225void dynrubin_decompress(unsigned char *data_in, unsigned char *cpage_out,
226 unsigned long sourcelen, unsigned long dstlen);
227long zlib_decompress(unsigned char *data_in, unsigned char *cpage_out,
228 __u32 srclen, __u32 destlen);
229#if defined(CONFIG_JFFS2_LZO_LZARI)
230int lzo_decompress(unsigned char *data_in, unsigned char *cpage_out,
231 u32 srclen, u32 destlen);
232int lzari_decompress(unsigned char *data_in, unsigned char *cpage_out,
233 u32 srclen, u32 destlen);
234#endif
235
236char *mkmodestr(unsigned long mode, char *str);
237#endif
238