* flash_eraseall reports incorrect percentage
@ 2008-01-30 13:03 Stefan Roese
2008-11-18 18:56 ` Ladislav Michl
0 siblings, 1 reply; 4+ messages in thread
From: Stefan Roese @ 2008-01-30 13:03 UTC (permalink / raw)
To: linux-mtd
It seems that the flash_eraseall utility doesn't report the correct percentage
upon completion. After erasing the last sector, the output seems not to get
updated anymore. This leads to something like this on a partition with only 2
sectors:
flash_eraseall /dev/mtd6
Erasing 256 Kibyte @ 40000 -- 50 % complete.
I'm just posting this report as a reference. Perhaps somebody has a little
time to fix it.
Thanks.
Best regards,
Stefan
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: flash_eraseall reports incorrect percentage
2008-01-30 13:03 flash_eraseall reports incorrect percentage Stefan Roese
@ 2008-11-18 18:56 ` Ladislav Michl
2008-11-21 9:51 ` Artem Bityutskiy
0 siblings, 1 reply; 4+ messages in thread
From: Ladislav Michl @ 2008-11-18 18:56 UTC (permalink / raw)
To: Stefan Roese; +Cc: linux-mtd
On Wed, Jan 30, 2008 at 02:03:13PM +0100, Stefan Roese wrote:
> It seems that the flash_eraseall utility doesn't report the correct percentage
> upon completion. After erasing the last sector, the output seems not to get
> updated anymore. This leads to something like this on a partition with only 2
> sectors:
>
> flash_eraseall /dev/mtd6
> Erasing 256 Kibyte @ 40000 -- 50 % complete.
>
> I'm just posting this report as a reference. Perhaps somebody has a little
> time to fix it.
Well, I sacrificed a little time otherwise used to prepare supper, but
fridge is emty...
# flash_eraseall /dev/mtd4
Erasing 128 Kibyte @ 2800000 -- 100 % complete.
flash_eraseall
* fix percentage reporting
* exit()ing from main() is overkill, just return
Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
diff --git a/flash_eraseall.c b/flash_eraseall.c
index 60036d3..a22fc49 100644
--- a/flash_eraseall.c
+++ b/flash_eraseall.c
@@ -49,6 +49,7 @@ static int quiet; /* true -- don't output progress */
static int jffs2; // format for jffs2 usage
static void process_options (int argc, char *argv[]);
+void show_progress (mtd_info_t *meminfo, erase_info_t *erase);
static void display_help (void);
static void display_version (void);
static struct jffs2_unknown_node cleanmarker;
@@ -63,16 +64,15 @@ int main (int argc, char *argv[])
process_options(argc, argv);
-
if ((fd = open(mtd_device, O_RDWR)) < 0) {
fprintf(stderr, "%s: %s: %s\n", exe_name, mtd_device, strerror(errno));
- exit(1);
+ return 1;
}
if (ioctl(fd, MEMGETINFO, &meminfo) != 0) {
fprintf(stderr, "%s: %s: unable to get MTD device info\n", exe_name, mtd_device);
- exit(1);
+ return 1;
}
erase.length = meminfo.erasesize;
@@ -88,7 +88,7 @@ int main (int argc, char *argv[])
if (ioctl(fd, MEMGETOOBSEL, &oobinfo) != 0) {
fprintf(stderr, "%s: %s: unable to get NAND oobinfo\n", exe_name, mtd_device);
- exit(1);
+ return 1;
}
/* Check for autoplacement */
@@ -96,7 +96,7 @@ int main (int argc, char *argv[])
/* Get the position of the free bytes */
if (!oobinfo.oobfree[0][1]) {
fprintf (stderr, " Eeep. Autoplacement selected and no empty space in oob\n");
- exit(1);
+ return 1;
}
clmpos = oobinfo.oobfree[0][0];
clmlen = oobinfo.oobfree[0][1];
@@ -137,23 +137,17 @@ int main (int argc, char *argv[])
bbtest = 0;
if (isNAND) {
fprintf(stderr, "%s: %s: Bad block check not available\n", exe_name, mtd_device);
- exit(1);
+ return 1;
}
} else {
fprintf(stderr, "\n%s: %s: MTD get bad block failed: %s\n", exe_name, mtd_device, strerror(errno));
- exit(1);
+ return 1;
}
}
}
- if (!quiet) {
- printf
- ("\rErasing %d Kibyte @ %x -- %2llu %% complete.",
- meminfo.erasesize / 1024, erase.start,
- (unsigned long long)
- erase.start * 100 / meminfo.size);
- }
- fflush(stdout);
+ if (!quiet)
+ show_progress(&meminfo, &erase);
if (ioctl(fd, MEMERASE, &erase) != 0) {
fprintf(stderr, "\n%s: %s: MTD Erase failure: %s\n", exe_name, mtd_device, strerror(errno));
@@ -187,8 +181,10 @@ int main (int argc, char *argv[])
if (!quiet)
printf (" Cleanmarker written at %x.", erase.start);
}
- if (!quiet)
+ if (!quiet) {
+ show_progress(&meminfo, &erase);
printf("\n");
+ }
return 0;
}
@@ -254,6 +250,13 @@ void process_options (int argc, char *argv[])
mtd_device = argv[optind];
}
+void show_progress (mtd_info_t *meminfo, erase_info_t *erase)
+{
+ printf("\rErasing %d Kibyte @ %x -- %2llu %% complete.",
+ meminfo->erasesize / 1024, erase->start,
+ (unsigned long long) erase->start * 100 / meminfo->size);
+ fflush(stdout);
+}
void display_help (void)
{
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: flash_eraseall reports incorrect percentage
2008-11-18 18:56 ` Ladislav Michl
@ 2008-11-21 9:51 ` Artem Bityutskiy
2008-11-21 11:22 ` Josh Boyer
0 siblings, 1 reply; 4+ messages in thread
From: Artem Bityutskiy @ 2008-11-21 9:51 UTC (permalink / raw)
To: Ladislav Michl; +Cc: Stefan Roese, linux-mtd
On Tue, 2008-11-18 at 19:56 +0100, Ladislav Michl wrote:
> On Wed, Jan 30, 2008 at 02:03:13PM +0100, Stefan Roese wrote:
> > It seems that the flash_eraseall utility doesn't report the correct percentage
> > upon completion. After erasing the last sector, the output seems not to get
> > updated anymore. This leads to something like this on a partition with only 2
> > sectors:
> >
> > flash_eraseall /dev/mtd6
> > Erasing 256 Kibyte @ 40000 -- 50 % complete.
> >
> > I'm just posting this report as a reference. Perhaps somebody has a little
> > time to fix it.
>
> Well, I sacrificed a little time otherwise used to prepare supper, but
> fridge is emty...
>
> # flash_eraseall /dev/mtd4
> Erasing 128 Kibyte @ 2800000 -- 100 % complete.
>
> flash_eraseall
> * fix percentage reporting
> * exit()ing from main() is overkill, just return
>
> Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
It seems others are busy, so I took a look at this. I think the patch is
OK, pushed to mtd-utils.git.
Thanks.
--
Best regards,
Artem Bityutskiy (Битюцкий Артём)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: flash_eraseall reports incorrect percentage
2008-11-21 9:51 ` Artem Bityutskiy
@ 2008-11-21 11:22 ` Josh Boyer
0 siblings, 0 replies; 4+ messages in thread
From: Josh Boyer @ 2008-11-21 11:22 UTC (permalink / raw)
To: dedekind; +Cc: Stefan Roese, Ladislav Michl, linux-mtd
On Fri, 21 Nov 2008 11:51:38 +0200
Artem Bityutskiy <dedekind@infradead.org> wrote:
> On Tue, 2008-11-18 at 19:56 +0100, Ladislav Michl wrote:
> > On Wed, Jan 30, 2008 at 02:03:13PM +0100, Stefan Roese wrote:
> > > It seems that the flash_eraseall utility doesn't report the correct percentage
> > > upon completion. After erasing the last sector, the output seems not to get
> > > updated anymore. This leads to something like this on a partition with only 2
> > > sectors:
> > >
> > > flash_eraseall /dev/mtd6
> > > Erasing 256 Kibyte @ 40000 -- 50 % complete.
> > >
> > > I'm just posting this report as a reference. Perhaps somebody has a little
> > > time to fix it.
> >
> > Well, I sacrificed a little time otherwise used to prepare supper, but
> > fridge is emty...
> >
> > # flash_eraseall /dev/mtd4
> > Erasing 128 Kibyte @ 2800000 -- 100 % complete.
> >
> > flash_eraseall
> > * fix percentage reporting
> > * exit()ing from main() is overkill, just return
> >
> > Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
>
>
> It seems others are busy, so I took a look at this. I think the patch is
> OK, pushed to mtd-utils.git.
Thanks. I was planning to do that this afternoon, but now I can stare
at some other patch instead :).
josh
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-11-21 11:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-30 13:03 flash_eraseall reports incorrect percentage Stefan Roese
2008-11-18 18:56 ` Ladislav Michl
2008-11-21 9:51 ` Artem Bityutskiy
2008-11-21 11:22 ` Josh Boyer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox