[U-Boot] [PATCH] Don't try to stat() a colon separated list of files in multi or script mode
Simon Glass
sjg at chromium.org
Thu Dec 3 23:03:49 CET 2015
Hi,
On 3 December 2015 at 14:55, Nye Liu <nyet at nyet.org> wrote:
>
> On 11/19/2015 6:15 AM, Simon Glass wrote:
>> Hi,
>>
>> On 18 November 2015 at 17:37, Nye Liu <nyet at nyet.org> wrote:
>>> ---
>>> tools/mkimage.c | 32 +++++++++++++++++++-------------
>>> 1 file changed, 19 insertions(+), 13 deletions(-)
>>>
>>
>> Can you please add a commit message explaining the problem, and what
>> you are trying to do here?
>>
>>> diff --git a/tools/mkimage.c b/tools/mkimage.c
>>> index 8af9d50..aa739b4 100644
>>> --- a/tools/mkimage.c
>>> +++ b/tools/mkimage.c
>>> @@ -311,21 +311,27 @@ NXTARG: ;
>>> exit (retval);
>>> }
>>>
>>> - dfd = open(params.datafile, O_RDONLY | O_BINARY);
>>> - if (dfd < 0) {
>>> - fprintf(stderr, "%s: Can't open %s: %s\n",
>>> - params.cmdname, params.datafile, strerror(errno));
>>> - exit(EXIT_FAILURE);
>>> - }
>>> + if (params.skipcpy ||
>>> + !(params.type == IH_TYPE_MULTI ||
>>> + params.type == IH_TYPE_SCRIPT)) {
>>> + dfd = open(params.datafile, O_RDONLY | O_BINARY);
>>> + if (dfd < 0) {
>>> + fprintf(stderr, "%s: Can't open %s: %s\n",
>>> + params.cmdname, params.datafile,
>>> + strerror(errno));
>>> + exit(EXIT_FAILURE);
>>> + }
>>>
>>> - if (fstat(dfd, &sbuf) < 0) {
>>> - fprintf(stderr, "%s: Can't stat %s: %s\n",
>>> - params.cmdname, params.datafile, strerror(errno));
>>> - exit(EXIT_FAILURE);
>>> - }
>>> + if (fstat(dfd, &sbuf) < 0) {
>>> + fprintf(stderr, "%s: Can't stat %s: %s\n",
>>> + params.cmdname, params.datafile,
>>> + strerror(errno));
>>> + exit(EXIT_FAILURE);
>>> + }
>>>
>>> - params.file_size = sbuf.st_size + tparams->header_size;
>>> - close(dfd);
>>> + params.file_size = sbuf.st_size + tparams->header_size;
>>> + close(dfd);
>>> + }
>>>
>>> /*
>>> * In case there an header with a variable
>>> --
>>> 2.6.2
>
> Meaning, you don't know what it does, or you won't accept the patch w/o it?
>
> In short,
>
> "mkimage -T multi -d file1:file2:file3"
>
> no longer works.
>
> It stats the file "file1:file2:file3" (and fails) before opening each
> file separately.
>
Yes, please put this explanation in version 2 of your patch.
Regards,
Simon
More information about the U-Boot
mailing list