Make ar7_part more readable and endianness safe
SVN-Revision: 8886
This commit is contained in:
parent
fbc7e5e4fc
commit
8d162264af
2 changed files with 64 additions and 42 deletions
|
@ -26,7 +26,18 @@
|
||||||
#include <linux/mtd/mtd.h>
|
#include <linux/mtd/mtd.h>
|
||||||
#include <linux/mtd/partitions.h>
|
#include <linux/mtd/partitions.h>
|
||||||
#include <linux/bootmem.h>
|
#include <linux/bootmem.h>
|
||||||
#include <linux/squashfs_fs.h>
|
#include <linux/magic.h>
|
||||||
|
|
||||||
|
#define AR7_PARTS 4
|
||||||
|
#define ROOT_OFFSET 0xe0000
|
||||||
|
|
||||||
|
#ifdef CONFIG_CPU_LITTLE_ENDIAN
|
||||||
|
#define LOADER_MAGIC1 0xfeedfa42
|
||||||
|
#define LOADER_MAGIC2 0xfeed1281
|
||||||
|
#else
|
||||||
|
#define LOADER_MAGIC1 0x42faedfe
|
||||||
|
#define LOADER_MAGIC2 0x8112edfe
|
||||||
|
#endif
|
||||||
|
|
||||||
struct ar7_bin_rec {
|
struct ar7_bin_rec {
|
||||||
unsigned int checksum;
|
unsigned int checksum;
|
||||||
|
@ -34,7 +45,7 @@ struct ar7_bin_rec {
|
||||||
unsigned int address;
|
unsigned int address;
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct mtd_partition ar7_parts[5];
|
static struct mtd_partition ar7_parts[AR7_PARTS];
|
||||||
|
|
||||||
static int create_mtd_partitions(struct mtd_info *master,
|
static int create_mtd_partitions(struct mtd_info *master,
|
||||||
struct mtd_partition **pparts,
|
struct mtd_partition **pparts,
|
||||||
|
@ -43,12 +54,10 @@ static int create_mtd_partitions(struct mtd_info *master,
|
||||||
struct ar7_bin_rec header;
|
struct ar7_bin_rec header;
|
||||||
unsigned int offset, len;
|
unsigned int offset, len;
|
||||||
unsigned int pre_size = master->erasesize, post_size = 0;
|
unsigned int pre_size = master->erasesize, post_size = 0;
|
||||||
unsigned int root_offset = 0xe0000;
|
unsigned int root_offset = ROOT_OFFSET;
|
||||||
|
|
||||||
int retries = 10;
|
int retries = 10;
|
||||||
|
|
||||||
printk(KERN_INFO "Parsing AR7 partition map...\n");
|
|
||||||
|
|
||||||
ar7_parts[0].name = "loader";
|
ar7_parts[0].name = "loader";
|
||||||
ar7_parts[0].offset = 0;
|
ar7_parts[0].offset = 0;
|
||||||
ar7_parts[0].size = master->erasesize;
|
ar7_parts[0].size = master->erasesize;
|
||||||
|
@ -65,9 +74,9 @@ static int create_mtd_partitions(struct mtd_info *master,
|
||||||
sizeof(header), &len, (u_char *)&header);
|
sizeof(header), &len, (u_char *)&header);
|
||||||
if (!strncmp((char *)&header, "TIENV0.8", 8))
|
if (!strncmp((char *)&header, "TIENV0.8", 8))
|
||||||
ar7_parts[1].offset = pre_size;
|
ar7_parts[1].offset = pre_size;
|
||||||
if (header.checksum == 0xfeedfa42)
|
if (header.checksum == LOADER_MAGIC1)
|
||||||
break;
|
break;
|
||||||
if (header.checksum == 0xfeed1281)
|
if (header.checksum == LOADER_MAGIC2)
|
||||||
break;
|
break;
|
||||||
pre_size += master->erasesize;
|
pre_size += master->erasesize;
|
||||||
} while (retries--);
|
} while (retries--);
|
||||||
|
@ -80,7 +89,7 @@ static int create_mtd_partitions(struct mtd_info *master,
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (header.checksum) {
|
switch (header.checksum) {
|
||||||
case 0xfeedfa42:
|
case LOADER_MAGIC1:
|
||||||
while (header.length) {
|
while (header.length) {
|
||||||
offset += sizeof(header) + header.length;
|
offset += sizeof(header) + header.length;
|
||||||
master->read(master, offset, sizeof(header),
|
master->read(master, offset, sizeof(header),
|
||||||
|
@ -88,7 +97,7 @@ static int create_mtd_partitions(struct mtd_info *master,
|
||||||
}
|
}
|
||||||
root_offset = offset + sizeof(header) + 4;
|
root_offset = offset + sizeof(header) + 4;
|
||||||
break;
|
break;
|
||||||
case 0xfeed1281:
|
case LOADER_MAGIC2:
|
||||||
while (header.length) {
|
while (header.length) {
|
||||||
offset += sizeof(header) + header.length;
|
offset += sizeof(header) + header.length;
|
||||||
master->read(master, offset, sizeof(header),
|
master->read(master, offset, sizeof(header),
|
||||||
|
@ -120,7 +129,7 @@ static int create_mtd_partitions(struct mtd_info *master,
|
||||||
ar7_parts[3].mask_flags = 0;
|
ar7_parts[3].mask_flags = 0;
|
||||||
|
|
||||||
*pparts = ar7_parts;
|
*pparts = ar7_parts;
|
||||||
return 4;
|
return AR7_PARTS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct mtd_part_parser ar7_parser = {
|
static struct mtd_part_parser ar7_parser = {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
diff -urN linux-2.6.21.1.old/fs/Kconfig linux-2.6.21.1.dev/fs/Kconfig
|
diff -urN linux-2.6.22.4/fs/Kconfig linux-2.6.22.4-squashfs/fs/Kconfig
|
||||||
--- linux-2.6.21.1.old/fs/Kconfig 2007-04-27 23:49:26.000000000 +0200
|
--- linux-2.6.22.4/fs/Kconfig 2007-08-21 06:33:06.000000000 +0200
|
||||||
+++ linux-2.6.21.1.dev/fs/Kconfig 2007-05-26 19:00:37.121351760 +0200
|
+++ linux-2.6.22.4-squashfs/fs/Kconfig 2007-09-20 19:13:44.000000000 +0200
|
||||||
@@ -1367,6 +1367,71 @@
|
@@ -1367,6 +1367,71 @@
|
||||||
|
|
||||||
If unsure, say N.
|
If unsure, say N.
|
||||||
|
@ -73,9 +73,9 @@ diff -urN linux-2.6.21.1.old/fs/Kconfig linux-2.6.21.1.dev/fs/Kconfig
|
||||||
config VXFS_FS
|
config VXFS_FS
|
||||||
tristate "FreeVxFS file system support (VERITAS VxFS(TM) compatible)"
|
tristate "FreeVxFS file system support (VERITAS VxFS(TM) compatible)"
|
||||||
depends on BLOCK
|
depends on BLOCK
|
||||||
diff -urN linux-2.6.21.1.old/fs/Makefile linux-2.6.21.1.dev/fs/Makefile
|
diff -urN linux-2.6.22.4/fs/Makefile linux-2.6.22.4-squashfs/fs/Makefile
|
||||||
--- linux-2.6.21.1.old/fs/Makefile 2007-04-27 23:49:26.000000000 +0200
|
--- linux-2.6.22.4/fs/Makefile 2007-08-21 06:33:06.000000000 +0200
|
||||||
+++ linux-2.6.21.1.dev/fs/Makefile 2007-05-26 19:00:37.121351760 +0200
|
+++ linux-2.6.22.4-squashfs/fs/Makefile 2007-09-20 19:13:44.000000000 +0200
|
||||||
@@ -72,6 +72,7 @@
|
@@ -72,6 +72,7 @@
|
||||||
obj-$(CONFIG_JBD2) += jbd2/
|
obj-$(CONFIG_JBD2) += jbd2/
|
||||||
obj-$(CONFIG_EXT2_FS) += ext2/
|
obj-$(CONFIG_EXT2_FS) += ext2/
|
||||||
|
@ -84,9 +84,9 @@ diff -urN linux-2.6.21.1.old/fs/Makefile linux-2.6.21.1.dev/fs/Makefile
|
||||||
obj-$(CONFIG_RAMFS) += ramfs/
|
obj-$(CONFIG_RAMFS) += ramfs/
|
||||||
obj-$(CONFIG_HUGETLBFS) += hugetlbfs/
|
obj-$(CONFIG_HUGETLBFS) += hugetlbfs/
|
||||||
obj-$(CONFIG_CODA_FS) += coda/
|
obj-$(CONFIG_CODA_FS) += coda/
|
||||||
diff -urN linux-2.6.21.1.old/fs/squashfs/inode.c linux-2.6.21.1.dev/fs/squashfs/inode.c
|
diff -urN linux-2.6.22.4/fs/squashfs/inode.c linux-2.6.22.4-squashfs/fs/squashfs/inode.c
|
||||||
--- linux-2.6.21.1.old/fs/squashfs/inode.c 1970-01-01 01:00:00.000000000 +0100
|
--- linux-2.6.22.4/fs/squashfs/inode.c 1970-01-01 01:00:00.000000000 +0100
|
||||||
+++ linux-2.6.21.1.dev/fs/squashfs/inode.c 2007-05-26 19:00:37.123351456 +0200
|
+++ linux-2.6.22.4-squashfs/fs/squashfs/inode.c 2007-09-20 19:13:44.000000000 +0200
|
||||||
@@ -0,0 +1,2122 @@
|
@@ -0,0 +1,2122 @@
|
||||||
+/*
|
+/*
|
||||||
+ * Squashfs - a compressed read only filesystem for Linux
|
+ * Squashfs - a compressed read only filesystem for Linux
|
||||||
|
@ -2210,9 +2210,9 @@ diff -urN linux-2.6.21.1.old/fs/squashfs/inode.c linux-2.6.21.1.dev/fs/squashfs/
|
||||||
+MODULE_DESCRIPTION("squashfs, a compressed read-only filesystem");
|
+MODULE_DESCRIPTION("squashfs, a compressed read-only filesystem");
|
||||||
+MODULE_AUTHOR("Phillip Lougher <phillip@lougher.org.uk>");
|
+MODULE_AUTHOR("Phillip Lougher <phillip@lougher.org.uk>");
|
||||||
+MODULE_LICENSE("GPL");
|
+MODULE_LICENSE("GPL");
|
||||||
diff -urN linux-2.6.21.1.old/fs/squashfs/Makefile linux-2.6.21.1.dev/fs/squashfs/Makefile
|
diff -urN linux-2.6.22.4/fs/squashfs/Makefile linux-2.6.22.4-squashfs/fs/squashfs/Makefile
|
||||||
--- linux-2.6.21.1.old/fs/squashfs/Makefile 1970-01-01 01:00:00.000000000 +0100
|
--- linux-2.6.22.4/fs/squashfs/Makefile 1970-01-01 01:00:00.000000000 +0100
|
||||||
+++ linux-2.6.21.1.dev/fs/squashfs/Makefile 2007-05-26 19:00:37.123351456 +0200
|
+++ linux-2.6.22.4-squashfs/fs/squashfs/Makefile 2007-09-20 19:13:44.000000000 +0200
|
||||||
@@ -0,0 +1,7 @@
|
@@ -0,0 +1,7 @@
|
||||||
+#
|
+#
|
||||||
+# Makefile for the linux squashfs routines.
|
+# Makefile for the linux squashfs routines.
|
||||||
|
@ -2221,9 +2221,9 @@ diff -urN linux-2.6.21.1.old/fs/squashfs/Makefile linux-2.6.21.1.dev/fs/squashfs
|
||||||
+obj-$(CONFIG_SQUASHFS) += squashfs.o
|
+obj-$(CONFIG_SQUASHFS) += squashfs.o
|
||||||
+squashfs-y += inode.o
|
+squashfs-y += inode.o
|
||||||
+squashfs-y += squashfs2_0.o
|
+squashfs-y += squashfs2_0.o
|
||||||
diff -urN linux-2.6.21.1.old/fs/squashfs/squashfs2_0.c linux-2.6.21.1.dev/fs/squashfs/squashfs2_0.c
|
diff -urN linux-2.6.22.4/fs/squashfs/squashfs2_0.c linux-2.6.22.4-squashfs/fs/squashfs/squashfs2_0.c
|
||||||
--- linux-2.6.21.1.old/fs/squashfs/squashfs2_0.c 1970-01-01 01:00:00.000000000 +0100
|
--- linux-2.6.22.4/fs/squashfs/squashfs2_0.c 1970-01-01 01:00:00.000000000 +0100
|
||||||
+++ linux-2.6.21.1.dev/fs/squashfs/squashfs2_0.c 2007-05-26 19:00:37.125351152 +0200
|
+++ linux-2.6.22.4-squashfs/fs/squashfs/squashfs2_0.c 2007-09-20 19:13:44.000000000 +0200
|
||||||
@@ -0,0 +1,758 @@
|
@@ -0,0 +1,758 @@
|
||||||
+/*
|
+/*
|
||||||
+ * Squashfs - a compressed read only filesystem for Linux
|
+ * Squashfs - a compressed read only filesystem for Linux
|
||||||
|
@ -2983,9 +2983,9 @@ diff -urN linux-2.6.21.1.old/fs/squashfs/squashfs2_0.c linux-2.6.21.1.dev/fs/squ
|
||||||
+
|
+
|
||||||
+ return 1;
|
+ return 1;
|
||||||
+}
|
+}
|
||||||
diff -urN linux-2.6.21.1.old/fs/squashfs/squashfs.h linux-2.6.21.1.dev/fs/squashfs/squashfs.h
|
diff -urN linux-2.6.22.4/fs/squashfs/squashfs.h linux-2.6.22.4-squashfs/fs/squashfs/squashfs.h
|
||||||
--- linux-2.6.21.1.old/fs/squashfs/squashfs.h 1970-01-01 01:00:00.000000000 +0100
|
--- linux-2.6.22.4/fs/squashfs/squashfs.h 1970-01-01 01:00:00.000000000 +0100
|
||||||
+++ linux-2.6.21.1.dev/fs/squashfs/squashfs.h 2007-05-26 19:00:37.125351152 +0200
|
+++ linux-2.6.22.4-squashfs/fs/squashfs/squashfs.h 2007-09-20 19:13:44.000000000 +0200
|
||||||
@@ -0,0 +1,86 @@
|
@@ -0,0 +1,86 @@
|
||||||
+/*
|
+/*
|
||||||
+ * Squashfs - a compressed read only filesystem for Linux
|
+ * Squashfs - a compressed read only filesystem for Linux
|
||||||
|
@ -3073,9 +3073,22 @@ diff -urN linux-2.6.21.1.old/fs/squashfs/squashfs.h linux-2.6.21.1.dev/fs/squash
|
||||||
+ return 0;
|
+ return 0;
|
||||||
+}
|
+}
|
||||||
+#endif
|
+#endif
|
||||||
diff -urN linux-2.6.21.1.old/include/linux/squashfs_fs.h linux-2.6.21.1.dev/include/linux/squashfs_fs.h
|
diff -urN linux-2.6.22.4/include/linux/magic.h linux-2.6.22.4-squashfs/include/linux/magic.h
|
||||||
--- linux-2.6.21.1.old/include/linux/squashfs_fs.h 1970-01-01 01:00:00.000000000 +0100
|
--- linux-2.6.22.4/include/linux/magic.h 2007-08-21 06:33:06.000000000 +0200
|
||||||
+++ linux-2.6.21.1.dev/include/linux/squashfs_fs.h 2007-05-26 19:00:37.143348416 +0200
|
+++ linux-2.6.22.4-squashfs/include/linux/magic.h 2007-09-20 19:15:43.000000000 +0200
|
||||||
|
@@ -36,6 +36,9 @@
|
||||||
|
#define REISER2FS_SUPER_MAGIC_STRING "ReIsEr2Fs"
|
||||||
|
#define REISER2FS_JR_SUPER_MAGIC_STRING "ReIsEr3Fs"
|
||||||
|
|
||||||
|
+#define SQUASHFS_MAGIC 0x73717368
|
||||||
|
+#define SQUASHFS_MAGIC_SWAP 0x68737173
|
||||||
|
+
|
||||||
|
#define SMB_SUPER_MAGIC 0x517B
|
||||||
|
#define USBDEVICE_SUPER_MAGIC 0x9fa2
|
||||||
|
|
||||||
|
diff -urN linux-2.6.22.4/include/linux/squashfs_fs.h linux-2.6.22.4-squashfs/include/linux/squashfs_fs.h
|
||||||
|
--- linux-2.6.22.4/include/linux/squashfs_fs.h 1970-01-01 01:00:00.000000000 +0100
|
||||||
|
+++ linux-2.6.22.4-squashfs/include/linux/squashfs_fs.h 2007-09-20 19:15:01.000000000 +0200
|
||||||
@@ -0,0 +1,911 @@
|
@@ -0,0 +1,911 @@
|
||||||
+#ifndef SQUASHFS_FS
|
+#ifndef SQUASHFS_FS
|
||||||
+#define SQUASHFS_FS
|
+#define SQUASHFS_FS
|
||||||
|
@ -3117,8 +3130,6 @@ diff -urN linux-2.6.21.1.old/include/linux/squashfs_fs.h linux-2.6.21.1.dev/incl
|
||||||
+#define SQUASHFS_CACHED_FRAGMENTS CONFIG_SQUASHFS_FRAGMENT_CACHE_SIZE
|
+#define SQUASHFS_CACHED_FRAGMENTS CONFIG_SQUASHFS_FRAGMENT_CACHE_SIZE
|
||||||
+#define SQUASHFS_MAJOR 3
|
+#define SQUASHFS_MAJOR 3
|
||||||
+#define SQUASHFS_MINOR 0
|
+#define SQUASHFS_MINOR 0
|
||||||
+#define SQUASHFS_MAGIC 0x73717368
|
|
||||||
+#define SQUASHFS_MAGIC_SWAP 0x68737173
|
|
||||||
+#define SQUASHFS_START 0
|
+#define SQUASHFS_START 0
|
||||||
+
|
+
|
||||||
+/* size of metadata (inode and directory) blocks */
|
+/* size of metadata (inode and directory) blocks */
|
||||||
|
@ -3263,6 +3274,8 @@ diff -urN linux-2.6.21.1.old/include/linux/squashfs_fs.h linux-2.6.21.1.dev/incl
|
||||||
+#define SQUASHFS_META_NUMBER 8
|
+#define SQUASHFS_META_NUMBER 8
|
||||||
+#define SQUASHFS_SLOTS 4
|
+#define SQUASHFS_SLOTS 4
|
||||||
+
|
+
|
||||||
|
+#include <linux/magic.h>
|
||||||
|
+
|
||||||
+struct meta_entry {
|
+struct meta_entry {
|
||||||
+ long long data_block;
|
+ long long data_block;
|
||||||
+ unsigned int index_block;
|
+ unsigned int index_block;
|
||||||
|
@ -3988,9 +4001,9 @@ diff -urN linux-2.6.21.1.old/include/linux/squashfs_fs.h linux-2.6.21.1.dev/incl
|
||||||
+
|
+
|
||||||
+#endif
|
+#endif
|
||||||
+#endif
|
+#endif
|
||||||
diff -urN linux-2.6.21.1.old/include/linux/squashfs_fs_i.h linux-2.6.21.1.dev/include/linux/squashfs_fs_i.h
|
diff -urN linux-2.6.22.4/include/linux/squashfs_fs_i.h linux-2.6.22.4-squashfs/include/linux/squashfs_fs_i.h
|
||||||
--- linux-2.6.21.1.old/include/linux/squashfs_fs_i.h 1970-01-01 01:00:00.000000000 +0100
|
--- linux-2.6.22.4/include/linux/squashfs_fs_i.h 1970-01-01 01:00:00.000000000 +0100
|
||||||
+++ linux-2.6.21.1.dev/include/linux/squashfs_fs_i.h 2007-05-26 19:00:37.143348416 +0200
|
+++ linux-2.6.22.4-squashfs/include/linux/squashfs_fs_i.h 2007-09-20 19:13:44.000000000 +0200
|
||||||
@@ -0,0 +1,45 @@
|
@@ -0,0 +1,45 @@
|
||||||
+#ifndef SQUASHFS_FS_I
|
+#ifndef SQUASHFS_FS_I
|
||||||
+#define SQUASHFS_FS_I
|
+#define SQUASHFS_FS_I
|
||||||
|
@ -4037,9 +4050,9 @@ diff -urN linux-2.6.21.1.old/include/linux/squashfs_fs_i.h linux-2.6.21.1.dev/in
|
||||||
+ struct inode vfs_inode;
|
+ struct inode vfs_inode;
|
||||||
+};
|
+};
|
||||||
+#endif
|
+#endif
|
||||||
diff -urN linux-2.6.21.1.old/include/linux/squashfs_fs_sb.h linux-2.6.21.1.dev/include/linux/squashfs_fs_sb.h
|
diff -urN linux-2.6.22.4/include/linux/squashfs_fs_sb.h linux-2.6.22.4-squashfs/include/linux/squashfs_fs_sb.h
|
||||||
--- linux-2.6.21.1.old/include/linux/squashfs_fs_sb.h 1970-01-01 01:00:00.000000000 +0100
|
--- linux-2.6.22.4/include/linux/squashfs_fs_sb.h 1970-01-01 01:00:00.000000000 +0100
|
||||||
+++ linux-2.6.21.1.dev/include/linux/squashfs_fs_sb.h 2007-05-26 19:00:37.144348264 +0200
|
+++ linux-2.6.22.4-squashfs/include/linux/squashfs_fs_sb.h 2007-09-20 19:13:44.000000000 +0200
|
||||||
@@ -0,0 +1,74 @@
|
@@ -0,0 +1,74 @@
|
||||||
+#ifndef SQUASHFS_FS_SB
|
+#ifndef SQUASHFS_FS_SB
|
||||||
+#define SQUASHFS_FS_SB
|
+#define SQUASHFS_FS_SB
|
||||||
|
@ -4115,9 +4128,9 @@ diff -urN linux-2.6.21.1.old/include/linux/squashfs_fs_sb.h linux-2.6.21.1.dev/i
|
||||||
+ int (*read_fragment_index_table)(struct super_block *s);
|
+ int (*read_fragment_index_table)(struct super_block *s);
|
||||||
+};
|
+};
|
||||||
+#endif
|
+#endif
|
||||||
diff -urN linux-2.6.21.1.old/init/do_mounts_rd.c linux-2.6.21.1.dev/init/do_mounts_rd.c
|
diff -urN linux-2.6.22.4/init/do_mounts_rd.c linux-2.6.22.4-squashfs/init/do_mounts_rd.c
|
||||||
--- linux-2.6.21.1.old/init/do_mounts_rd.c 2007-04-27 23:49:26.000000000 +0200
|
--- linux-2.6.22.4/init/do_mounts_rd.c 2007-08-21 06:33:06.000000000 +0200
|
||||||
+++ linux-2.6.21.1.dev/init/do_mounts_rd.c 2007-05-26 19:00:37.144348264 +0200
|
+++ linux-2.6.22.4-squashfs/init/do_mounts_rd.c 2007-09-20 19:13:44.000000000 +0200
|
||||||
@@ -5,6 +5,7 @@
|
@@ -5,6 +5,7 @@
|
||||||
#include <linux/ext2_fs.h>
|
#include <linux/ext2_fs.h>
|
||||||
#include <linux/romfs_fs.h>
|
#include <linux/romfs_fs.h>
|
||||||
|
|
Loading…
Reference in a new issue