aboutsummaryrefslogtreecommitdiffstats
path: root/mtdutils
diff options
context:
space:
mode:
authorDoug Zongker <dougz@android.com>2010-09-09 16:41:49 -0700
committerDoug Zongker <dougz@android.com>2010-09-09 16:54:35 -0700
commitaaf3f56c44c37dca4ef9cc9efde68727ca26105f (patch)
tree98348aa7f7a18d4914aeb193e5b2b9d7982677cb /mtdutils
parent4bc980626c1cf6f1ea7d36e4b54e0023c896c9de (diff)
downloadbootable_recovery-aaf3f56c44c37dca4ef9cc9efde68727ca26105f.zip
bootable_recovery-aaf3f56c44c37dca4ef9cc9efde68727ca26105f.tar.gz
bootable_recovery-aaf3f56c44c37dca4ef9cc9efde68727ca26105f.tar.bz2
block is bad if ioctl() returns nonzero
Change-Id: I6fc4ce796bc663d05035927c0af0ce7ab6d07218
Diffstat (limited to 'mtdutils')
-rw-r--r--mtdutils/mtdutils.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/mtdutils/mtdutils.c b/mtdutils/mtdutils.c
index 18e6a5d..3e354e3 100644
--- a/mtdutils/mtdutils.c
+++ b/mtdutils/mtdutils.c
@@ -414,9 +414,12 @@ static int write_block(MtdWriteContext *ctx, const char *data)
ssize_t size = partition->erase_size;
while (pos + size <= (int) partition->size) {
loff_t bpos = pos;
- if (ioctl(fd, MEMGETBADBLOCK, &bpos) > 0) {
+ int ret = ioctl(fd, MEMGETBADBLOCK, &bpos);
+ if (ret != 0 && !(ret == -1 && errno == EOPNOTSUPP)) {
add_bad_block_offset(ctx, pos);
- fprintf(stderr, "mtd: not writing bad block at 0x%08lx\n", pos);
+ fprintf(stderr,
+ "mtd: not writing bad block at 0x%08lx (ret %d errno %d)\n",
+ pos, ret, errno);
pos += partition->erase_size;
continue; // Don't try to erase known factory-bad blocks.
}