[PATCH 2/3] envfs: add command_abi_version support

Jean-Christophe PLAGNIOL-VILLARD plagnioj at jcrosoft.com
Tue Oct 23 06:20:59 EDT 2012


On 10:59 Tue 23 Oct     , Sascha Hauer wrote:
> On Mon, Oct 22, 2012 at 06:07:27PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > allow to store the command abi version
> > This will allow to detect incompatibility
> > 
> > Increase envfs minor to 1
> > 
> > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
> > ---
> >  commands/loadenv.c    |   11 ++++++++++-
> >  common/environment.c  |    7 ++++++-
> >  common/startup.c      |    4 ++--
> >  include/envfs.h       |    4 ++--
> >  include/environment.h |   13 ++++++++++++-
> >  scripts/bareboxenv.c  |    9 ++++++++-
> >  6 files changed, 40 insertions(+), 8 deletions(-)
> > 
> > diff --git a/commands/loadenv.c b/commands/loadenv.c
> > index 5bf1740..c52ee4b 100644
> > --- a/commands/loadenv.c
> > +++ b/commands/loadenv.c
> > @@ -26,6 +26,9 @@
> >  
> >  static int do_loadenv(int argc, char *argv[])
> >  {
> > +	int ret;
> > +	uint16_t command_abi_version;
> > +
> >  	char *filename, *dirname;
> >  
> >  	if (argc < 3)
> > @@ -37,7 +40,13 @@ static int do_loadenv(int argc, char *argv[])
> >  	else
> >  		filename = argv[1];
> >  	printf("loading environment from %s\n", filename);
> > -	return envfs_load(filename, dirname);
> > +	ret = envfs_load(filename, dirname, &command_abi_version);
> > +
> > +	if (command_abi_version < COMMAND_ABI_VERSION)
> 
> '!=' instead of '<'? The incompatibility is often in both directions.
> 
> We may have to introduce min/max, I'm not sure on that.
no if your env is compatible with more recent but back compatible too

as you do this with the example of mount update I did recently

if [ $command_abi_version -lt 1 ]
then
	mount /dev/disk0.0 fat /mnt
else
	mount /dev/disk0.0 /mnt
fi
> 
> 
> > -int envfs_load(char *filename, char *dir)
> > +int envfs_load(char *filename, char *dir, uint16_t *command_abi_version)
> >  {
> >  	struct envfs_super super;
> >  	void *buf = NULL, *buf_free = NULL;
> > @@ -235,6 +236,7 @@ int envfs_load(char *filename, char *dir)
> >  		goto out;
> >  	}
> >  
> > +
> >  	if ( ENVFS_32(super.magic) != ENVFS_MAGIC) {
> >  		printf("envfs: wrong magic on %s\n", filename);
> >  		ret = -EIO;
> 
> Drop this hunk.
> 
> > diff --git a/scripts/bareboxenv.c b/scripts/bareboxenv.c
> > index f44a1f8..6bd23e8 100644
> > --- a/scripts/bareboxenv.c
> > +++ b/scripts/bareboxenv.c
> > @@ -115,6 +115,7 @@ char *concat_subpath_file(const char *path, const char *f)
> >  }
> >  
> >  #include "../lib/recursive_action.c"
> > +#include "../include/command_abi.h"
> >  #include "../include/envfs.h"
> >  #include "../crypto/crc32.c"
> >  #include "../lib/make_directory.c"
> > @@ -189,14 +190,20 @@ int main(int argc, char *argv[])
> >  	}
> >  
> >  	if (load) {
> > +		uint16_t command_abi_version;
> > +
> >  		if (verbose)
> >  			printf("loading env from file %s to %s\n", filename, dirname);
> > -		envfs_load(filename, dirname);
> > +		envfs_load(filename, dirname, &command_abi_version);
> > +		if (verbose)
> > +			printf("with command_abi_version = %u\n", command_abi_version);
> >  	}
> >  	if (save) {
> >  		if (verbose)
> >  			printf("saving contents of %s to file %s\n", dirname, filename);
> >  		envfs_save(filename, dirname);
> > +		if (verbose)
> > +			printf("with command_abi_version = %u\n", COMMAND_ABI_VERSION);
> >  	}
> 
> For testing purposes or for generating an environment for another
> barebox version it would be useful to be able to specify the ABI version
> from the command line.
yeah I was thinking of it too

as I was thinking to genereate an env compatible with multiple version
as we have the way to detect it

Best Regards,
J.
> 
> Sascha
> 
> -- 
> 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