summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Zongker <dougz@android.com>2010-09-15 21:32:22 +0200
committerAndroid Git Automerger <android-git-automerger@android.com>2010-09-15 21:32:22 +0200
commit4f69afdb631a2480d466505635cde3a1d61e3610 (patch)
tree9e6da8749a7451e451e16af95d10f73ce61fa20d
parentam f94a3575: am 61ba7a83: stop treating all-zero blocks as bad (diff)
parentam d12560aa: add the ability to seek to a raw location while reading MTD partition (diff)
downloadandroid_bootable_recovery-4f69afdb631a2480d466505635cde3a1d61e3610.tar
android_bootable_recovery-4f69afdb631a2480d466505635cde3a1d61e3610.tar.gz
android_bootable_recovery-4f69afdb631a2480d466505635cde3a1d61e3610.tar.bz2
android_bootable_recovery-4f69afdb631a2480d466505635cde3a1d61e3610.tar.lz
android_bootable_recovery-4f69afdb631a2480d466505635cde3a1d61e3610.tar.xz
android_bootable_recovery-4f69afdb631a2480d466505635cde3a1d61e3610.tar.zst
android_bootable_recovery-4f69afdb631a2480d466505635cde3a1d61e3610.zip
-rw-r--r--mtdutils/mtdutils.c7
-rw-r--r--mtdutils/mtdutils.h1
2 files changed, 8 insertions, 0 deletions
diff --git a/mtdutils/mtdutils.c b/mtdutils/mtdutils.c
index c913a1945..d16f44ef8 100644
--- a/mtdutils/mtdutils.c
+++ b/mtdutils/mtdutils.c
@@ -279,6 +279,12 @@ MtdReadContext *mtd_read_partition(const MtdPartition *partition)
return ctx;
}
+// Seeks to a location in the partition. Don't mix with reads of
+// anything other than whole blocks; unpredictable things will result.
+void mtd_read_skip_to(const MtdReadContext* ctx, size_t offset) {
+ lseek64(ctx->fd, offset, SEEK_SET);
+}
+
static int read_block(const MtdPartition *partition, int fd, char *data)
{
struct mtd_ecc_stats before, after;
@@ -449,6 +455,7 @@ static int write_block(MtdWriteContext *ctx, const char *data)
if (retry > 0) {
fprintf(stderr, "mtd: wrote block after %d retries\n", retry);
}
+ fprintf(stderr, "mtd: successfully wrote block at %x\n", pos);
return 0; // Success!
}
diff --git a/mtdutils/mtdutils.h b/mtdutils/mtdutils.h
index 528a5bbe8..45d3ebc91 100644
--- a/mtdutils/mtdutils.h
+++ b/mtdutils/mtdutils.h
@@ -45,6 +45,7 @@ typedef struct MtdWriteContext MtdWriteContext;
MtdReadContext *mtd_read_partition(const MtdPartition *);
ssize_t mtd_read_data(MtdReadContext *, char *data, size_t data_len);
void mtd_read_close(MtdReadContext *);
+void mtd_read_skip_to(const MtdReadContext *, size_t offset);
MtdWriteContext *mtd_write_partition(const MtdPartition *);
ssize_t mtd_write_data(MtdWriteContext *, const char *data, size_t data_len);