From: Nahor <nahor.j+gmane@gmail.com>
To: linux-mtd@lists.infradead.org
Subject: Re: [PATCH 2/3] [MTD-UTILS] Use same kind of code for reading OOB than for regular data
Date: Tue, 09 Jun 2009 16:07:39 -0700 [thread overview]
Message-ID: <h0mpvs$8nk$1@ger.gmane.org> (raw)
In-Reply-To: <4A2E98BD.30704@orb.com>
Use the same code structure when reading the OOB than when reading the
regular data.
Signed-off-by: Jehan Bing <jehan@orb.com>
--- a/nandwrite.c 2009-06-09 13:20:56.000000000 -0700
+++ b/nandwrite.c 2009-06-09 13:20:44.000000000 -0700
@@ -520,17 +520,32 @@ int main(int argc, char * const argv[])
}
if (writeoob) {
- int tinycnt = 0;
+ {
+ int readlen = meminfo.oobsize;
- while(tinycnt < meminfo.oobsize) {
- cnt = read(ifd, oobreadbuf + tinycnt, meminfo.oobsize - tinycnt);
- if (cnt == 0) { // EOF
- break;
- } else if (cnt < 0) {
- perror ("File I/O error on input file");
+ int tinycnt = 0;
+
+ while (tinycnt < readlen) {
+ cnt = read(ifd, oobreadbuf + tinycnt, readlen - tinycnt);
+ if (cnt == 0) { // EOF
+ break;
+ } else if (cnt < 0) {
+ perror ("File I/O error on input");
+ goto closeall;
+ }
+ tinycnt += cnt;
+ }
+
+ if (tinycnt < readlen) {
+ fprintf(stderr, "Unexpected EOF. Expecting at least "
+ "%d more bytes for OOB\n", readlen - tinycnt);
goto closeall;
}
- tinycnt += cnt;
+
+ if ((ifd == STDIN_FILENO) && (cnt == 0)) {
+ /* No more bytes - we are done after writing the remaining bytes */
+ imglen = 0;
+ }
}
if (!noecc) {
next prev parent reply other threads:[~2009-06-09 23:08 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-08 22:32 [PATCH] [MTD-UTILS] Bad block handling in nandwrite when reading from standard input Jehan Bing
2009-06-09 12:53 ` Artem Bityutskiy
2009-06-09 17:15 ` Jehan Bing
2009-06-09 23:04 ` [PATCH 1/3] [MTD-UTILS] Unified reading from standard input and from file Jehan Bing
2009-06-10 16:03 ` Artem Bityutskiy
2009-06-10 16:05 ` Artem Bityutskiy
2009-06-10 17:23 ` Jamie Lokier
2009-06-10 17:11 ` Jehan Bing
2009-06-11 7:32 ` Artem Bityutskiy
2009-06-11 17:43 ` [PATCH 1/3 v2] " Jehan Bing
2009-06-12 5:30 ` Artem Bityutskiy
2009-06-09 23:07 ` Nahor [this message]
2009-06-09 23:19 ` [PATCH 3/3] [MTD-UTILS] Handle bad block when reading from standard input Jehan Bing
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='h0mpvs$8nk$1@ger.gmane.org' \
--to=nahor.j+gmane@gmail.com \
--cc=linux-mtd@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.