forward port missing parts of the mtd permission change in whiterussian (and add...
[openwrt.git] / target / linux / generic-2.6 / patches / 050-mtdpart_redboot_partition_truncate.patch
1 Redboot supports storing the FIS directory and the RedBoot
2 configuration information in the same block of flash memory. This is
3 not the most common RedBoot configuration, but it is used on
4 commercially available boards supported by the kernel.
5
6 A recent patch to mtd/redboot.c (http://lkml.org/lkml/2006/3/20/410)
7 which corrected the skipping of deleted table entries has exposed the
8 latent problem of the kernel redboot parser running off the end of the
9 FIS directory and interpreting the RedBoot configuration information
10 as table entries.
11
12 This patch terminates the table parsing when the first truly empty
13 entry is found (table entry deletion only clears the first byte of the
14 name, so two cleared bytes in a row indicates the end of the table),
15 thereby supporting the combined redboot FIS directory and RedBoot
16 configuration information flash layout scenario.
17
18 Signed-off-by: Rod Whitby <rod@whitby.id.au>
19 --
20
21 Index: linux-2.6.19/drivers/mtd/redboot.c
22 ===================================================================
23 --- linux-2.6.19.orig/drivers/mtd/redboot.c
24 +++ linux-2.6.19/drivers/mtd/redboot.c
25 @@ -96,7 +96,19 @@ static int parse_redboot_partitions(stru
26 */
27 if (swab32(buf[i].size) == master->erasesize) {
28 int j;
29 - for (j = 0; j < numslots && buf[j].name[0] != 0xff; ++j) {
30 + for (j = 0; j < numslots; ++j) {
31 +
32 + /* A single 0xff denotes a deleted entry.
33 + * Two of them in a row is the end of the table.
34 + */
35 + if (buf[j].name[0] == 0xff) {
36 + if (buf[j].name[1] == 0xff) {
37 + break;
38 + } else {
39 + continue;
40 + }
41 + }
42 +
43 /* The unsigned long fields were written with the
44 * wrong byte sex, name and pad have no byte sex.
45 */
46 @@ -123,8 +135,13 @@ static int parse_redboot_partitions(stru
47 for (i = 0; i < numslots; i++) {
48 struct fis_list *new_fl, **prev;
49
50 - if (buf[i].name[0] == 0xff)
51 - continue;
52 + if (buf[i].name[0] == 0xff) {
53 + if (buf[i].name[1] == 0xff) {
54 + break;
55 + } else {
56 + continue;
57 + }
58 + }
59 if (!redboot_checksum(&buf[i]))
60 break;
61
This page took 0.042187 seconds and 5 git commands to generate.