source: svn/trunk/newcon3bcm2_21bu/toolchain/mips-linux-uclibc/include/linux/jffs2.h

Last change on this file was 2, checked in by jglee, 11 years ago

first commit

  • Property svn:executable set to *
File size: 5.0 KB
Line 
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/* You must include something which defines the C99 uintXX_t types.
18   We don't do it from here because this file is used in too many
19   different environments. */
20
21#define JFFS2_SUPER_MAGIC 0x72b6
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/* We only allow a single char for length, and 0xFF is empty flash so
31   we don't want it confused with a real length. Hence max 254.
32*/
33#define JFFS2_MAX_NAME_LEN 254
34
35/* How small can we sensibly write nodes? */
36#define JFFS2_MIN_DATA_LEN 128
37
38#define JFFS2_COMPR_NONE        0x00
39#define JFFS2_COMPR_ZERO        0x01
40#define JFFS2_COMPR_RTIME       0x02
41#define JFFS2_COMPR_RUBINMIPS   0x03
42#define JFFS2_COMPR_COPY        0x04
43#define JFFS2_COMPR_DYNRUBIN    0x05
44#define JFFS2_COMPR_ZLIB        0x06
45#define JFFS2_COMPR_LZO         0x07
46#define JFFS2_COMPR_LZARI       0x08
47/* Compatibility flags. */
48#define JFFS2_COMPAT_MASK 0xc000      /* What do to if an unknown nodetype is found */
49#define JFFS2_NODE_ACCURATE 0x2000
50/* INCOMPAT: Fail to mount the filesystem */
51#define JFFS2_FEATURE_INCOMPAT 0xc000
52/* ROCOMPAT: Mount read-only */
53#define JFFS2_FEATURE_ROCOMPAT 0x8000
54/* RWCOMPAT_COPY: Mount read/write, and copy the node when it's GC'd */
55#define JFFS2_FEATURE_RWCOMPAT_COPY 0x4000
56/* RWCOMPAT_DELETE: Mount read/write, and delete the node when it's GC'd */
57#define JFFS2_FEATURE_RWCOMPAT_DELETE 0x0000
58
59#define JFFS2_NODETYPE_DIRENT (JFFS2_FEATURE_INCOMPAT | JFFS2_NODE_ACCURATE | 1)
60#define JFFS2_NODETYPE_INODE (JFFS2_FEATURE_INCOMPAT | JFFS2_NODE_ACCURATE | 2)
61#define JFFS2_NODETYPE_CLEANMARKER (JFFS2_FEATURE_RWCOMPAT_DELETE | JFFS2_NODE_ACCURATE | 3)
62#define JFFS2_NODETYPE_PADDING (JFFS2_FEATURE_RWCOMPAT_DELETE | JFFS2_NODE_ACCURATE | 4)
63
64// Maybe later...
65//#define JFFS2_NODETYPE_CHECKPOINT (JFFS2_FEATURE_RWCOMPAT_DELETE | JFFS2_NODE_ACCURATE | 3)
66//#define JFFS2_NODETYPE_OPTIONS (JFFS2_FEATURE_RWCOMPAT_COPY | JFFS2_NODE_ACCURATE | 4)
67
68
69#define JFFS2_INO_FLAG_PREREAD    1     /* Do read_inode() for this one at
70                                           mount time, don't wait for it to
71                                           happen later */
72#define JFFS2_INO_FLAG_USERCOMPR  2     /* User has requested a specific
73                                           compression type */
74
75
76/* These can go once we've made sure we've caught all uses without
77   byteswapping */
78
79typedef struct {
80        uint32_t v32;
81} __attribute__((packed))  jint32_t;
82
83typedef struct {
84        uint32_t m;
85} __attribute__((packed))  jmode_t;
86
87typedef struct {
88        uint16_t v16;
89} __attribute__((packed)) jint16_t;
90
91struct jffs2_unknown_node
92{
93        /* All start like this */
94        jint16_t magic;
95        jint16_t nodetype;
96        jint32_t totlen; /* So we can skip over nodes we don't grok */
97        jint32_t hdr_crc;
98} __attribute__((packed));
99
100struct jffs2_raw_dirent
101{
102        jint16_t magic;
103        jint16_t nodetype;      /* == JFFS_NODETYPE_DIRENT */
104        jint32_t totlen;
105        jint32_t hdr_crc;
106        jint32_t pino;
107        jint32_t version;
108        jint32_t ino; /* == zero for unlink */
109        jint32_t mctime;
110        uint8_t nsize;
111        uint8_t type;
112        uint8_t unused[2];
113        jint32_t node_crc;
114        jint32_t name_crc;
115        uint8_t name[0];
116} __attribute__((packed));
117
118/* The JFFS2 raw inode structure: Used for storage on physical media.  */
119/* The uid, gid, atime, mtime and ctime members could be longer, but
120   are left like this for space efficiency. If and when people decide
121   they really need them extended, it's simple enough to add support for
122   a new type of raw node.
123*/
124struct jffs2_raw_inode
125{
126        jint16_t magic;      /* A constant magic number.  */
127        jint16_t nodetype;   /* == JFFS_NODETYPE_INODE */
128        jint32_t totlen;     /* Total length of this node (inc data, etc.) */
129        jint32_t hdr_crc;
130        jint32_t ino;        /* Inode number.  */
131        jint32_t version;    /* Version number.  */
132        jmode_t mode;       /* The file's type or mode.  */
133        jint16_t uid;        /* The file's owner.  */
134        jint16_t gid;        /* The file's group.  */
135        jint32_t isize;      /* Total resultant size of this inode (used for truncations)  */
136        jint32_t atime;      /* Last access time.  */
137        jint32_t mtime;      /* Last modification time.  */
138        jint32_t ctime;      /* Change time.  */
139        jint32_t offset;     /* Where to begin to write.  */
140        jint32_t csize;      /* (Compressed) data size */
141        jint32_t dsize;      /* Size of the node's data. (after decompression) */
142        uint8_t compr;       /* Compression algorithm used */
143        uint8_t usercompr;   /* Compression algorithm requested by the user */
144        jint16_t flags;      /* See JFFS2_INO_FLAG_* */
145        jint32_t data_crc;   /* CRC for the (compressed) data.  */
146        jint32_t node_crc;   /* CRC for the raw inode (excluding data)  */
147        uint8_t data[0];
148} __attribute__((packed));
149
150union jffs2_node_union {
151        struct jffs2_raw_inode i;
152        struct jffs2_raw_dirent d;
153        struct jffs2_unknown_node u;
154};
155
156#endif /* __LINUX_JFFS2_H__ */
Note: See TracBrowser for help on using the repository browser.