[U-Boot] [PATCH V2 2/5] fs: implement infra-structure for an 'exists' function

Stephen Warren swarren at wwwdotorg.org
Mon Jan 27 18:03:04 CET 2014


On 01/26/2014 08:41 AM, Simon Glass wrote:
> Hi Stephen,
> 
> On 23 January 2014 12:56, Stephen Warren <swarren at wwwdotorg.org
> <mailto:swarren at wwwdotorg.org>> wrote:
> 
>     From: Stephen Warren <swarren at nvidia.com <mailto:swarren at nvidia.com>>
> 
>     This could be used in scripts such as:
> 
>     if exists mmc 0:1 /boot/boot.scr; then
>         load mmc 0:1 ${scriptaddr} /boot/boot.scr
>         source ${scriptaddr}
>     fi
...
> Acked-by: Simon Glass <sjg at chromium.org <mailto:sjg at chromium.org>>
> 
> Seems useful.
> 
> In addition, if it is just the error messages you are worried about (and
> I agree they should be eliminated) I wonder if we should consider adding
> a -e flag (or similar) to the read command to make it silently fail when
> the file does not exist? Arguably your code fragment above could be:
> 
> if load -e mmc 0:1 ${scriptaddr} /boot/boot.scr; then
>     source ${scriptaddr}
> fi

That would certainly work, although I think a direct check of
file-existence is more in line with how a regular Unix shell script
would work (test -e). I could imagine wanting to test for the existence
of a file without caring about its contents (e.g. using a file as a flag
to trigger a firmware upgrade or something)


More information about the U-Boot mailing list