[U-Boot] [PATCH 1/1]: filesystems : add "file exists" cmd

Tom Rini trini at konsulko.com
Sat Oct 8 19:48:53 CEST 2016


On Wed, Oct 05, 2016 at 12:38:01PM -0700, Sergey Kubushyn wrote:

> This adds "file exists" commands to generic FS as well as to FAT, EXT4,
> and UBIFS. Also adds "file size" command to UBIFS.
> 
> The return value for "file exists" commands is REVERSED i.e. they
> return 1 if file exists and 0 otherwise. This is a deliberate decision
> because those commands are supposed to be used almost exclusively in
> scripts and TRUE value is _not_ zero while FALSE is zero.
> 
> As of now the only way to check for a file existence is to attempt a
> read on that file (aka load.) That works but it makes an unnecessary
> read, overwrites memory at destination address if file not a zero
> length one, and outputs unnecessary messages to the console in any
> case.
> 
> Checking file existence in scripts is a valuable feature that allows
> the higher level software (e.g. Linux) to interact with U-Boot by
> creating some semaphore files and rebooting. We do use it quite
> extensively for system setup at manufacturing time and for other
> purposes (e.g. our Android "recovery" is implemented this way.)
> 
> Signed-off-by: Sergey Kubushyn <ksi at koi8.net>

Can you please do this in at least two patches?  file size to ubi should
be its own patch.  Also:

> +int do_ext4_file_exists(cmd_tbl_t *cmdtp, int flag, int argc,
> +						char *const argv[])
> +{
> +	int ret;
> +
> +	ret = do_file_exists(cmdtp, flag, argc, argv, FS_TYPE_EXT);
> + +	if (ret == 0) return 1;
> +	if (ret == 1) return 0;
> +	return ret;
> +}

I can only assume this hasn't been compile tested in a while, and you
should simplify the code into a single if/else and a comment on what we
want/mean.  Thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20161008/7a8ac7db/attachment.sig>


More information about the U-Boot mailing list