diff -ubNr --exclude=.gitignore linux-2.6.18/drivers/mtd/redboot.c /tmp/fc_base/opt/amltd/develop/linuxppc-2.6/drivers/mtd/redboot.c --- linux-2.6.18/drivers/mtd/redboot.c 2006-09-19 21:42:06.000000000 -0600 +++ /tmp/fc_base/opt/amltd/develop/linuxppc-2.6/drivers/mtd/redboot.c 2006-10-24 11:59:32.000000000 -0600 @@ -85,6 +85,10 @@ numslots = (master->erasesize / sizeof(struct fis_image_desc)); for (i = 0; i < numslots; i++) { + if (buf[i].name[0] == 0xff) { + i = numslots; + break; + } if (!memcmp(buf[i].name, "FIS directory", 14)) { /* This is apparently the FIS directory entry for the * FIS directory itself. The FIS directory size is @@ -124,7 +128,7 @@ struct fis_list *new_fl, **prev; if (buf[i].name[0] == 0xff) - continue; + break; if (!redboot_checksum(&buf[i])) break; @@ -196,14 +200,22 @@ parts[i].size = fl->img->size; parts[i].offset = fl->img->flash_base; parts[i].name = names; - strcpy(names, fl->img->name); + #ifdef CONFIG_MTD_REDBOOT_PARTS_READONLY if (!memcmp(names, "RedBoot", 8) || !memcmp(names, "RedBoot config", 15) || !memcmp(names, "FIS directory", 14)) { parts[i].mask_flags = MTD_WRITEABLE; } +#else + if (!memcmp(names, "FIS directory", 14)) { + // Special hack to let directory be read/write + if ((fl->img->size & (master->erasesize - 1)) != 0) { + parts[i].size = (fl->img->size + (master->erasesize - 1)) & ~(master->erasesize - 1); + } + } + #endif names += strlen(names)+1;