public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* mtd-utils: ubiformat: writing images on flash with badblocks.
@ 2011-08-25  8:26 Anton Olofsson
  2011-09-11 10:59 ` Artem Bityutskiy
  0 siblings, 1 reply; 7+ messages in thread
From: Anton Olofsson @ 2011-08-25  8:26 UTC (permalink / raw)
  To: linux-mtd

Hi!

We encountered some problems with ubiformat
and writing ubi-images onto flash with badblocks.

If a badblock was encountered during write ubiformat would
skip writing that “file-block” altogether, and this would eventually
result in EOF while trying to read the image file.

The quick fix was to rewind the filedescriptor for the next pass.

Im not sure if others have encountered this problem
or even if this is the correct way to handle this situation.

Here is the change made though:

--- a/ubi-utils/ubiformat.c
+++ b/ubi-utils/ubiformat.c
@@ -546,6 +546,11 @@ static int flash_image(libmtd_t libmtd, const
struct mtd_dev_info *mtd,
                                if (mark_bad(mtd, si, eb))
                                        goto out_close;
                        }
+                       /*rewind fd so next read_all(...) reads correct block*/
+                       if (lseek(fd, -mtd->eb_size, SEEK_CUR) == -1) {
+                               sys_errmsg("unable to rewind file");
+                               goto out_close;
+                       }
                        continue;
                }
                if (++written_ebs >= img_ebs)

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-09-19  4:51 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-25  8:26 mtd-utils: ubiformat: writing images on flash with badblocks Anton Olofsson
2011-09-11 10:59 ` Artem Bityutskiy
2011-09-12  6:41   ` Ricard Wanderlof
2011-09-12  9:33     ` Artem Bityutskiy
2011-09-12  9:40       ` Ricard Wanderlof
2011-09-13  9:33   ` Anton Olofsson
2011-09-19  4:53     ` Artem Bityutskiy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox