mtd/util mkfs.jffs.c,1.12,1.13
tpoynor at infradead.org
tpoynor at infradead.org
Wed Nov 10 14:46:18 EST 2004
Update of /home/cvs/mtd/util
In directory phoenix.infradead.org:/tmp/cvs-serv20287
Modified Files:
mkfs.jffs.c
Log Message:
Use local endian conversion macros; recent kernel versions are no longer
userspace clean.
Index: mkfs.jffs.c
===================================================================
RCS file: /home/cvs/mtd/util/mkfs.jffs.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- mkfs.jffs.c 5 May 2004 18:33:33 -0000 1.12
+++ mkfs.jffs.c 10 Nov 2004 19:46:15 -0000 1.13
@@ -20,6 +20,31 @@
#include <asm/byteorder.h>
#include <ctype.h>
+#define swab16(x) \
+ ((__u16)( \
+ (((__u16)(x) & (__u16)0x00ffU) << 8) | \
+ (((__u16)(x) & (__u16)0xff00U) >> 8) ))
+#define swab32(x) \
+ ((__u32)( \
+ (((__u32)(x) & (__u32)0x000000ffUL) << 24) | \
+ (((__u32)(x) & (__u32)0x0000ff00UL) << 8) | \
+ (((__u32)(x) & (__u32)0x00ff0000UL) >> 8) | \
+ (((__u32)(x) & (__u32)0xff000000UL) >> 24) ))
+
+#if __BYTE_ORDER == __BIG_ENDIAN
+#define cpu_to_le16(x) ({ __u16 _x = x; swab16(_x); })
+#define cpu_to_le32(x) ({ __u32 _x = x; swab32(_x); })
+#define cpu_to_be16(x) (x)
+#define cpu_to_be32(x) (x)
+#else
+#define cpu_to_le16(x) (x)
+#define cpu_to_le32(x) (x)
+#define cpu_to_be16(x) ({ __u16 _x = x; swab16(_x); })
+#define cpu_to_be32(x) ({ __u32 _x = x; swab32(_x); })
+#endif
+#define le32_to_cpu(x) cpu_to_le32(x)
+#define be32_to_cpu(x) cpu_to_be32(x)
+
#define BLOCK_SIZE 1024
#define JFFS_MAGIC 0x34383931 /* "1984" */
#define JFFS_MAX_NAME_LEN 256
@@ -184,10 +209,10 @@
*adr = val;
break;
case ENDIAN_LITTLE:
- *adr = __cpu_to_le32(val);
+ *adr = cpu_to_le32(val);
break;
case ENDIAN_BIG:
- *adr = __cpu_to_be32(val);
+ *adr = cpu_to_be32(val);
break;
}
}
@@ -199,10 +224,10 @@
*adr = val;
break;
case ENDIAN_LITTLE:
- *adr = __cpu_to_le16(val);
+ *adr = cpu_to_le16(val);
break;
case ENDIAN_BIG:
- *adr = __cpu_to_be16(val);
+ *adr = cpu_to_be16(val);
break;
}
}
@@ -216,10 +241,10 @@
val = *adr;
break;
case ENDIAN_LITTLE:
- val = __le32_to_cpu(*adr);
+ val = le32_to_cpu(*adr);
break;
case ENDIAN_BIG:
- val = __be32_to_cpu(*adr);
+ val = be32_to_cpu(*adr);
break;
}
return val;
@@ -322,10 +347,10 @@
tmp = st.st_rdev;
break;
case ENDIAN_LITTLE:
- tmp = __cpu_to_le16(st.st_rdev);
+ tmp = cpu_to_le16(st.st_rdev);
break;
case ENDIAN_BIG:
- tmp = __cpu_to_be16(st.st_rdev);
+ tmp = cpu_to_be16(st.st_rdev);
break;
}
fwrite((char *)&tmp, sizeof(st.st_rdev) / 4, 1, fs);
More information about the linux-mtd-cvs
mailing list