| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * JFFS2 -- Journalling Flash File System, Version 2. | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2010-08-08 14:15:22 +01:00
										 |  |  |  * Copyright © 2001-2007 Red Hat, Inc. | 
					
						
							|  |  |  |  * Copyright © 2004-2010 David Woodhouse <dwmw2@infradead.org> | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  |  * | 
					
						
							|  |  |  |  * Created by David Woodhouse <dwmw2@infradead.org> | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2005-11-07 11:16:07 +00:00
										 |  |  |  * For licensing information, see the file 'LICENCE' in the | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  |  * jffs2 directory. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifndef __LINUX_JFFS2_H__
 | 
					
						
							|  |  |  | #define __LINUX_JFFS2_H__
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-26 00:51:41 +01:00
										 |  |  | #include <linux/types.h>
 | 
					
						
							| 
									
										
										
										
											2006-09-24 11:13:19 -04:00
										 |  |  | #include <linux/magic.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | /* You must include something which defines the C99 uintXX_t types. 
 | 
					
						
							|  |  |  |    We don't do it from here because this file is used in too many | 
					
						
							|  |  |  |    different environments. */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Values we may expect to find in the 'magic' field */ | 
					
						
							|  |  |  | #define JFFS2_OLD_MAGIC_BITMASK 0x1984
 | 
					
						
							|  |  |  | #define JFFS2_MAGIC_BITMASK 0x1985
 | 
					
						
							|  |  |  | #define KSAMTIB_CIGAM_2SFFJ 0x8519 /* For detecting wrong-endian fs */
 | 
					
						
							|  |  |  | #define JFFS2_EMPTY_BITMASK 0xffff
 | 
					
						
							|  |  |  | #define JFFS2_DIRTY_BITMASK 0x0000
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-09-07 09:35:26 +01:00
										 |  |  | /* Summary node MAGIC marker */ | 
					
						
							|  |  |  | #define JFFS2_SUM_MAGIC	0x02851885
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | /* We only allow a single char for length, and 0xFF is empty flash so
 | 
					
						
							|  |  |  |    we don't want it confused with a real length. Hence max 254. | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | #define JFFS2_MAX_NAME_LEN 254
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* How small can we sensibly write nodes? */ | 
					
						
							|  |  |  | #define JFFS2_MIN_DATA_LEN 128
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define JFFS2_COMPR_NONE	0x00
 | 
					
						
							|  |  |  | #define JFFS2_COMPR_ZERO	0x01
 | 
					
						
							|  |  |  | #define JFFS2_COMPR_RTIME	0x02
 | 
					
						
							|  |  |  | #define JFFS2_COMPR_RUBINMIPS	0x03
 | 
					
						
							|  |  |  | #define JFFS2_COMPR_COPY	0x04
 | 
					
						
							|  |  |  | #define JFFS2_COMPR_DYNRUBIN	0x05
 | 
					
						
							|  |  |  | #define JFFS2_COMPR_ZLIB	0x06
 | 
					
						
							| 
									
										
										
										
											2007-07-10 10:28:36 +01:00
										 |  |  | #define JFFS2_COMPR_LZO		0x07
 | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | /* Compatibility flags. */ | 
					
						
							|  |  |  | #define JFFS2_COMPAT_MASK 0xc000      /* What do to if an unknown nodetype is found */
 | 
					
						
							|  |  |  | #define JFFS2_NODE_ACCURATE 0x2000
 | 
					
						
							|  |  |  | /* INCOMPAT: Fail to mount the filesystem */ | 
					
						
							|  |  |  | #define JFFS2_FEATURE_INCOMPAT 0xc000
 | 
					
						
							|  |  |  | /* ROCOMPAT: Mount read-only */ | 
					
						
							|  |  |  | #define JFFS2_FEATURE_ROCOMPAT 0x8000
 | 
					
						
							|  |  |  | /* RWCOMPAT_COPY: Mount read/write, and copy the node when it's GC'd */ | 
					
						
							|  |  |  | #define JFFS2_FEATURE_RWCOMPAT_COPY 0x4000
 | 
					
						
							|  |  |  | /* RWCOMPAT_DELETE: Mount read/write, and delete the node when it's GC'd */ | 
					
						
							|  |  |  | #define JFFS2_FEATURE_RWCOMPAT_DELETE 0x0000
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define JFFS2_NODETYPE_DIRENT (JFFS2_FEATURE_INCOMPAT | JFFS2_NODE_ACCURATE | 1)
 | 
					
						
							|  |  |  | #define JFFS2_NODETYPE_INODE (JFFS2_FEATURE_INCOMPAT | JFFS2_NODE_ACCURATE | 2)
 | 
					
						
							|  |  |  | #define JFFS2_NODETYPE_CLEANMARKER (JFFS2_FEATURE_RWCOMPAT_DELETE | JFFS2_NODE_ACCURATE | 3)
 | 
					
						
							|  |  |  | #define JFFS2_NODETYPE_PADDING (JFFS2_FEATURE_RWCOMPAT_DELETE | JFFS2_NODE_ACCURATE | 4)
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-09-07 09:35:26 +01:00
										 |  |  | #define JFFS2_NODETYPE_SUMMARY (JFFS2_FEATURE_RWCOMPAT_DELETE | JFFS2_NODE_ACCURATE | 6)
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-05-13 15:09:47 +09:00
										 |  |  | #define JFFS2_NODETYPE_XATTR (JFFS2_FEATURE_INCOMPAT | JFFS2_NODE_ACCURATE | 8)
 | 
					
						
							|  |  |  | #define JFFS2_NODETYPE_XREF (JFFS2_FEATURE_INCOMPAT | JFFS2_NODE_ACCURATE | 9)
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* XATTR Related */ | 
					
						
							|  |  |  | #define JFFS2_XPREFIX_USER		1	/* for "user." */
 | 
					
						
							|  |  |  | #define JFFS2_XPREFIX_SECURITY		2	/* for "security." */
 | 
					
						
							|  |  |  | #define JFFS2_XPREFIX_ACL_ACCESS	3	/* for "system.posix_acl_access" */
 | 
					
						
							|  |  |  | #define JFFS2_XPREFIX_ACL_DEFAULT	4	/* for "system.posix_acl_default" */
 | 
					
						
							|  |  |  | #define JFFS2_XPREFIX_TRUSTED		5	/* for "trusted.*" */
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define JFFS2_ACL_VERSION		0x0001
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | // Maybe later...
 | 
					
						
							|  |  |  | //#define JFFS2_NODETYPE_CHECKPOINT (JFFS2_FEATURE_RWCOMPAT_DELETE | JFFS2_NODE_ACCURATE | 3)
 | 
					
						
							|  |  |  | //#define JFFS2_NODETYPE_OPTIONS (JFFS2_FEATURE_RWCOMPAT_COPY | JFFS2_NODE_ACCURATE | 4)
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-11-07 11:16:07 +00:00
										 |  |  | #define JFFS2_INO_FLAG_PREREAD	  1	/* Do read_inode() for this one at
 | 
					
						
							|  |  |  | 					   mount time, don't wait for it to | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 					   happen later */ | 
					
						
							| 
									
										
										
										
											2005-11-07 11:16:07 +00:00
										 |  |  | #define JFFS2_INO_FLAG_USERCOMPR  2	/* User has requested a specific
 | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 					   compression type */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* These can go once we've made sure we've caught all uses without
 | 
					
						
							|  |  |  |    byteswapping */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | typedef struct { | 
					
						
							| 
									
										
										
										
											2009-02-26 00:51:41 +01:00
										 |  |  | 	__u32 v32; | 
					
						
							| 
									
										
										
										
											2006-05-16 23:03:08 +01:00
										 |  |  | } __attribute__((packed)) jint32_t; | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | typedef struct { | 
					
						
							| 
									
										
										
										
											2009-02-26 00:51:41 +01:00
										 |  |  | 	__u32 m; | 
					
						
							| 
									
										
										
										
											2006-05-16 23:03:08 +01:00
										 |  |  | } __attribute__((packed)) jmode_t; | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | typedef struct { | 
					
						
							| 
									
										
										
										
											2009-02-26 00:51:41 +01:00
										 |  |  | 	__u16 v16; | 
					
						
							| 
									
										
										
										
											2006-05-16 23:03:08 +01:00
										 |  |  | } __attribute__((packed)) jint16_t; | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | struct jffs2_unknown_node | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	/* All start like this */ | 
					
						
							|  |  |  | 	jint16_t magic; | 
					
						
							|  |  |  | 	jint16_t nodetype; | 
					
						
							|  |  |  | 	jint32_t totlen; /* So we can skip over nodes we don't grok */ | 
					
						
							|  |  |  | 	jint32_t hdr_crc; | 
					
						
							| 
									
										
										
										
											2006-05-15 00:49:43 +01:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | struct jffs2_raw_dirent | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	jint16_t magic; | 
					
						
							| 
									
										
										
										
											2005-07-24 16:29:59 +01:00
										 |  |  | 	jint16_t nodetype;	/* == JFFS2_NODETYPE_DIRENT */ | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 	jint32_t totlen; | 
					
						
							|  |  |  | 	jint32_t hdr_crc; | 
					
						
							|  |  |  | 	jint32_t pino; | 
					
						
							|  |  |  | 	jint32_t version; | 
					
						
							|  |  |  | 	jint32_t ino; /* == zero for unlink */ | 
					
						
							|  |  |  | 	jint32_t mctime; | 
					
						
							| 
									
										
										
										
											2009-02-26 00:51:41 +01:00
										 |  |  | 	__u8 nsize; | 
					
						
							|  |  |  | 	__u8 type; | 
					
						
							|  |  |  | 	__u8 unused[2]; | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 	jint32_t node_crc; | 
					
						
							|  |  |  | 	jint32_t name_crc; | 
					
						
							| 
									
										
										
										
											2009-02-26 00:51:41 +01:00
										 |  |  | 	__u8 name[0]; | 
					
						
							| 
									
										
										
										
											2006-05-15 00:49:43 +01:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* The JFFS2 raw inode structure: Used for storage on physical media.  */ | 
					
						
							| 
									
										
										
										
											2005-11-07 11:16:07 +00:00
										 |  |  | /* The uid, gid, atime, mtime and ctime members could be longer, but
 | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  |    are left like this for space efficiency. If and when people decide | 
					
						
							|  |  |  |    they really need them extended, it's simple enough to add support for | 
					
						
							|  |  |  |    a new type of raw node. | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | struct jffs2_raw_inode | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	jint16_t magic;      /* A constant magic number.  */ | 
					
						
							| 
									
										
										
										
											2005-07-24 16:29:59 +01:00
										 |  |  | 	jint16_t nodetype;   /* == JFFS2_NODETYPE_INODE */ | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 	jint32_t totlen;     /* Total length of this node (inc data, etc.) */ | 
					
						
							|  |  |  | 	jint32_t hdr_crc; | 
					
						
							|  |  |  | 	jint32_t ino;        /* Inode number.  */ | 
					
						
							|  |  |  | 	jint32_t version;    /* Version number.  */ | 
					
						
							|  |  |  | 	jmode_t mode;       /* The file's type or mode.  */ | 
					
						
							|  |  |  | 	jint16_t uid;        /* The file's owner.  */ | 
					
						
							|  |  |  | 	jint16_t gid;        /* The file's group.  */ | 
					
						
							|  |  |  | 	jint32_t isize;      /* Total resultant size of this inode (used for truncations)  */ | 
					
						
							|  |  |  | 	jint32_t atime;      /* Last access time.  */ | 
					
						
							|  |  |  | 	jint32_t mtime;      /* Last modification time.  */ | 
					
						
							|  |  |  | 	jint32_t ctime;      /* Change time.  */ | 
					
						
							|  |  |  | 	jint32_t offset;     /* Where to begin to write.  */ | 
					
						
							|  |  |  | 	jint32_t csize;      /* (Compressed) data size */ | 
					
						
							|  |  |  | 	jint32_t dsize;	     /* Size of the node's data. (after decompression) */ | 
					
						
							| 
									
										
										
										
											2009-02-26 00:51:41 +01:00
										 |  |  | 	__u8 compr;       /* Compression algorithm used */ | 
					
						
							|  |  |  | 	__u8 usercompr;   /* Compression algorithm requested by the user */ | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 	jint16_t flags;	     /* See JFFS2_INO_FLAG_* */ | 
					
						
							|  |  |  | 	jint32_t data_crc;   /* CRC for the (compressed) data.  */ | 
					
						
							|  |  |  | 	jint32_t node_crc;   /* CRC for the raw inode (excluding data)  */ | 
					
						
							| 
									
										
										
										
											2009-02-26 00:51:41 +01:00
										 |  |  | 	__u8 data[0]; | 
					
						
							| 
									
										
										
										
											2006-05-15 00:49:43 +01:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-05-13 15:09:47 +09:00
										 |  |  | struct jffs2_raw_xattr { | 
					
						
							|  |  |  | 	jint16_t magic; | 
					
						
							|  |  |  | 	jint16_t nodetype;	/* = JFFS2_NODETYPE_XATTR */ | 
					
						
							|  |  |  | 	jint32_t totlen; | 
					
						
							|  |  |  | 	jint32_t hdr_crc; | 
					
						
							|  |  |  | 	jint32_t xid;		/* XATTR identifier number */ | 
					
						
							|  |  |  | 	jint32_t version; | 
					
						
							| 
									
										
										
										
											2009-02-26 00:51:41 +01:00
										 |  |  | 	__u8 xprefix; | 
					
						
							|  |  |  | 	__u8 name_len; | 
					
						
							| 
									
										
										
										
											2006-05-13 15:09:47 +09:00
										 |  |  | 	jint16_t value_len; | 
					
						
							|  |  |  | 	jint32_t data_crc; | 
					
						
							|  |  |  | 	jint32_t node_crc; | 
					
						
							| 
									
										
										
										
											2009-02-26 00:51:41 +01:00
										 |  |  | 	__u8 data[0]; | 
					
						
							| 
									
										
										
										
											2006-05-13 15:09:47 +09:00
										 |  |  | } __attribute__((packed)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | struct jffs2_raw_xref | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	jint16_t magic; | 
					
						
							|  |  |  | 	jint16_t nodetype;	/* = JFFS2_NODETYPE_XREF */ | 
					
						
							|  |  |  | 	jint32_t totlen; | 
					
						
							|  |  |  | 	jint32_t hdr_crc; | 
					
						
							|  |  |  | 	jint32_t ino;		/* inode number */ | 
					
						
							|  |  |  | 	jint32_t xid;		/* XATTR identifier number */ | 
					
						
							| 
									
										
										
										
											2010-07-01 20:48:44 +02:00
										 |  |  | 	jint32_t xseqno;	/* xref sequential number */ | 
					
						
							| 
									
										
										
										
											2006-05-13 15:09:47 +09:00
										 |  |  | 	jint32_t node_crc; | 
					
						
							|  |  |  | } __attribute__((packed)); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-09-26 12:37:25 +01:00
										 |  |  | struct jffs2_raw_summary | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2005-09-07 09:35:26 +01:00
										 |  |  | 	jint16_t magic; | 
					
						
							| 
									
										
										
										
											2005-09-26 12:37:25 +01:00
										 |  |  | 	jint16_t nodetype; 	/* = JFFS2_NODETYPE_SUMMARY */ | 
					
						
							| 
									
										
										
										
											2005-09-07 09:35:26 +01:00
										 |  |  | 	jint32_t totlen; | 
					
						
							|  |  |  | 	jint32_t hdr_crc; | 
					
						
							|  |  |  | 	jint32_t sum_num;	/* number of sum entries*/ | 
					
						
							|  |  |  | 	jint32_t cln_mkr;	/* clean marker size, 0 = no cleanmarker */ | 
					
						
							|  |  |  | 	jint32_t padded;	/* sum of the size of padding nodes */ | 
					
						
							|  |  |  | 	jint32_t sum_crc;	/* summary information crc */ | 
					
						
							|  |  |  | 	jint32_t node_crc; 	/* node crc */ | 
					
						
							|  |  |  | 	jint32_t sum[0]; 	/* inode summary info */ | 
					
						
							| 
									
										
										
										
											2006-05-15 00:49:43 +01:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2005-09-07 09:35:26 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-11-07 11:16:07 +00:00
										 |  |  | union jffs2_node_union | 
					
						
							| 
									
										
										
										
											2005-09-26 12:37:25 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 	struct jffs2_raw_inode i; | 
					
						
							|  |  |  | 	struct jffs2_raw_dirent d; | 
					
						
							| 
									
										
										
										
											2006-05-13 15:09:47 +09:00
										 |  |  | 	struct jffs2_raw_xattr x; | 
					
						
							|  |  |  | 	struct jffs2_raw_xref r; | 
					
						
							| 
									
										
										
										
											2005-09-26 12:37:25 +01:00
										 |  |  | 	struct jffs2_raw_summary s; | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 	struct jffs2_unknown_node u; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-05-19 00:28:49 +01:00
										 |  |  | /* Data payload for device nodes. */ | 
					
						
							|  |  |  | union jffs2_device_node { | 
					
						
							| 
									
										
										
										
											2010-02-02 14:43:10 -08:00
										 |  |  | 	jint16_t old_id; | 
					
						
							|  |  |  | 	jint32_t new_id; | 
					
						
							| 
									
										
										
										
											2006-05-19 00:28:49 +01:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | #endif /* __LINUX_JFFS2_H__ */
 |