mtd/include/linux jffs2.h,1.24,1.25
David Woodhouse
dwmw2 at infradead.org
Tue Aug 20 17:37:30 EDT 2002
- Previous message: mtd/fs/jffs2 nodelist.c,1.30.2.4,1.30.2.5
- Next message: mtd/fs/jffs2 dir.c,1.71,1.72 erase.c,1.40,1.41 file.c,1.76,1.77 fs.c,1.15,1.16 gc.c,1.79,1.80 nodelist.c,1.47,1.48 nodemgmt.c,1.72,1.73 read.c,1.23,1.24 readinode.c,1.73,1.74 scan.c,1.81,1.82 wbuf.c,1.15,1.16 write.c,1.57,1.58
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /home/cvs/mtd/include/linux
In directory phoenix.infradead.org:/tmp/cvs-serv7536/include/linux
Modified Files:
jffs2.h
Log Message:
Byte-swapping code at last. Whether it's BE, LE or native is controlled by
a #define in jffs2.h for now.
Index: jffs2.h
===================================================================
RCS file: /home/cvs/mtd/include/linux/jffs2.h,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- jffs2.h 20 May 2002 14:56:37 -0000 1.24
+++ jffs2.h 20 Aug 2002 21:37:27 -0000 1.25
@@ -68,30 +68,65 @@
compression type */
+/* These can go once we've made sure we've caught all uses without
+ byteswapping */
+
+typedef struct {
+ uint32_t v32;
+} __attribute__((packed)) jint32_t;
+
+typedef struct {
+ uint16_t v16;
+} __attribute__((packed)) jint16_t;
+
+#define JFFS2_NATIVE_ENDIAN
+
+#if defined(JFFS2_NATIVE_ENDIAN)
+#define cpu_to_je16(x) ((jint16_t){x})
+#define cpu_to_je32(x) ((jint32_t){x})
+
+#define je16_to_cpu(x) ((x).v16)
+#define je32_to_cpu(x) ((x).v32)
+#elif defined(JFFS2_BIG_ENDIAN)
+#define cpu_to_je16(x) ((jint16_t){cpu_to_be16(x)})
+#define cpu_to_je32(x) ((jint32_t){cpu_to_be32(x)})
+
+#define je16_to_cpu(x) (be16_to_cpu(x.v16))
+#define je32_to_cpu(x) (be32_to_cpu(x.v32))
+#elif defined(JFFS2_LITTLE_ENDIAN)
+#define cpu_to_je16(x) ((jint16_t){cpu_to_le16(x)})
+#define cpu_to_je32(x) ((jint32_t){cpu_to_le32(x)})
+
+#define je16_to_cpu(x) (le16_to_cpu(x.v16))
+#define je32_to_cpu(x) (le32_to_cpu(x.v32))
+#else
+#error wibble
+#endif
+
struct jffs2_unknown_node
{
/* All start like this */
- uint16_t magic;
- uint16_t nodetype;
- uint32_t totlen; /* So we can skip over nodes we don't grok */
- uint32_t hdr_crc;
+ jint16_t magic;
+ jint16_t nodetype;
+ jint32_t totlen; /* So we can skip over nodes we don't grok */
+ jint32_t hdr_crc;
} __attribute__((packed));
struct jffs2_raw_dirent
{
- uint16_t magic;
- uint16_t nodetype; /* == JFFS_NODETYPE_DIRENT */
- uint32_t totlen;
- uint32_t hdr_crc;
- uint32_t pino;
- uint32_t version;
- uint32_t ino; /* == zero for unlink */
- uint32_t mctime;
+ jint16_t magic;
+ jint16_t nodetype; /* == JFFS_NODETYPE_DIRENT */
+ jint32_t totlen;
+ jint32_t hdr_crc;
+ jint32_t pino;
+ jint32_t version;
+ jint32_t ino; /* == zero for unlink */
+ jint32_t mctime;
uint8_t nsize;
uint8_t type;
uint8_t unused[2];
- uint32_t node_crc;
- uint32_t name_crc;
+ jint32_t node_crc;
+ jint32_t name_crc;
uint8_t name[0];
} __attribute__((packed));
@@ -103,27 +138,27 @@
*/
struct jffs2_raw_inode
{
- uint16_t magic; /* A constant magic number. */
- uint16_t nodetype; /* == JFFS_NODETYPE_INODE */
- uint32_t totlen; /* Total length of this node (inc data, etc.) */
- uint32_t hdr_crc;
- uint32_t ino; /* Inode number. */
- uint32_t version; /* Version number. */
- uint32_t mode; /* The file's type or mode. */
- uint16_t uid; /* The file's owner. */
- uint16_t gid; /* The file's group. */
- uint32_t isize; /* Total resultant size of this inode (used for truncations) */
- uint32_t atime; /* Last access time. */
- uint32_t mtime; /* Last modification time. */
- uint32_t ctime; /* Change time. */
- uint32_t offset; /* Where to begin to write. */
- uint32_t csize; /* (Compressed) data size */
- uint32_t dsize; /* Size of the node's data. (after decompression) */
+ jint16_t magic; /* A constant magic number. */
+ jint16_t nodetype; /* == JFFS_NODETYPE_INODE */
+ 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. */
+ jint32_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) */
uint8_t compr; /* Compression algorithm used */
uint8_t usercompr; /* Compression algorithm requested by the user */
- uint16_t flags; /* See JFFS2_INO_FLAG_* */
- uint32_t data_crc; /* CRC for the (compressed) data. */
- uint32_t node_crc; /* CRC for the raw inode (excluding data) */
+ 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) */
// uint8_t data[dsize];
} __attribute__((packed));
- Previous message: mtd/fs/jffs2 nodelist.c,1.30.2.4,1.30.2.5
- Next message: mtd/fs/jffs2 dir.c,1.71,1.72 erase.c,1.40,1.41 file.c,1.76,1.77 fs.c,1.15,1.16 gc.c,1.79,1.80 nodelist.c,1.47,1.48 nodemgmt.c,1.72,1.73 read.c,1.23,1.24 readinode.c,1.73,1.74 scan.c,1.81,1.82 wbuf.c,1.15,1.16 write.c,1.57,1.58
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the linux-mtd-cvs
mailing list