brintos

brintos / linux-shallow public Read only

0
0
Text · 6.7 KiB · 637ee4a Raw
219 lines · c
1/*2 * JFFS2 -- Journalling Flash File System, Version 2.3 *4 * Copyright © 2001-2007 Red Hat, Inc.5 * Copyright © 2004-2010 David Woodhouse <dwmw2@infradead.org>6 *7 * Created by David Woodhouse <dwmw2@infradead.org>8 *9 * For licensing information, see the file 'LICENCE' in the10 * 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 many21   different environments. */22 23/* Values we may expect to find in the 'magic' field */24#define JFFS2_OLD_MAGIC_BITMASK 0x198425#define JFFS2_MAGIC_BITMASK 0x198526#define KSAMTIB_CIGAM_2SFFJ 0x8519 /* For detecting wrong-endian fs */27#define JFFS2_EMPTY_BITMASK 0xffff28#define JFFS2_DIRTY_BITMASK 0x000029 30/* Summary node MAGIC marker */31#define JFFS2_SUM_MAGIC	0x0285188532 33/* We only allow a single char for length, and 0xFF is empty flash so34   we don't want it confused with a real length. Hence max 254.35*/36#define JFFS2_MAX_NAME_LEN 25437 38/* How small can we sensibly write nodes? */39#define JFFS2_MIN_DATA_LEN 12840 41#define JFFS2_COMPR_NONE	0x0042#define JFFS2_COMPR_ZERO	0x0143#define JFFS2_COMPR_RTIME	0x0244#define JFFS2_COMPR_RUBINMIPS	0x0345#define JFFS2_COMPR_COPY	0x0446#define JFFS2_COMPR_DYNRUBIN	0x0547#define JFFS2_COMPR_ZLIB	0x0648#define JFFS2_COMPR_LZO		0x0749/* Compatibility flags. */50#define JFFS2_COMPAT_MASK 0xc000      /* What do to if an unknown nodetype is found */51#define JFFS2_NODE_ACCURATE 0x200052/* INCOMPAT: Fail to mount the filesystem */53#define JFFS2_FEATURE_INCOMPAT 0xc00054/* ROCOMPAT: Mount read-only */55#define JFFS2_FEATURE_ROCOMPAT 0x800056/* RWCOMPAT_COPY: Mount read/write, and copy the node when it's GC'd */57#define JFFS2_FEATURE_RWCOMPAT_COPY 0x400058/* RWCOMPAT_DELETE: Mount read/write, and delete the node when it's GC'd */59#define JFFS2_FEATURE_RWCOMPAT_DELETE 0x000060 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		0x000179 80#define JFFS2_INO_FLAG_PREREAD	  1	/* Do read_inode() for this one at81					   mount time, don't wait for it to82					   happen later */83#define JFFS2_INO_FLAG_USERCOMPR  2	/* User has requested a specific84					   compression type */85 86 87/* These can go once we've made sure we've caught all uses without88   byteswapping */89 90typedef struct {91	__u32 v32;92} __attribute__((packed)) jint32_t;93 94typedef struct {95	__u32 m;96} __attribute__((packed)) jmode_t;97 98typedef struct {99	__u16 v16;100} __attribute__((packed)) jint16_t;101 102struct jffs2_unknown_node103{104	/* All start like this */105	jint16_t magic;106	jint16_t nodetype;107	jint32_t totlen; /* So we can skip over nodes we don't grok */108	jint32_t hdr_crc;109};110 111struct jffs2_raw_dirent112{113	jint16_t magic;114	jint16_t nodetype;	/* == JFFS2_NODETYPE_DIRENT */115	jint32_t totlen;116	jint32_t hdr_crc;117	jint32_t pino;118	jint32_t version;119	jint32_t ino; /* == zero for unlink */120	jint32_t mctime;121	__u8 nsize;122	__u8 type;123	__u8 unused[2];124	jint32_t node_crc;125	jint32_t name_crc;126	__u8 name[];127};128 129/* The JFFS2 raw inode structure: Used for storage on physical media.  */130/* The uid, gid, atime, mtime and ctime members could be longer, but131   are left like this for space efficiency. If and when people decide132   they really need them extended, it's simple enough to add support for133   a new type of raw node.134*/135struct jffs2_raw_inode136{137	jint16_t magic;      /* A constant magic number.  */138	jint16_t nodetype;   /* == JFFS2_NODETYPE_INODE */139	jint32_t totlen;     /* Total length of this node (inc data, etc.) */140	jint32_t hdr_crc;141	jint32_t ino;        /* Inode number.  */142	jint32_t version;    /* Version number.  */143	jmode_t mode;       /* The file's type or mode.  */144	jint16_t uid;        /* The file's owner.  */145	jint16_t gid;        /* The file's group.  */146	jint32_t isize;      /* Total resultant size of this inode (used for truncations)  */147	jint32_t atime;      /* Last access time.  */148	jint32_t mtime;      /* Last modification time.  */149	jint32_t ctime;      /* Change time.  */150	jint32_t offset;     /* Where to begin to write.  */151	jint32_t csize;      /* (Compressed) data size */152	jint32_t dsize;	     /* Size of the node's data. (after decompression) */153	__u8 compr;       /* Compression algorithm used */154	__u8 usercompr;   /* Compression algorithm requested by the user */155	jint16_t flags;	     /* See JFFS2_INO_FLAG_* */156	jint32_t data_crc;   /* CRC for the (compressed) data.  */157	jint32_t node_crc;   /* CRC for the raw inode (excluding data)  */158	__u8 data[];159};160 161struct jffs2_raw_xattr {162	jint16_t magic;163	jint16_t nodetype;	/* = JFFS2_NODETYPE_XATTR */164	jint32_t totlen;165	jint32_t hdr_crc;166	jint32_t xid;		/* XATTR identifier number */167	jint32_t version;168	__u8 xprefix;169	__u8 name_len;170	jint16_t value_len;171	jint32_t data_crc;172	jint32_t node_crc;173	__u8 data[];174} __attribute__((packed));175 176struct jffs2_raw_xref177{178	jint16_t magic;179	jint16_t nodetype;	/* = JFFS2_NODETYPE_XREF */180	jint32_t totlen;181	jint32_t hdr_crc;182	jint32_t ino;		/* inode number */183	jint32_t xid;		/* XATTR identifier number */184	jint32_t xseqno;	/* xref sequential number */185	jint32_t node_crc;186} __attribute__((packed));187 188struct jffs2_raw_summary189{190	jint16_t magic;191	jint16_t nodetype; 	/* = JFFS2_NODETYPE_SUMMARY */192	jint32_t totlen;193	jint32_t hdr_crc;194	jint32_t sum_num;	/* number of sum entries*/195	jint32_t cln_mkr;	/* clean marker size, 0 = no cleanmarker */196	jint32_t padded;	/* sum of the size of padding nodes */197	jint32_t sum_crc;	/* summary information crc */198	jint32_t node_crc; 	/* node crc */199	jint32_t sum[]; 	/* inode summary info */200};201 202union jffs2_node_union203{204	struct jffs2_raw_inode i;205	struct jffs2_raw_dirent d;206	struct jffs2_raw_xattr x;207	struct jffs2_raw_xref r;208	struct jffs2_raw_summary s;209	struct jffs2_unknown_node u;210};211 212/* Data payload for device nodes. */213union jffs2_device_node {214	jint16_t old_id;215	jint32_t new_id;216};217 218#endif /* __LINUX_JFFS2_H__ */219