From 898b17afb2611359467b1585578758cb633c4b9a Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Mon, 21 Apr 2008 19:13:58 +0300 Subject: ubi-utils: fix percent output in ubiformat Signed-off-by: Artem Bityutskiy --- ubi-utils/new-utils/src/ubiformat.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'ubi-utils/new-utils/src/ubiformat.c') diff --git a/ubi-utils/new-utils/src/ubiformat.c b/ubi-utils/new-utils/src/ubiformat.c index 98f2d5f..dfae415 100644 --- a/ubi-utils/new-utils/src/ubiformat.c +++ b/ubi-utils/new-utils/src/ubiformat.c @@ -296,7 +296,7 @@ static int drop_ffs(const struct mtd_info *mtd, const void *buf, int len) static int flash_image(const struct mtd_info *mtd, const struct ubigen_info *ui, struct ubi_scan_info *si) { - int fd, img_ebs, eb, written_ebs = 0; + int fd, img_ebs, eb, written_ebs = 0, divisor; struct stat st; if (stat(args.image, &st)) @@ -316,6 +316,7 @@ static int flash_image(const struct mtd_info *mtd, const struct ubigen_info *ui, return sys_errmsg("cannot open \"%s\"", args.image); verbose(args.verbose, "will write %d eraseblocks", img_ebs); + divisor = img_ebs; for (eb = 0; eb < mtd->eb_cnt; eb++) { int err, new_len; char buf[mtd->eb_size]; @@ -323,12 +324,14 @@ static int flash_image(const struct mtd_info *mtd, const struct ubigen_info *ui, if (!args.quiet && !args.verbose) { printf("\r" PROGRAM_NAME ": flashing eraseblock %d -- %2lld %% complete ", - eb, (long long)(eb + 1) * 100 / img_ebs); + eb, (long long)(eb + 1) * 100 / divisor); fflush(stdout); } - if (si->ec[eb] == EB_BAD) + if (si->ec[eb] == EB_BAD) { + divisor += 1; continue; + } if (args.verbose) { normsg_cont("eraseblock %d: erase", eb); -- cgit v1.2.3