mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
To: barebox@lists.infradead.org
Cc: Lior Amsalem <alior@marvell.com>,
	Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
Subject: [PATCHv2 02/10] scripts/kwbimage: add a few sanity checks
Date: Wed, 15 May 2013 09:36:28 +0200	[thread overview]
Message-ID: <1368603396-27887-3-git-send-email-thomas.petazzoni@free-electrons.com> (raw)
In-Reply-To: <1368603396-27887-1-git-send-email-thomas.petazzoni@free-electrons.com>

This commit uses the newly introduced image_count_options() function
to:

 - See if there is any DATA option that require the creation of an
   extended header for v0 header.

 - Verify that no more than one payload has been provided when
   creating a v0 header.

 - Verify that no more than one binary payload has been provided when
   creating a v1 header. Technically speaking, it is possible to
   support several payloads, but in real life, only one gets used, so
   we will only support that to make the code simpler for now. It can
   always be extended later on if needed.

 - Verify that no more than one payload has been provided when
   creating a v1 header.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
 scripts/kwbimage.c |   18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/scripts/kwbimage.c b/scripts/kwbimage.c
index 0d5dcac..cca20ab 100644
--- a/scripts/kwbimage.c
+++ b/scripts/kwbimage.c
@@ -712,12 +712,16 @@ static void *image_create_v0(struct image_cfg_element *image_cfg,
 	headersz  = sizeof(struct main_hdr_v0);
 	payloadsz = 0;
 
-	e = image_find_option(image_cfg, cfgn, IMAGE_CFG_DATA);
-	if (e) {
+	if (image_count_options(image_cfg, cfgn, IMAGE_CFG_DATA) > 0) {
 		has_ext = 1;
 		headersz += sizeof(struct ext_hdr_v0);
 	}
 
+	if (image_count_options(image_cfg, cfgn, IMAGE_CFG_PAYLOAD) > 1) {
+		fprintf(stderr, "More than one payload, not possible\n");
+		return NULL;
+	}
+
 	payloade = image_find_option(image_cfg, cfgn, IMAGE_CFG_PAYLOAD);
 	if (payloade) {
 		struct stat s;
@@ -818,6 +822,16 @@ static void *image_create_v1(struct image_cfg_element *image_cfg,
 	headersz = sizeof(struct main_hdr_v1);
 	payloadsz = 0;
 
+	if (image_count_options(image_cfg, cfgn, IMAGE_CFG_BINARY) > 1) {
+		fprintf(stderr, "More than one binary blob, not supported\n");
+		return NULL;
+	}
+
+	if (image_count_options(image_cfg, cfgn, IMAGE_CFG_PAYLOAD) > 1) {
+		fprintf(stderr, "More than one payload, not possible\n");
+		return NULL;
+	}
+
 	e = image_find_option(image_cfg, cfgn, IMAGE_CFG_BINARY);
 	if (e) {
 		struct stat s;
-- 
1.7.9.5


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

  parent reply	other threads:[~2013-05-15  7:36 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-15  7:36 [PATCHv2 00/10] kwbimage improvements, Kirkwood support Thomas Petazzoni
2013-05-15  7:36 ` [PATCHv2 01/10] scripts/kwbimage: add a new function image_count_options() Thomas Petazzoni
2013-05-15  7:36 ` Thomas Petazzoni [this message]
2013-05-15  7:36 ` [PATCHv2 03/10] scripts/kwbimage: make the v0 image creation more flexible Thomas Petazzoni
2013-05-15  7:36 ` [PATCHv2 04/10] scripts/kwbimage: simplify the v1 image creation Thomas Petazzoni
2013-05-15  7:36 ` [PATCHv2 05/10] scripts/kwbimage: make image_boot_mode_id() return -1 on failure Thomas Petazzoni
2013-05-15  7:36 ` [PATCHv2 06/10] scripts/kwbimage: add support for NAND ECC and page size header fields Thomas Petazzoni
2013-05-15  7:36 ` [PATCHv2 07/10] arm: mvebu: add Feroceon CPU type Thomas Petazzoni
2013-05-15  7:36 ` [PATCHv2 08/10] arm: mvebu: initial support for Marvell Kirkwood SoCs Thomas Petazzoni
2013-05-15  7:36 ` [PATCHv2 09/10] arm: mvebu: add basic support for Globalscale Guruplug board Thomas Petazzoni
2013-05-15  7:36 ` [PATCHv2 10/10] arm: mvebu: remove useless lines in kwbimage.cfg for CuBox Thomas Petazzoni
2013-05-15 20:07 ` [PATCHv2 00/10] kwbimage improvements, Kirkwood support Sebastian Hesselbarth
2013-05-17  5:41   ` Sascha Hauer

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=1368603396-27887-3-git-send-email-thomas.petazzoni@free-electrons.com \
    --to=thomas.petazzoni@free-electrons.com \
    --cc=alior@marvell.com \
    --cc=barebox@lists.infradead.org \
    --cc=ezequiel.garcia@free-electrons.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