mtd/util docfdisk.c,1.4,1.5
dbrown at infradead.org
dbrown at infradead.org
Wed Jul 28 09:38:00 EDT 2004
Update of /home/cvs/mtd/util
In directory phoenix.infradead.org:/tmp/cvs-serv29430
Modified Files:
docfdisk.c
Log Message:
One more attempt to skip ECC errors, out of sheer stubbornness. Also first attempt to fix some partition logic errors.
Index: docfdisk.c
===================================================================
RCS file: /home/cvs/mtd/util/docfdisk.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- docfdisk.c 28 Jul 2004 13:01:34 -0000 1.4
+++ docfdisk.c 28 Jul 2004 13:37:58 -0000 1.5
@@ -169,6 +169,8 @@
unsigned char *oobbuf;
struct mtd_oob_buf oob;
char line[20];
+ int mhoffs;
+ struct INFTLMediaHeader *mh2;
if (argc < 2) {
printf(
@@ -219,7 +221,7 @@
for (mhblock = 0; mhblock < MAXSCAN; mhblock++) {
if ((ret = pread(fd, buf, meminfo.erasesize, mhblock * meminfo.erasesize)) < 0) {
- if (errno == -EBADMSG) {
+ if (errno == EBADMSG) {
printf("ECC error at eraseblock %d\n", mhblock);
continue;
}
@@ -237,9 +239,10 @@
return 1;
}
printf("Found INFTL Media Header at block %d:\n", mhblock);
+ mhoffs = mhblock * meminfo.erasesize;
oob.ptr = oobbuf;
- oob.start = mhblock * meminfo.erasesize;
+ oob.start = mhoffs;
for (i = 0; i < meminfo.erasesize; i += meminfo.oobblock) {
if (ioctl(fd, MEMREADOOB, &oob)) {
perror("ioctl(MEMREADOOB)");
@@ -249,7 +252,7 @@
oob.ptr += meminfo.oobsize;
}
- show_header(oob.start);
+ show_header(mhoffs);
if (!npart)
return 0;
@@ -259,7 +262,7 @@
unitsize = meminfo.erasesize >> le32_to_cpu(mh->BlockMultiplierBits);
totblocks = meminfo.size / unitsize;
- block = oob.start / unitsize;
+ block = mhoffs / unitsize;
block++;
mh->NoOfBDTLPartitions = 0;
@@ -282,8 +285,12 @@
}
ip->flags = cpu_to_le32(INFTL_BINARY | INFTL_LAST);
+ /* update the spare as well */
+ mh2 = (struct INFTLMediaHeader *) (buf + 4096);
+ memcpy((void *) mh2, (void *) mh, sizeof(struct INFTLMediaHeader));
+
printf("\nProposed new Media Header:\n");
- show_header(oob.start);
+ show_header(mhoffs);
printf("\nReady to update device. Type 'yes' to proceed, anything else to abort: ");
fgets(line, sizeof(line), stdin);
@@ -291,7 +298,7 @@
return 0;
printf("Updating MediaHeader...\n");
- erase.start = mhblock * meminfo.erasesize;
+ erase.start = mhoffs;
erase.length = meminfo.erasesize;
if (ioctl(fd, MEMERASE, &erase)) {
perror("ioctl(MEMERASE)");
@@ -299,7 +306,7 @@
return 1;
}
- if ((ret = pwrite(fd, buf, meminfo.erasesize, mhblock * meminfo.erasesize)) < 0) {
+ if ((ret = pwrite(fd, buf, meminfo.erasesize, mhoffs)) < 0) {
perror("Write eraseblock");
printf("Your MediaHeader may be hosed. UHOH!\n");
return 1;
@@ -311,7 +318,7 @@
}
oob.ptr = oobbuf;
- oob.start = mhblock * meminfo.erasesize;
+ oob.start = mhoffs;
for (i = 0; i < meminfo.erasesize; i += meminfo.oobblock) {
if (ioctl(fd, MEMWRITEOOB, &oob)) {
perror("ioctl(MEMWRITEOOB)");
More information about the linux-mtd-cvs
mailing list