mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 2/3] envfs: add command_abi_version support
Date: Tue, 23 Oct 2012 10:59:06 +0200	[thread overview]
Message-ID: <20121023085906.GR27665@pengutronix.de> (raw)
In-Reply-To: <1350922048-25699-2-git-send-email-plagnioj@jcrosoft.com>

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@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.


> -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.

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 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2012-10-23  8:59 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-22 16:03 [PATCH 0/3] introduce command abi version Jean-Christophe PLAGNIOL-VILLARD
2012-10-22 16:07 ` [PATCH 1/3] command: introduce " Jean-Christophe PLAGNIOL-VILLARD
2012-10-22 16:07   ` [PATCH 2/3] envfs: add command_abi_version support Jean-Christophe PLAGNIOL-VILLARD
2012-10-23  8:59     ` Sascha Hauer [this message]
2012-10-23 10:20       ` Jean-Christophe PLAGNIOL-VILLARD
2012-10-23 12:56         ` Sascha Hauer
2012-10-23 13:27           ` Jean-Christophe PLAGNIOL-VILLARD
2012-10-22 16:07   ` [PATCH 3/3] environment: detect command_abi_version Jean-Christophe PLAGNIOL-VILLARD
2012-10-29  8:50   ` [PATCH 1/3] command: introduce abi version Sascha Hauer
2012-10-29  9:56     ` Johannes Stezenbach
2012-10-29 10:31       ` Sascha Hauer
2012-10-29 16:05       ` Jean-Christophe PLAGNIOL-VILLARD
2012-10-29 17:00         ` Johannes Stezenbach
2012-10-29 18:05           ` Jean-Christophe PLAGNIOL-VILLARD
2012-10-23  8:51 ` [PATCH 0/3] introduce command " Sascha Hauer
2012-10-23 10:28   ` Jean-Christophe PLAGNIOL-VILLARD

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20121023085906.GR27665@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=plagnioj@jcrosoft.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox