Changeset 8886


Ignore:
Timestamp:
2007-09-20T21:25:38+02:00 (10 years ago)
Author:
matteo
Message:

Make ar7_part more readable and endianness safe

Location:
trunk/target/linux
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/target/linux/ar7/files/drivers/mtd/ar7part.c

    r8764 r8886  
    2727#include <linux/mtd/partitions.h> 
    2828#include <linux/bootmem.h> 
    29 #include <linux/squashfs_fs.h> 
     29#include <linux/magic.h> 
     30 
     31#define AR7_PARTS       4 
     32#define ROOT_OFFSET     0xe0000 
     33 
     34#ifdef CONFIG_CPU_LITTLE_ENDIAN 
     35#define LOADER_MAGIC1   0xfeedfa42 
     36#define LOADER_MAGIC2   0xfeed1281 
     37#else 
     38#define LOADER_MAGIC1   0x42faedfe 
     39#define LOADER_MAGIC2   0x8112edfe 
     40#endif 
    3041 
    3142struct ar7_bin_rec { 
     
    3546}; 
    3647 
    37 static struct mtd_partition ar7_parts[5]; 
     48static struct mtd_partition ar7_parts[AR7_PARTS]; 
    3849 
    3950static int create_mtd_partitions(struct mtd_info *master, 
     
    4455        unsigned int offset, len; 
    4556        unsigned int pre_size = master->erasesize, post_size = 0; 
    46         unsigned int root_offset = 0xe0000; 
     57        unsigned int root_offset = ROOT_OFFSET; 
    4758 
    4859        int retries = 10; 
    49  
    50         printk(KERN_INFO "Parsing AR7 partition map...\n"); 
    5160 
    5261        ar7_parts[0].name = "loader"; 
     
    6675                if (!strncmp((char *)&header, "TIENV0.8", 8)) 
    6776                        ar7_parts[1].offset = pre_size; 
    68                 if (header.checksum == 0xfeedfa42) 
     77                if (header.checksum == LOADER_MAGIC1) 
    6978                        break; 
    70                 if (header.checksum == 0xfeed1281) 
     79                if (header.checksum == LOADER_MAGIC2) 
    7180                        break; 
    7281                pre_size += master->erasesize; 
     
    8190 
    8291        switch (header.checksum) { 
    83         case 0xfeedfa42: 
     92        case LOADER_MAGIC1: 
    8493                while (header.length) { 
    8594                        offset += sizeof(header) + header.length; 
     
    8998                root_offset = offset + sizeof(header) + 4; 
    9099                break; 
    91         case 0xfeed1281: 
     100        case LOADER_MAGIC2: 
    92101                while (header.length) { 
    93102                        offset += sizeof(header) + header.length; 
     
    121130 
    122131        *pparts = ar7_parts; 
    123         return 4; 
     132        return AR7_PARTS; 
    124133} 
    125134 
  • trunk/target/linux/generic-2.6/patches-2.6.22/001-squashfs.patch

    r7644 r8886  
    1 diff -urN linux-2.6.21.1.old/fs/Kconfig linux-2.6.21.1.dev/fs/Kconfig 
    2 --- linux-2.6.21.1.old/fs/Kconfig       2007-04-27 23:49:26.000000000 +0200 
    3 +++ linux-2.6.21.1.dev/fs/Kconfig       2007-05-26 19:00:37.121351760 +0200 
     1diff -urN linux-2.6.22.4/fs/Kconfig linux-2.6.22.4-squashfs/fs/Kconfig 
     2--- linux-2.6.22.4/fs/Kconfig   2007-08-21 06:33:06.000000000 +0200 
     3+++ linux-2.6.22.4-squashfs/fs/Kconfig  2007-09-20 19:13:44.000000000 +0200 
    44@@ -1367,6 +1367,71 @@ 
    55  
     
    7474        tristate "FreeVxFS file system support (VERITAS VxFS(TM) compatible)" 
    7575        depends on BLOCK 
    76 diff -urN linux-2.6.21.1.old/fs/Makefile linux-2.6.21.1.dev/fs/Makefile 
    77 --- linux-2.6.21.1.old/fs/Makefile      2007-04-27 23:49:26.000000000 +0200 
    78 +++ linux-2.6.21.1.dev/fs/Makefile      2007-05-26 19:00:37.121351760 +0200 
     76diff -urN linux-2.6.22.4/fs/Makefile linux-2.6.22.4-squashfs/fs/Makefile 
     77--- linux-2.6.22.4/fs/Makefile  2007-08-21 06:33:06.000000000 +0200 
     78+++ linux-2.6.22.4-squashfs/fs/Makefile 2007-09-20 19:13:44.000000000 +0200 
    7979@@ -72,6 +72,7 @@ 
    8080 obj-$(CONFIG_JBD2)             += jbd2/ 
     
    8585 obj-$(CONFIG_HUGETLBFS)                += hugetlbfs/ 
    8686 obj-$(CONFIG_CODA_FS)          += coda/ 
    87 diff -urN linux-2.6.21.1.old/fs/squashfs/inode.c linux-2.6.21.1.dev/fs/squashfs/inode.c 
    88 --- linux-2.6.21.1.old/fs/squashfs/inode.c      1970-01-01 01:00:00.000000000 +0100 
    89 +++ linux-2.6.21.1.dev/fs/squashfs/inode.c      2007-05-26 19:00:37.123351456 +0200 
     87diff -urN linux-2.6.22.4/fs/squashfs/inode.c linux-2.6.22.4-squashfs/fs/squashfs/inode.c 
     88--- linux-2.6.22.4/fs/squashfs/inode.c  1970-01-01 01:00:00.000000000 +0100 
     89+++ linux-2.6.22.4-squashfs/fs/squashfs/inode.c 2007-09-20 19:13:44.000000000 +0200 
    9090@@ -0,0 +1,2122 @@ 
    9191+/* 
     
    22112211+MODULE_AUTHOR("Phillip Lougher <phillip@lougher.org.uk>"); 
    22122212+MODULE_LICENSE("GPL"); 
    2213 diff -urN linux-2.6.21.1.old/fs/squashfs/Makefile linux-2.6.21.1.dev/fs/squashfs/Makefile 
    2214 --- linux-2.6.21.1.old/fs/squashfs/Makefile     1970-01-01 01:00:00.000000000 +0100 
    2215 +++ linux-2.6.21.1.dev/fs/squashfs/Makefile     2007-05-26 19:00:37.123351456 +0200 
     2213diff -urN linux-2.6.22.4/fs/squashfs/Makefile linux-2.6.22.4-squashfs/fs/squashfs/Makefile 
     2214--- linux-2.6.22.4/fs/squashfs/Makefile 1970-01-01 01:00:00.000000000 +0100 
     2215+++ linux-2.6.22.4-squashfs/fs/squashfs/Makefile        2007-09-20 19:13:44.000000000 +0200 
    22162216@@ -0,0 +1,7 @@ 
    22172217+# 
     
    22222222+squashfs-y += inode.o 
    22232223+squashfs-y += squashfs2_0.o 
    2224 diff -urN linux-2.6.21.1.old/fs/squashfs/squashfs2_0.c linux-2.6.21.1.dev/fs/squashfs/squashfs2_0.c 
    2225 --- linux-2.6.21.1.old/fs/squashfs/squashfs2_0.c        1970-01-01 01:00:00.000000000 +0100 
    2226 +++ linux-2.6.21.1.dev/fs/squashfs/squashfs2_0.c        2007-05-26 19:00:37.125351152 +0200 
     2224diff -urN linux-2.6.22.4/fs/squashfs/squashfs2_0.c linux-2.6.22.4-squashfs/fs/squashfs/squashfs2_0.c 
     2225--- linux-2.6.22.4/fs/squashfs/squashfs2_0.c    1970-01-01 01:00:00.000000000 +0100 
     2226+++ linux-2.6.22.4-squashfs/fs/squashfs/squashfs2_0.c   2007-09-20 19:13:44.000000000 +0200 
    22272227@@ -0,0 +1,758 @@ 
    22282228+/* 
     
    29842984+       return 1; 
    29852985+} 
    2986 diff -urN linux-2.6.21.1.old/fs/squashfs/squashfs.h linux-2.6.21.1.dev/fs/squashfs/squashfs.h 
    2987 --- linux-2.6.21.1.old/fs/squashfs/squashfs.h   1970-01-01 01:00:00.000000000 +0100 
    2988 +++ linux-2.6.21.1.dev/fs/squashfs/squashfs.h   2007-05-26 19:00:37.125351152 +0200 
     2986diff -urN linux-2.6.22.4/fs/squashfs/squashfs.h linux-2.6.22.4-squashfs/fs/squashfs/squashfs.h 
     2987--- linux-2.6.22.4/fs/squashfs/squashfs.h       1970-01-01 01:00:00.000000000 +0100 
     2988+++ linux-2.6.22.4-squashfs/fs/squashfs/squashfs.h      2007-09-20 19:13:44.000000000 +0200 
    29892989@@ -0,0 +1,86 @@ 
    29902990+/* 
     
    30743074+} 
    30753075+#endif 
    3076 diff -urN linux-2.6.21.1.old/include/linux/squashfs_fs.h linux-2.6.21.1.dev/include/linux/squashfs_fs.h 
    3077 --- linux-2.6.21.1.old/include/linux/squashfs_fs.h      1970-01-01 01:00:00.000000000 +0100 
    3078 +++ linux-2.6.21.1.dev/include/linux/squashfs_fs.h      2007-05-26 19:00:37.143348416 +0200 
     3076diff -urN linux-2.6.22.4/include/linux/magic.h linux-2.6.22.4-squashfs/include/linux/magic.h 
     3077--- linux-2.6.22.4/include/linux/magic.h        2007-08-21 06:33:06.000000000 +0200 
     3078+++ linux-2.6.22.4-squashfs/include/linux/magic.h       2007-09-20 19:15:43.000000000 +0200 
     3079@@ -36,6 +36,9 @@ 
     3080 #define REISER2FS_SUPER_MAGIC_STRING   "ReIsEr2Fs" 
     3081 #define REISER2FS_JR_SUPER_MAGIC_STRING        "ReIsEr3Fs" 
     3082  
     3083+#define SQUASHFS_MAGIC                 0x73717368 
     3084+#define SQUASHFS_MAGIC_SWAP            0x68737173 
     3085+ 
     3086 #define SMB_SUPER_MAGIC                0x517B 
     3087 #define USBDEVICE_SUPER_MAGIC  0x9fa2 
     3088  
     3089diff -urN linux-2.6.22.4/include/linux/squashfs_fs.h linux-2.6.22.4-squashfs/include/linux/squashfs_fs.h 
     3090--- linux-2.6.22.4/include/linux/squashfs_fs.h  1970-01-01 01:00:00.000000000 +0100 
     3091+++ linux-2.6.22.4-squashfs/include/linux/squashfs_fs.h 2007-09-20 19:15:01.000000000 +0200 
    30793092@@ -0,0 +1,911 @@ 
    30803093+#ifndef SQUASHFS_FS 
     
    31183131+#define SQUASHFS_MAJOR                 3 
    31193132+#define SQUASHFS_MINOR                 0 
    3120 +#define SQUASHFS_MAGIC                 0x73717368 
    3121 +#define SQUASHFS_MAGIC_SWAP            0x68737173 
    31223133+#define SQUASHFS_START                 0 
    31233134+ 
     
    32633274+#define SQUASHFS_META_NUMBER   8 
    32643275+#define SQUASHFS_SLOTS         4 
     3276+ 
     3277+#include <linux/magic.h> 
    32653278+ 
    32663279+struct meta_entry { 
     
    39894002+#endif 
    39904003+#endif 
    3991 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 
    3992 --- linux-2.6.21.1.old/include/linux/squashfs_fs_i.h    1970-01-01 01:00:00.000000000 +0100 
    3993 +++ linux-2.6.21.1.dev/include/linux/squashfs_fs_i.h    2007-05-26 19:00:37.143348416 +0200 
     4004diff -urN linux-2.6.22.4/include/linux/squashfs_fs_i.h linux-2.6.22.4-squashfs/include/linux/squashfs_fs_i.h 
     4005--- linux-2.6.22.4/include/linux/squashfs_fs_i.h        1970-01-01 01:00:00.000000000 +0100 
     4006+++ linux-2.6.22.4-squashfs/include/linux/squashfs_fs_i.h       2007-09-20 19:13:44.000000000 +0200 
    39944007@@ -0,0 +1,45 @@ 
    39954008+#ifndef SQUASHFS_FS_I 
     
    40384051+}; 
    40394052+#endif 
    4040 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 
    4041 --- linux-2.6.21.1.old/include/linux/squashfs_fs_sb.h   1970-01-01 01:00:00.000000000 +0100 
    4042 +++ linux-2.6.21.1.dev/include/linux/squashfs_fs_sb.h   2007-05-26 19:00:37.144348264 +0200 
     4053diff -urN linux-2.6.22.4/include/linux/squashfs_fs_sb.h linux-2.6.22.4-squashfs/include/linux/squashfs_fs_sb.h 
     4054--- linux-2.6.22.4/include/linux/squashfs_fs_sb.h       1970-01-01 01:00:00.000000000 +0100 
     4055+++ linux-2.6.22.4-squashfs/include/linux/squashfs_fs_sb.h      2007-09-20 19:13:44.000000000 +0200 
    40434056@@ -0,0 +1,74 @@ 
    40444057+#ifndef SQUASHFS_FS_SB 
     
    41164129+}; 
    41174130+#endif 
    4118 diff -urN linux-2.6.21.1.old/init/do_mounts_rd.c linux-2.6.21.1.dev/init/do_mounts_rd.c 
    4119 --- linux-2.6.21.1.old/init/do_mounts_rd.c      2007-04-27 23:49:26.000000000 +0200 
    4120 +++ linux-2.6.21.1.dev/init/do_mounts_rd.c      2007-05-26 19:00:37.144348264 +0200 
     4131diff -urN linux-2.6.22.4/init/do_mounts_rd.c linux-2.6.22.4-squashfs/init/do_mounts_rd.c 
     4132--- linux-2.6.22.4/init/do_mounts_rd.c  2007-08-21 06:33:06.000000000 +0200 
     4133+++ linux-2.6.22.4-squashfs/init/do_mounts_rd.c 2007-09-20 19:13:44.000000000 +0200 
    41214134@@ -5,6 +5,7 @@ 
    41224135 #include <linux/ext2_fs.h> 
Note: See TracChangeset for help on using the changeset viewer.