All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Korsgaard <jacmet@sunsite.dk>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] tools/mkimage: use lseek rather than fstat for file size for -l option
Date: Wed, 03 Dec 2008 08:43:52 +0100	[thread overview]
Message-ID: <87ljuxzosn.fsf@macbook.be.48ers.dk> (raw)
In-Reply-To: <20081203002254.473EB834B020@gemini.denx.de> (Wolfgang Denk's message of "Wed\, 03 Dec 2008 01\:22\:54 +0100")

>>>>> "Wolfgang" == Wolfgang Denk <wd@denx.de> writes:

Hi,

 Wolfgang> Hm... but lseek() on /dev/mtdblockN will return the size of
 Wolfgang> the MTD device, not of the image that may be stored in it,
 Wolfgang> right?

Yes.

 Wolfgang> Later, you should get data checksum errors because of the
 Wolfgang> incorrect lenght, i.  e.  a ``ERROR: "<image>" has
 Wolfgang> corrupted data!'' error message.

Exactly, hence my other patch (tools/mkimage: ignore trailing garbage)
to only error out if the size is smaller than the size defined in the
header.

 Wolfgang> I don't think this works.

 >> -		if (fstat(ifd, &sbuf) < 0) {
 >> -			fprintf (stderr, "%s: Can't stat %s: %s\n",
 >> +		sbuf.st_size = lseek(ifd, 0, SEEK_END);
 >> +		if (sbuf.st_size == (off_t)-1) {
 >> +			fprintf (stderr, "%s: Can't get size of %s: %s\n",

 Wolfgang> If you don't use *stat(), you should not use any struct
 Wolfgang> stat type either.

Ok, I kept it like that to keep the patch as minimal as possible -
I'll change it and resend.

-- 
Bye, Peter Korsgaard

  reply	other threads:[~2008-12-03  7:43 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-01 16:23 [U-Boot] [PATCH] tools/mkimage: ignore trailing garbage Peter Korsgaard
2008-12-01 16:23 ` [U-Boot] [PATCH] tools/mkimage: use lseek rather than fstat for file size for -l option Peter Korsgaard
2008-12-02  7:48   ` Thomas De Schampheleire
2008-12-02 20:05     ` Peter Korsgaard
2008-12-03  0:22       ` Wolfgang Denk
2008-12-03  7:43         ` Peter Korsgaard [this message]
2008-12-03 11:54           ` Wolfgang Denk
2008-12-03 12:07             ` Peter Korsgaard

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=87ljuxzosn.fsf@macbook.be.48ers.dk \
    --to=jacmet@sunsite.dk \
    --cc=u-boot@lists.denx.de \
    /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.