Enable 'saveenv' for non eraseable media

Sascha Hauer s.hauer at pengutronix.de
Thu Nov 19 03:43:14 EST 2009


On Wed, Nov 18, 2009 at 04:00:54PM +0100, Juergen Beisert wrote:
> 'close()' clobbers the 'errno' value from the erase command. So it must be done
> *after* the check for ENOSYS to ingnore it correctly.

Applied.

Sascha

> 
> Signed-off by: Juergen Beisert <j.beisert at pengutronix.de>
> 
> ---
>  commands/saveenv.c |    5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> Index: u-boot-v2/commands/saveenv.c
> ===================================================================
> --- u-boot-v2.orig/commands/saveenv.c
> +++ u-boot-v2/commands/saveenv.c
> @@ -62,14 +62,15 @@ static int do_saveenv(cmd_tbl_t *cmdtp, 
>  
>  	ret = erase(fd, ~0, 0);
>  
> -	close(fd);
> -
>  	/* ENOSYS is no error here, many devices do not need it */
>  	if (ret && errno != -ENOSYS) {
>  		printf("could not erase %s: %s\n", filename, errno_str());
> +		close(fd);
>  		return 1;
>  	}
>  
> +	close(fd);
> +
>  	ret = envfs_save(filename, dirname);
>  	if (ret) {
>  		printf("saveenv failed\n");
> 
> -- 
> Pengutronix e.K.                              | Juergen Beisert             |
> Linux Solutions for Science and Industry      | Phone: +49-8766-939 228     |
> Vertretung Sued/Muenchen, Germany             | Fax:   +49-5121-206917-5555 |
> Amtsgericht Hildesheim, HRA 2686              | http://www.pengutronix.de/  |
> 
> _______________________________________________
> u-boot-v2 mailing list
> u-boot-v2 at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/u-boot-v2
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |




More information about the barebox mailing list