OpenWrt – Blame information for rev 4
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
4 | office | 1 | /* |
2 | * JFFS2 -- Journalling Flash File System, Version 2. |
||
3 | * |
||
4 | * Copyright (C) 2001-2003 Red Hat, Inc. |
||
5 | * |
||
6 | * Created by David Woodhouse <dwmw2@infradead.org> |
||
7 | * |
||
8 | * For licensing information, see the file 'LICENCE' in the |
||
9 | * jffs2 directory. |
||
10 | * |
||
11 | * |
||
12 | */ |
||
13 | |||
14 | #ifndef __LINUX_JFFS2_H__ |
||
15 | #define __LINUX_JFFS2_H__ |
||
16 | |||
17 | #define JFFS2_SUPER_MAGIC 0x72b6 |
||
18 | |||
19 | /* You must include something which defines the C99 uintXX_t types. |
||
20 | We don't do it from here because this file is used in too many |
||
21 | different environments. */ |
||
22 | |||
23 | /* Values we may expect to find in the 'magic' field */ |
||
24 | #define JFFS2_OLD_MAGIC_BITMASK 0x1984 |
||
25 | #define JFFS2_MAGIC_BITMASK 0x1985 |
||
26 | #define KSAMTIB_CIGAM_2SFFJ 0x8519 /* For detecting wrong-endian fs */ |
||
27 | #define JFFS2_EMPTY_BITMASK 0xffff |
||
28 | #define JFFS2_DIRTY_BITMASK 0x0000 |
||
29 | |||
30 | /* Summary node MAGIC marker */ |
||
31 | #define JFFS2_SUM_MAGIC 0x02851885 |
||
32 | |||
33 | /* We only allow a single char for length, and 0xFF is empty flash so |
||
34 | we don't want it confused with a real length. Hence max 254. |
||
35 | */ |
||
36 | #define JFFS2_MAX_NAME_LEN 254 |
||
37 | |||
38 | /* How small can we sensibly write nodes? */ |
||
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 | /* Compatibility flags. */ |
||
49 | #define JFFS2_COMPAT_MASK 0xc000 /* What do to if an unknown nodetype is found */ |
||
50 | #define JFFS2_NODE_ACCURATE 0x2000 |
||
51 | /* INCOMPAT: Fail to mount the filesystem */ |
||
52 | #define JFFS2_FEATURE_INCOMPAT 0xc000 |
||
53 | /* ROCOMPAT: Mount read-only */ |
||
54 | #define JFFS2_FEATURE_ROCOMPAT 0x8000 |
||
55 | /* RWCOMPAT_COPY: Mount read/write, and copy the node when it's GC'd */ |
||
56 | #define JFFS2_FEATURE_RWCOMPAT_COPY 0x4000 |
||
57 | /* RWCOMPAT_DELETE: Mount read/write, and delete the node when it's GC'd */ |
||
58 | #define JFFS2_FEATURE_RWCOMPAT_DELETE 0x0000 |
||
59 | |||
60 | #define JFFS2_NODETYPE_DIRENT (JFFS2_FEATURE_INCOMPAT | JFFS2_NODE_ACCURATE | 1) |
||
61 | #define JFFS2_NODETYPE_INODE (JFFS2_FEATURE_INCOMPAT | JFFS2_NODE_ACCURATE | 2) |
||
62 | #define JFFS2_NODETYPE_CLEANMARKER (JFFS2_FEATURE_RWCOMPAT_DELETE | JFFS2_NODE_ACCURATE | 3) |
||
63 | #define JFFS2_NODETYPE_PADDING (JFFS2_FEATURE_RWCOMPAT_DELETE | JFFS2_NODE_ACCURATE | 4) |
||
64 | |||
65 | #define JFFS2_NODETYPE_SUMMARY (JFFS2_FEATURE_RWCOMPAT_DELETE | JFFS2_NODE_ACCURATE | 6) |
||
66 | |||
67 | #define JFFS2_NODETYPE_XATTR (JFFS2_FEATURE_INCOMPAT | JFFS2_NODE_ACCURATE | 8) |
||
68 | #define JFFS2_NODETYPE_XREF (JFFS2_FEATURE_INCOMPAT | JFFS2_NODE_ACCURATE | 9) |
||
69 | |||
70 | /* XATTR Related */ |
||
71 | #define JFFS2_XPREFIX_USER 1 /* for "user." */ |
||
72 | #define JFFS2_XPREFIX_SECURITY 2 /* for "security." */ |
||
73 | #define JFFS2_XPREFIX_ACL_ACCESS 3 /* for "system.posix_acl_access" */ |
||
74 | #define JFFS2_XPREFIX_ACL_DEFAULT 4 /* for "system.posix_acl_default" */ |
||
75 | #define JFFS2_XPREFIX_TRUSTED 5 /* for "trusted.*" */ |
||
76 | |||
77 | #define JFFS2_ACL_VERSION 0x0001 |
||
78 | |||
79 | // Maybe later... |
||
80 | //#define JFFS2_NODETYPE_CHECKPOINT (JFFS2_FEATURE_RWCOMPAT_DELETE | JFFS2_NODE_ACCURATE | 3) |
||
81 | //#define JFFS2_NODETYPE_OPTIONS (JFFS2_FEATURE_RWCOMPAT_COPY | JFFS2_NODE_ACCURATE | 4) |
||
82 | |||
83 | |||
84 | #define JFFS2_INO_FLAG_PREREAD 1 /* Do read_inode() for this one at |
||
85 | mount time, don't wait for it to |
||
86 | happen later */ |
||
87 | #define JFFS2_INO_FLAG_USERCOMPR 2 /* User has requested a specific |
||
88 | compression type */ |
||
89 | |||
90 | |||
91 | /* These can go once we've made sure we've caught all uses without |
||
92 | byteswapping */ |
||
93 | |||
94 | typedef uint32_t jint32_t; |
||
95 | |||
96 | typedef uint32_t jmode_t; |
||
97 | |||
98 | typedef uint16_t jint16_t; |
||
99 | |||
100 | struct jffs2_unknown_node |
||
101 | { |
||
102 | /* All start like this */ |
||
103 | jint16_t magic; |
||
104 | jint16_t nodetype; |
||
105 | jint32_t totlen; /* So we can skip over nodes we don't grok */ |
||
106 | jint32_t hdr_crc; |
||
107 | }; |
||
108 | |||
109 | struct jffs2_raw_dirent |
||
110 | { |
||
111 | jint16_t magic; |
||
112 | jint16_t nodetype; /* == JFFS2_NODETYPE_DIRENT */ |
||
113 | jint32_t totlen; |
||
114 | jint32_t hdr_crc; |
||
115 | jint32_t pino; |
||
116 | jint32_t version; |
||
117 | jint32_t ino; /* == zero for unlink */ |
||
118 | jint32_t mctime; |
||
119 | uint8_t nsize; |
||
120 | uint8_t type; |
||
121 | uint8_t unused[2]; |
||
122 | jint32_t node_crc; |
||
123 | jint32_t name_crc; |
||
124 | uint8_t name[0]; |
||
125 | }; |
||
126 | |||
127 | /* The JFFS2 raw inode structure: Used for storage on physical media. */ |
||
128 | /* The uid, gid, atime, mtime and ctime members could be longer, but |
||
129 | are left like this for space efficiency. If and when people decide |
||
130 | they really need them extended, it's simple enough to add support for |
||
131 | a new type of raw node. |
||
132 | */ |
||
133 | struct jffs2_raw_inode |
||
134 | { |
||
135 | jint16_t magic; /* A constant magic number. */ |
||
136 | jint16_t nodetype; /* == JFFS2_NODETYPE_INODE */ |
||
137 | jint32_t totlen; /* Total length of this node (inc data, etc.) */ |
||
138 | jint32_t hdr_crc; |
||
139 | jint32_t ino; /* Inode number. */ |
||
140 | jint32_t version; /* Version number. */ |
||
141 | jmode_t mode; /* The file's type or mode. */ |
||
142 | jint16_t uid; /* The file's owner. */ |
||
143 | jint16_t gid; /* The file's group. */ |
||
144 | jint32_t isize; /* Total resultant size of this inode (used for truncations) */ |
||
145 | jint32_t atime; /* Last access time. */ |
||
146 | jint32_t mtime; /* Last modification time. */ |
||
147 | jint32_t ctime; /* Change time. */ |
||
148 | jint32_t offset; /* Where to begin to write. */ |
||
149 | jint32_t csize; /* (Compressed) data size */ |
||
150 | jint32_t dsize; /* Size of the node's data. (after decompression) */ |
||
151 | uint8_t compr; /* Compression algorithm used */ |
||
152 | uint8_t usercompr; /* Compression algorithm requested by the user */ |
||
153 | jint16_t flags; /* See JFFS2_INO_FLAG_* */ |
||
154 | jint32_t data_crc; /* CRC for the (compressed) data. */ |
||
155 | jint32_t node_crc; /* CRC for the raw inode (excluding data) */ |
||
156 | uint8_t data[0]; |
||
157 | }; |
||
158 | |||
159 | struct jffs2_raw_xattr { |
||
160 | jint16_t magic; |
||
161 | jint16_t nodetype; /* = JFFS2_NODETYPE_XATTR */ |
||
162 | jint32_t totlen; |
||
163 | jint32_t hdr_crc; |
||
164 | jint32_t xid; /* XATTR identifier number */ |
||
165 | jint32_t version; |
||
166 | uint8_t xprefix; |
||
167 | uint8_t name_len; |
||
168 | jint16_t value_len; |
||
169 | jint32_t data_crc; |
||
170 | jint32_t node_crc; |
||
171 | uint8_t data[0]; |
||
172 | } __attribute__((packed)); |
||
173 | |||
174 | struct jffs2_raw_xref |
||
175 | { |
||
176 | jint16_t magic; |
||
177 | jint16_t nodetype; /* = JFFS2_NODETYPE_XREF */ |
||
178 | jint32_t totlen; |
||
179 | jint32_t hdr_crc; |
||
180 | jint32_t ino; /* inode number */ |
||
181 | jint32_t xid; /* XATTR identifier number */ |
||
182 | jint32_t xseqno; /* xref sequencial number */ |
||
183 | jint32_t node_crc; |
||
184 | } __attribute__((packed)); |
||
185 | |||
186 | struct jffs2_raw_summary |
||
187 | { |
||
188 | jint16_t magic; |
||
189 | jint16_t nodetype; /* = JFFS2_NODETYPE_SUMMARY */ |
||
190 | jint32_t totlen; |
||
191 | jint32_t hdr_crc; |
||
192 | jint32_t sum_num; /* number of sum entries*/ |
||
193 | jint32_t cln_mkr; /* clean marker size, 0 = no cleanmarker */ |
||
194 | jint32_t padded; /* sum of the size of padding nodes */ |
||
195 | jint32_t sum_crc; /* summary information crc */ |
||
196 | jint32_t node_crc; /* node crc */ |
||
197 | jint32_t sum[0]; /* inode summary info */ |
||
198 | }; |
||
199 | |||
200 | union jffs2_node_union |
||
201 | { |
||
202 | struct jffs2_raw_inode i; |
||
203 | struct jffs2_raw_dirent d; |
||
204 | struct jffs2_raw_xattr x; |
||
205 | struct jffs2_raw_xref r; |
||
206 | struct jffs2_raw_summary s; |
||
207 | struct jffs2_unknown_node u; |
||
208 | }; |
||
209 | |||
210 | /* Data payload for device nodes. */ |
||
211 | union jffs2_device_node { |
||
212 | jint16_t old; |
||
213 | jint32_t new; |
||
214 | }; |
||
215 | |||
216 | #endif /* __LINUX_JFFS2_H__ */ |