From d12560aa2134d3af21a1220cd4873553f9c51743 Mon Sep 17 00:00:00 2001 From: Doug Zongker Date: Tue, 14 Sep 2010 14:25:48 -0700 Subject: add the ability to seek to a raw location while reading MTD partition Change-Id: Id1563ca667c50e61cf1bb15d2cf783a50937eece --- mtdutils/mtdutils.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'mtdutils/mtdutils.c') diff --git a/mtdutils/mtdutils.c b/mtdutils/mtdutils.c index c913a19..d16f44e 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! } -- cgit v1.1