diff options
author | Rafał Miłecki <zajec5@gmail.com> | 2016-06-11 01:41:10 +0200 |
---|---|---|
committer | Rafał Miłecki <zajec5@gmail.com> | 2016-06-20 08:01:31 +0200 |
commit | 7e08f2ccbdb717c502810085457b824d0f2d067b (patch) | |
tree | b4722ba8a21c5f1cb98b491a7134cf055c2b7bfe | |
parent | cf6d9d97fbaa7d85b0f972bdc7ad710e96125fd2 (diff) | |
download | mtk-20170518-7e08f2ccbdb717c502810085457b824d0f2d067b.zip mtk-20170518-7e08f2ccbdb717c502810085457b824d0f2d067b.tar.gz mtk-20170518-7e08f2ccbdb717c502810085457b824d0f2d067b.tar.bz2 |
mtd: support -c (datasize) option for fixseama command
Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
-rw-r--r-- | package/system/mtd/src/mtd.c | 8 | ||||
-rw-r--r-- | package/system/mtd/src/mtd.h | 2 | ||||
-rw-r--r-- | package/system/mtd/src/seama.c | 6 |
3 files changed, 9 insertions, 7 deletions
diff --git a/package/system/mtd/src/mtd.c b/package/system/mtd/src/mtd.c index 284c879..8fbddf5 100644 --- a/package/system/mtd/src/mtd.c +++ b/package/system/mtd/src/mtd.c @@ -674,7 +674,7 @@ resume: break; case MTD_IMAGE_FORMAT_SEAMA: if (mtd_fixseama) - mtd_fixseama(mtd, 0); + mtd_fixseama(mtd, 0, 0); break; default: break; @@ -737,8 +737,10 @@ static void usage(void) if (mtd_fixtrx) { fprintf(stderr, " -o offset offset of the image header in the partition(for fixtrx)\n"); + } + if (mtd_fixtrx || mtd_fixseama) { fprintf(stderr, - " -c datasize amount of data to be used for checksum calculation (for fixtrx)\n"); + " -c datasize amount of data to be used for checksum calculation (for fixtrx / fixseama)\n"); } fprintf(stderr, #ifdef FIS_SUPPORT @@ -987,7 +989,7 @@ int main (int argc, char **argv) break; case CMD_FIXSEAMA: if (mtd_fixseama) - mtd_fixseama(device, 0); + mtd_fixseama(device, 0, data_size); break; } diff --git a/package/system/mtd/src/mtd.h b/package/system/mtd/src/mtd.h index 0a8b1ae..9b2e32f 100644 --- a/package/system/mtd/src/mtd.h +++ b/package/system/mtd/src/mtd.h @@ -26,6 +26,6 @@ extern void mtd_parse_jffs2data(const char *buf, const char *dir); extern int trx_fixup(int fd, const char *name) __attribute__ ((weak)); extern int trx_check(int imagefd, const char *mtd, char *buf, int *len) __attribute__ ((weak)); extern int mtd_fixtrx(const char *mtd, size_t offset, size_t data_size) __attribute__ ((weak)); -extern int mtd_fixseama(const char *mtd, size_t offset) __attribute__ ((weak)); +extern int mtd_fixseama(const char *mtd, size_t offset, size_t data_size) __attribute__ ((weak)); extern int mtd_resetbc(const char *mtd) __attribute__ ((weak)); #endif /* __mtd_h */ diff --git a/package/system/mtd/src/seama.c b/package/system/mtd/src/seama.c index f8b677b..bcda321 100644 --- a/package/system/mtd/src/seama.c +++ b/package/system/mtd/src/seama.c @@ -104,14 +104,13 @@ err_out: } int -mtd_fixseama(const char *mtd, size_t offset) +mtd_fixseama(const char *mtd, size_t offset, size_t data_size) { int fd; char *first_block; ssize_t res; size_t block_offset; size_t data_offset; - size_t data_size; struct seama_entity_header *shdr; if (quiet < 2) @@ -155,7 +154,8 @@ mtd_fixseama(const char *mtd, size_t offset) } data_offset = offset + sizeof(struct seama_entity_header) + ntohs(shdr->metasize); - data_size = mtdsize - data_offset; + if (!data_size) + data_size = mtdsize - data_offset; if (data_size > ntohl(shdr->size)) data_size = ntohl(shdr->size); if (seama_fix_md5(shdr, fd, data_offset, data_size)) |