[U-Boot] fatls returncode
Mirza Krak
mirza.krak at hostmobility.com
Mon Apr 3 06:14:29 UTC 2017
2017-03-27 10:51 GMT+02:00 Wolfgang Denk <wd at denx.de>:
> Dear Mirza,
>
> In message <CAJ=nTstVijhpwMh9HfCbnzBzRz4GA9aujq=4oSWAkYCUs1+pOA at mail.gmail.com> you wrote:
>>
>> > Please update to a recent versionof the code. The return code
>> > handling has probably been fixed by this commit:
>> >
>> > 0a04ed8 2015-09-11 17:15:21 -0400 FIX: fat: Provide correct return co=
>> de from disk_{read|write} to upper layers
>>
>> I did an update (cherry-picked FAT related commits from upstream), but
>> I still get the same result.
>
> I see.
>
>> Analyzing the code in fs/fat/fat.c:do_fat_read_at (which is called by
>> the fatls command) one can see that "ret" is set in three locations.
>> In my case I never reach any of these three, since my exit path is:
>>
>> fs/fat/fat.c:
>>
>> 1139 /* If end of rootdir reached */
>> 1140 if (rootdir_end) {
>> 1141 if (dols == LS_ROOT) {
>> 1142 printf("\n%d file(s), %d dir(s)\n\n",
>> 1143 files, dirs);
>> 1144 *size = 0;
>> 1145 }
>> 1146 goto exit;
>> 1147 }
>
> OK... Understood.
>
>> So either this exit path is actually an error and it is correct as-is,
>> or this path should set "ret = 0". My knowledge of FAT is limited so I
>> can not really tell which it should be but there is no indications in
>> the code/comments that this exit path is an error.
>
> I think the exit is OK, as we have reached the end of the root
> directory, but it should set "ret = 0;" before the goto.
>
> But then, I am not an expert on this code either, so I added Sergei
> Shtylyov on cc: who added this line with
>
> commit ac4977719e157bcb3c45c70d9dd781164727530d
> Author: Sergei Shtylyov <sshtylyov at ru.mvista.com>
> Date: Mon Aug 8 09:38:33 2011 +0000
>
> fat: fix crash with big sector size
>
>
> Sergei, do you agree that ret = 0 should be set before the "goto
> exit" here?
I also found the commit that removed the "ret = 0" since it did indeed
exist earlier.
1ad0b98a067a ("fat: Prepare API change for files greater than 2GB")
Added author on CC.
That commit also removed another occurrence of "ret = 0" which I
question if that was correct as well.
--
Med Vänliga Hälsningar / Best Regards
*******************************************************************
Mirza Krak
Host Mobility AB
mirza.krak at hostmobility.com
Anders Personsgatan 12, 416 64 Göteborg
Sweden
http://www.hostmobility.com
Direct: +46 31 31 32 704
Phone: +46 31 31 32 700
Fax: +46 31 80 67 51
Mobile: +46 730 28 06 22
*******************************************************************
More information about the U-Boot
mailing list