Skip to content

Commit 0c0f128

Browse files
committed
JFFS2: Import from Linux
Import of Journalling Flash File System, Version 2 from Linux 3.11. This part of the Linux kernel is under a separate license which is similar to the RTEMS license. The file "cpukit/libfs/src/jffs2/include/linux/jffs2.h" is a copy of "linux-3.11/include/uapi/linux/jffs2.h". The file "LICENSE.JFFS2" is a copy of "linux-3.11/fs/jffs2/LICENCE". The files "linux-3.11/fs/jffs2/LICENCE", "linux-3.11/fs/jffs2/acl.h", "linux-3.11/fs/jffs2/build.c", "linux-3.11/fs/jffs2/compr.c", "linux-3.11/fs/jffs2/compr.h", "linux-3.11/fs/jffs2/compr_rtime.c", "linux-3.11/fs/jffs2/compr_rubin.c", "linux-3.11/fs/jffs2/compr_zlib.c", "linux-3.11/fs/jffs2/debug.c", "linux-3.11/fs/jffs2/debug.h", "linux-3.11/fs/jffs2/erase.c", "linux-3.11/fs/jffs2/gc.c", "linux-3.11/fs/jffs2/jffs2_fs_i.h", "linux-3.11/fs/jffs2/jffs2_fs_sb.h", "linux-3.11/fs/jffs2/nodelist.c", "linux-3.11/fs/jffs2/nodelist.h", "linux-3.11/fs/jffs2/nodemgmt.c", "linux-3.11/fs/jffs2/read.c", "linux-3.11/fs/jffs2/readinode.c", "linux-3.11/fs/jffs2/scan.c", "linux-3.11/fs/jffs2/summary.h", "linux-3.11/fs/jffs2/write.c", and "linux-3.11/fs/jffs2/xattr.h" are copied to "cpukit/libfs/src/jffs2/src".
1 parent 8ac962e commit 0c0f128

25 files changed

+11380
-0
lines changed

LICENSE.JFFS2

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
The files in this directory and elsewhere which refer to this LICENCE
2+
file are part of JFFS2, the Journalling Flash File System v2.
3+
4+
Copyright © 2001-2007 Red Hat, Inc. and others
5+
6+
JFFS2 is free software; you can redistribute it and/or modify it under
7+
the terms of the GNU General Public License as published by the Free
8+
Software Foundation; either version 2 or (at your option) any later
9+
version.
10+
11+
JFFS2 is distributed in the hope that it will be useful, but WITHOUT
12+
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+
for more details.
15+
16+
You should have received a copy of the GNU General Public License along
17+
with JFFS2; if not, write to the Free Software Foundation, Inc.,
18+
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
19+
20+
As a special exception, if other files instantiate templates or use
21+
macros or inline functions from these files, or you compile these
22+
files and link them with other works to produce a work based on these
23+
files, these files do not by themselves cause the resulting work to be
24+
covered by the GNU General Public License. However the source code for
25+
these files must still be made available in accordance with section (3)
26+
of the GNU General Public License.
27+
28+
This exception does not invalidate any other reasons why a work based on
29+
this file might be covered by the GNU General Public License.
30+
Lines changed: 223 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,223 @@
1+
/*
2+
* JFFS2 -- Journalling Flash File System, Version 2.
3+
*
4+
* Copyright © 2001-2007 Red Hat, Inc.
5+
* Copyright © 2004-2010 David Woodhouse <[email protected]>
6+
*
7+
* Created by David Woodhouse <[email protected]>
8+
*
9+
* For licensing information, see the file 'LICENCE' in the
10+
* jffs2 directory.
11+
*/
12+
13+
#ifndef __LINUX_JFFS2_H__
14+
#define __LINUX_JFFS2_H__
15+
16+
#include <linux/types.h>
17+
#include <linux/magic.h>
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+
#define JFFS2_COMPR_LZO 0x07
49+
/* Compatibility flags. */
50+
#define JFFS2_COMPAT_MASK 0xc000 /* What do to if an unknown nodetype is found */
51+
#define JFFS2_NODE_ACCURATE 0x2000
52+
/* INCOMPAT: Fail to mount the filesystem */
53+
#define JFFS2_FEATURE_INCOMPAT 0xc000
54+
/* ROCOMPAT: Mount read-only */
55+
#define JFFS2_FEATURE_ROCOMPAT 0x8000
56+
/* RWCOMPAT_COPY: Mount read/write, and copy the node when it's GC'd */
57+
#define JFFS2_FEATURE_RWCOMPAT_COPY 0x4000
58+
/* RWCOMPAT_DELETE: Mount read/write, and delete the node when it's GC'd */
59+
#define JFFS2_FEATURE_RWCOMPAT_DELETE 0x0000
60+
61+
#define JFFS2_NODETYPE_DIRENT (JFFS2_FEATURE_INCOMPAT | JFFS2_NODE_ACCURATE | 1)
62+
#define JFFS2_NODETYPE_INODE (JFFS2_FEATURE_INCOMPAT | JFFS2_NODE_ACCURATE | 2)
63+
#define JFFS2_NODETYPE_CLEANMARKER (JFFS2_FEATURE_RWCOMPAT_DELETE | JFFS2_NODE_ACCURATE | 3)
64+
#define JFFS2_NODETYPE_PADDING (JFFS2_FEATURE_RWCOMPAT_DELETE | JFFS2_NODE_ACCURATE | 4)
65+
66+
#define JFFS2_NODETYPE_SUMMARY (JFFS2_FEATURE_RWCOMPAT_DELETE | JFFS2_NODE_ACCURATE | 6)
67+
68+
#define JFFS2_NODETYPE_XATTR (JFFS2_FEATURE_INCOMPAT | JFFS2_NODE_ACCURATE | 8)
69+
#define JFFS2_NODETYPE_XREF (JFFS2_FEATURE_INCOMPAT | JFFS2_NODE_ACCURATE | 9)
70+
71+
/* XATTR Related */
72+
#define JFFS2_XPREFIX_USER 1 /* for "user." */
73+
#define JFFS2_XPREFIX_SECURITY 2 /* for "security." */
74+
#define JFFS2_XPREFIX_ACL_ACCESS 3 /* for "system.posix_acl_access" */
75+
#define JFFS2_XPREFIX_ACL_DEFAULT 4 /* for "system.posix_acl_default" */
76+
#define JFFS2_XPREFIX_TRUSTED 5 /* for "trusted.*" */
77+
78+
#define JFFS2_ACL_VERSION 0x0001
79+
80+
// Maybe later...
81+
//#define JFFS2_NODETYPE_CHECKPOINT (JFFS2_FEATURE_RWCOMPAT_DELETE | JFFS2_NODE_ACCURATE | 3)
82+
//#define JFFS2_NODETYPE_OPTIONS (JFFS2_FEATURE_RWCOMPAT_COPY | JFFS2_NODE_ACCURATE | 4)
83+
84+
85+
#define JFFS2_INO_FLAG_PREREAD 1 /* Do read_inode() for this one at
86+
mount time, don't wait for it to
87+
happen later */
88+
#define JFFS2_INO_FLAG_USERCOMPR 2 /* User has requested a specific
89+
compression type */
90+
91+
92+
/* These can go once we've made sure we've caught all uses without
93+
byteswapping */
94+
95+
typedef struct {
96+
__u32 v32;
97+
} __attribute__((packed)) jint32_t;
98+
99+
typedef struct {
100+
__u32 m;
101+
} __attribute__((packed)) jmode_t;
102+
103+
typedef struct {
104+
__u16 v16;
105+
} __attribute__((packed)) jint16_t;
106+
107+
struct jffs2_unknown_node
108+
{
109+
/* All start like this */
110+
jint16_t magic;
111+
jint16_t nodetype;
112+
jint32_t totlen; /* So we can skip over nodes we don't grok */
113+
jint32_t hdr_crc;
114+
};
115+
116+
struct jffs2_raw_dirent
117+
{
118+
jint16_t magic;
119+
jint16_t nodetype; /* == JFFS2_NODETYPE_DIRENT */
120+
jint32_t totlen;
121+
jint32_t hdr_crc;
122+
jint32_t pino;
123+
jint32_t version;
124+
jint32_t ino; /* == zero for unlink */
125+
jint32_t mctime;
126+
__u8 nsize;
127+
__u8 type;
128+
__u8 unused[2];
129+
jint32_t node_crc;
130+
jint32_t name_crc;
131+
__u8 name[0];
132+
};
133+
134+
/* The JFFS2 raw inode structure: Used for storage on physical media. */
135+
/* The uid, gid, atime, mtime and ctime members could be longer, but
136+
are left like this for space efficiency. If and when people decide
137+
they really need them extended, it's simple enough to add support for
138+
a new type of raw node.
139+
*/
140+
struct jffs2_raw_inode
141+
{
142+
jint16_t magic; /* A constant magic number. */
143+
jint16_t nodetype; /* == JFFS2_NODETYPE_INODE */
144+
jint32_t totlen; /* Total length of this node (inc data, etc.) */
145+
jint32_t hdr_crc;
146+
jint32_t ino; /* Inode number. */
147+
jint32_t version; /* Version number. */
148+
jmode_t mode; /* The file's type or mode. */
149+
jint16_t uid; /* The file's owner. */
150+
jint16_t gid; /* The file's group. */
151+
jint32_t isize; /* Total resultant size of this inode (used for truncations) */
152+
jint32_t atime; /* Last access time. */
153+
jint32_t mtime; /* Last modification time. */
154+
jint32_t ctime; /* Change time. */
155+
jint32_t offset; /* Where to begin to write. */
156+
jint32_t csize; /* (Compressed) data size */
157+
jint32_t dsize; /* Size of the node's data. (after decompression) */
158+
__u8 compr; /* Compression algorithm used */
159+
__u8 usercompr; /* Compression algorithm requested by the user */
160+
jint16_t flags; /* See JFFS2_INO_FLAG_* */
161+
jint32_t data_crc; /* CRC for the (compressed) data. */
162+
jint32_t node_crc; /* CRC for the raw inode (excluding data) */
163+
__u8 data[0];
164+
};
165+
166+
struct jffs2_raw_xattr {
167+
jint16_t magic;
168+
jint16_t nodetype; /* = JFFS2_NODETYPE_XATTR */
169+
jint32_t totlen;
170+
jint32_t hdr_crc;
171+
jint32_t xid; /* XATTR identifier number */
172+
jint32_t version;
173+
__u8 xprefix;
174+
__u8 name_len;
175+
jint16_t value_len;
176+
jint32_t data_crc;
177+
jint32_t node_crc;
178+
__u8 data[0];
179+
} __attribute__((packed));
180+
181+
struct jffs2_raw_xref
182+
{
183+
jint16_t magic;
184+
jint16_t nodetype; /* = JFFS2_NODETYPE_XREF */
185+
jint32_t totlen;
186+
jint32_t hdr_crc;
187+
jint32_t ino; /* inode number */
188+
jint32_t xid; /* XATTR identifier number */
189+
jint32_t xseqno; /* xref sequential number */
190+
jint32_t node_crc;
191+
} __attribute__((packed));
192+
193+
struct jffs2_raw_summary
194+
{
195+
jint16_t magic;
196+
jint16_t nodetype; /* = JFFS2_NODETYPE_SUMMARY */
197+
jint32_t totlen;
198+
jint32_t hdr_crc;
199+
jint32_t sum_num; /* number of sum entries*/
200+
jint32_t cln_mkr; /* clean marker size, 0 = no cleanmarker */
201+
jint32_t padded; /* sum of the size of padding nodes */
202+
jint32_t sum_crc; /* summary information crc */
203+
jint32_t node_crc; /* node crc */
204+
jint32_t sum[0]; /* inode summary info */
205+
};
206+
207+
union jffs2_node_union
208+
{
209+
struct jffs2_raw_inode i;
210+
struct jffs2_raw_dirent d;
211+
struct jffs2_raw_xattr x;
212+
struct jffs2_raw_xref r;
213+
struct jffs2_raw_summary s;
214+
struct jffs2_unknown_node u;
215+
};
216+
217+
/* Data payload for device nodes. */
218+
union jffs2_device_node {
219+
jint16_t old_id;
220+
jint32_t new_id;
221+
};
222+
223+
#endif /* __LINUX_JFFS2_H__ */

cpukit/libfs/src/jffs2/src/LICENCE

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
The files in this directory and elsewhere which refer to this LICENCE
2+
file are part of JFFS2, the Journalling Flash File System v2.
3+
4+
Copyright © 2001-2007 Red Hat, Inc. and others
5+
6+
JFFS2 is free software; you can redistribute it and/or modify it under
7+
the terms of the GNU General Public License as published by the Free
8+
Software Foundation; either version 2 or (at your option) any later
9+
version.
10+
11+
JFFS2 is distributed in the hope that it will be useful, but WITHOUT
12+
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+
for more details.
15+
16+
You should have received a copy of the GNU General Public License along
17+
with JFFS2; if not, write to the Free Software Foundation, Inc.,
18+
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
19+
20+
As a special exception, if other files instantiate templates or use
21+
macros or inline functions from these files, or you compile these
22+
files and link them with other works to produce a work based on these
23+
files, these files do not by themselves cause the resulting work to be
24+
covered by the GNU General Public License. However the source code for
25+
these files must still be made available in accordance with section (3)
26+
of the GNU General Public License.
27+
28+
This exception does not invalidate any other reasons why a work based on
29+
this file might be covered by the GNU General Public License.
30+

cpukit/libfs/src/jffs2/src/acl.h

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* JFFS2 -- Journalling Flash File System, Version 2.
3+
*
4+
* Copyright © 2006 NEC Corporation
5+
*
6+
* Created by KaiGai Kohei <[email protected]>
7+
*
8+
* For licensing information, see the file 'LICENCE' in this directory.
9+
*
10+
*/
11+
12+
struct jffs2_acl_entry {
13+
jint16_t e_tag;
14+
jint16_t e_perm;
15+
jint32_t e_id;
16+
};
17+
18+
struct jffs2_acl_entry_short {
19+
jint16_t e_tag;
20+
jint16_t e_perm;
21+
};
22+
23+
struct jffs2_acl_header {
24+
jint32_t a_version;
25+
};
26+
27+
#ifdef CONFIG_JFFS2_FS_POSIX_ACL
28+
29+
struct posix_acl *jffs2_get_acl(struct inode *inode, int type);
30+
extern int jffs2_acl_chmod(struct inode *);
31+
extern int jffs2_init_acl_pre(struct inode *, struct inode *, umode_t *);
32+
extern int jffs2_init_acl_post(struct inode *);
33+
34+
extern const struct xattr_handler jffs2_acl_access_xattr_handler;
35+
extern const struct xattr_handler jffs2_acl_default_xattr_handler;
36+
37+
#else
38+
39+
#define jffs2_get_acl (NULL)
40+
#define jffs2_acl_chmod(inode) (0)
41+
#define jffs2_init_acl_pre(dir_i,inode,mode) (0)
42+
#define jffs2_init_acl_post(inode) (0)
43+
44+
#endif /* CONFIG_JFFS2_FS_POSIX_ACL */

0 commit comments

Comments
 (0)