]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - include/jffs2/jffs2.h
* Fix debug code in omap5912osk flash driver
[karo-tx-uboot.git] / include / jffs2 / jffs2.h
1 /*
2  * JFFS2 -- Journalling Flash File System, Version 2.
3  *
4  * Copyright (C) 2001 Red Hat, Inc.
5  *
6  * Created by David Woodhouse <dwmw2@cambridge.redhat.com>
7  *
8  * The original JFFS, from which the design for JFFS2 was derived,
9  * was designed and implemented by Axis Communications AB.
10  *
11  * The contents of this file are subject to the Red Hat eCos Public
12  * License Version 1.1 (the "Licence"); you may not use this file
13  * except in compliance with the Licence.  You may obtain a copy of
14  * the Licence at http://www.redhat.com/
15  *
16  * Software distributed under the Licence is distributed on an "AS IS"
17  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
18  * See the Licence for the specific language governing rights and
19  * limitations under the Licence.
20  *
21  * The Original Code is JFFS2 - Journalling Flash File System, version 2
22  *
23  * Alternatively, the contents of this file may be used under the
24  * terms of the GNU General Public License version 2 (the "GPL"), in
25  * which case the provisions of the GPL are applicable instead of the
26  * above.  If you wish to allow the use of your version of this file
27  * only under the terms of the GPL and not to allow others to use your
28  * version of this file under the RHEPL, indicate your decision by
29  * deleting the provisions above and replace them with the notice and
30  * other provisions required by the GPL.  If you do not delete the
31  * provisions above, a recipient may use your version of this file
32  * under either the RHEPL or the GPL.
33  *
34  * $Id: jffs2.h,v 1.2 2002/01/17 00:53:20 nyet Exp $
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 /* Values we may expect to find in the 'magic' field */
47 #define JFFS2_OLD_MAGIC_BITMASK 0x1984
48 #define JFFS2_MAGIC_BITMASK 0x1985
49 #define KSAMTIB_CIGAM_2SFFJ 0x5981 /* For detecting wrong-endian fs */
50 #define JFFS2_EMPTY_BITMASK 0xffff
51 #define JFFS2_DIRTY_BITMASK 0x0000
52
53 /* We only allow a single char for length, and 0xFF is empty flash so
54    we don't want it confused with a real length. Hence max 254.
55 */
56 #define JFFS2_MAX_NAME_LEN 254
57
58 /* How small can we sensibly write nodes? */
59 #define JFFS2_MIN_DATA_LEN 128
60
61 #define JFFS2_COMPR_NONE        0x00
62 #define JFFS2_COMPR_ZERO        0x01
63 #define JFFS2_COMPR_RTIME       0x02
64 #define JFFS2_COMPR_RUBINMIPS   0x03
65 #define JFFS2_COMPR_COPY        0x04
66 #define JFFS2_COMPR_DYNRUBIN    0x05
67 #define JFFS2_COMPR_ZLIB        0x06
68 #if defined(CONFIG_JFFS2_LZO_LZARI)
69 #define JFFS2_COMPR_LZO         0x07
70 #define JFFS2_COMPR_LZARI       0x08
71 #define JFFS2_NUM_COMPR         9
72 #else
73 #define JFFS2_NUM_COMPR         7
74 #endif
75
76 /* Compatibility flags. */
77 #define JFFS2_COMPAT_MASK 0xc000      /* What do to if an unknown nodetype is found */
78 #define JFFS2_NODE_ACCURATE 0x2000
79 /* INCOMPAT: Fail to mount the filesystem */
80 #define JFFS2_FEATURE_INCOMPAT 0xc000
81 /* ROCOMPAT: Mount read-only */
82 #define JFFS2_FEATURE_ROCOMPAT 0x8000
83 /* RWCOMPAT_COPY: Mount read/write, and copy the node when it's GC'd */
84 #define JFFS2_FEATURE_RWCOMPAT_COPY 0x4000
85 /* RWCOMPAT_DELETE: Mount read/write, and delete the node when it's GC'd */
86 #define JFFS2_FEATURE_RWCOMPAT_DELETE 0x0000
87
88 #define JFFS2_NODETYPE_DIRENT (JFFS2_FEATURE_INCOMPAT | JFFS2_NODE_ACCURATE | 1)
89 #define JFFS2_NODETYPE_INODE (JFFS2_FEATURE_INCOMPAT | JFFS2_NODE_ACCURATE | 2)
90 #define JFFS2_NODETYPE_CLEANMARKER (JFFS2_FEATURE_RWCOMPAT_DELETE | JFFS2_NODE_ACCURATE | 3)
91 #define JFFS2_NODETYPE_PADDING (JFFS2_FEATURE_RWCOMPAT_DELETE | JFFS2_NODE_ACCURATE | 4)
92
93 /* Maybe later... */
94 /*#define JFFS2_NODETYPE_CHECKPOINT (JFFS2_FEATURE_RWCOMPAT_DELETE | JFFS2_NODE_ACCURATE | 3) */
95 /*#define JFFS2_NODETYPE_OPTIONS (JFFS2_FEATURE_RWCOMPAT_COPY | JFFS2_NODE_ACCURATE | 4) */
96
97 /* Same as the non_ECC versions, but with extra space for real
98  * ECC instead of just the checksum. For use on NAND flash
99  */
100 /*#define JFFS2_NODETYPE_DIRENT_ECC (JFFS2_FEATURE_INCOMPAT | JFFS2_NODE_ACCURATE | 5) */
101 /*#define JFFS2_NODETYPE_INODE_ECC (JFFS2_FEATURE_INCOMPAT | JFFS2_NODE_ACCURATE | 6) */
102
103 #define JFFS2_INO_FLAG_PREREAD    1     /* Do read_inode() for this one at
104                                            mount time, don't wait for it to
105                                            happen later */
106 #define JFFS2_INO_FLAG_USERCOMPR  2     /* User has requested a specific
107                                            compression type */
108
109
110 struct jffs2_unknown_node
111 {
112         /* All start like this */
113         __u16 magic;
114         __u16 nodetype;
115         __u32 totlen; /* So we can skip over nodes we don't grok */
116         __u32 hdr_crc;
117 } __attribute__((packed));
118
119 struct jffs2_raw_dirent
120 {
121         __u16 magic;
122         __u16 nodetype; /* == JFFS_NODETYPE_DIRENT */
123         __u32 totlen;
124         __u32 hdr_crc;
125         __u32 pino;
126         __u32 version;
127         __u32 ino; /* == zero for unlink */
128         __u32 mctime;
129         __u8 nsize;
130         __u8 type;
131         __u8 unused[2];
132         __u32 node_crc;
133         __u32 name_crc;
134         __u8 name[0];
135 } __attribute__((packed));
136
137 /* The JFFS2 raw inode structure: Used for storage on physical media.  */
138 /* The uid, gid, atime, mtime and ctime members could be longer, but
139    are left like this for space efficiency. If and when people decide
140    they really need them extended, it's simple enough to add support for
141    a new type of raw node.
142 */
143 struct jffs2_raw_inode
144 {
145         __u16 magic;      /* A constant magic number.  */
146         __u16 nodetype;   /* == JFFS_NODETYPE_INODE */
147         __u32 totlen;     /* Total length of this node (inc data, etc.) */
148         __u32 hdr_crc;
149         __u32 ino;        /* Inode number.  */
150         __u32 version;    /* Version number.  */
151         __u32 mode;       /* The file's type or mode.  */
152         __u16 uid;        /* The file's owner.  */
153         __u16 gid;        /* The file's group.  */
154         __u32 isize;      /* Total resultant size of this inode (used for truncations)  */
155         __u32 atime;      /* Last access time.  */
156         __u32 mtime;      /* Last modification time.  */
157         __u32 ctime;      /* Change time.  */
158         __u32 offset;     /* Where to begin to write.  */
159         __u32 csize;      /* (Compressed) data size */
160         __u32 dsize;      /* Size of the node's data. (after decompression) */
161         __u8 compr;       /* Compression algorithm used */
162         __u8 usercompr;   /* Compression algorithm requested by the user */
163         __u16 flags;      /* See JFFS2_INO_FLAG_* */
164         __u32 data_crc;   /* CRC for the (compressed) data.  */
165         __u32 node_crc;   /* CRC for the raw inode (excluding data)  */
166 /*      __u8 data[dsize]; */
167 } __attribute__((packed));
168
169 union jffs2_node_union {
170         struct jffs2_raw_inode i;
171         struct jffs2_raw_dirent d;
172         struct jffs2_unknown_node u;
173 } __attribute__((packed));
174
175 enum
176   {
177     DT_UNKNOWN = 0,
178 # define DT_UNKNOWN     DT_UNKNOWN
179     DT_FIFO = 1,
180 # define DT_FIFO        DT_FIFO
181     DT_CHR = 2,
182 # define DT_CHR         DT_CHR
183     DT_DIR = 4,
184 # define DT_DIR         DT_DIR
185     DT_BLK = 6,
186 # define DT_BLK         DT_BLK
187     DT_REG = 8,
188 # define DT_REG         DT_REG
189     DT_LNK = 10,
190 # define DT_LNK         DT_LNK
191     DT_SOCK = 12,
192 # define DT_SOCK        DT_SOCK
193     DT_WHT = 14
194 # define DT_WHT         DT_WHT
195   };
196
197
198 u32 jffs2_1pass_ls(struct part_info *part,const char *fname);
199 u32 jffs2_1pass_load(char *dest, struct part_info *part,const char *fname);
200 u32 jffs2_1pass_info(struct part_info *part);
201
202 void rtime_decompress(unsigned char *data_in, unsigned char *cpage_out,
203                 u32 srclen, u32 destlen);
204 void rubin_do_decompress(unsigned char *bits, unsigned char *in,
205                 unsigned char *page_out, __u32 destlen);
206 void dynrubin_decompress(unsigned char *data_in, unsigned char *cpage_out,
207                 unsigned long sourcelen, unsigned long dstlen);
208 long zlib_decompress(unsigned char *data_in, unsigned char *cpage_out,
209                 __u32 srclen, __u32 destlen);
210 #if defined(CONFIG_JFFS2_LZO_LZARI)
211 int lzo_decompress(unsigned char *data_in, unsigned char *cpage_out,
212                 u32 srclen, u32 destlen);
213 int lzari_decompress(unsigned char *data_in, unsigned char *cpage_out,
214                 u32 srclen, u32 destlen);
215 #endif
216
217 char *mkmodestr(unsigned long mode, char *str);
218 #endif /* __LINUX_JFFS2_H__ */