mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] commands: crc: support setting environment variables
@ 2015-01-29 15:43 Michael Grzeschik
  2015-01-30  7:56 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Michael Grzeschik @ 2015-01-29 15:43 UTC (permalink / raw)
  To: barebox

From: Jan Luebbe <jlu@pengutronix.de>

Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
---
 commands/crc.c | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/commands/crc.c b/commands/crc.c
index 9b6a3e2..58b750e 100644
--- a/commands/crc.c
+++ b/commands/crc.c
@@ -46,9 +46,10 @@ static int do_crc(int argc, char *argv[])
 #ifdef CONFIG_CMD_CRC_CMP
 	char *vfilename = NULL;
 #endif
+	char *crcvarname = NULL, *sizevarname = NULL;
 	int opt, err = 0, filegiven = 0, verify = 0;
 
-	while((opt = getopt(argc, argv, "f:F:v:V:")) > 0) {
+	while((opt = getopt(argc, argv, "f:F:v:V:r:s:")) > 0) {
 		switch(opt) {
 		case 'f':
 			filename = optarg;
@@ -60,6 +61,12 @@ static int do_crc(int argc, char *argv[])
 			vfilename = optarg;
 			break;
 #endif
+		case 'r':
+			crcvarname = optarg;
+			break;
+		case 's':
+			sizevarname = optarg;
+			break;
 		case 'v':
 			verify = 1;
 			vcrc = simple_strtoul(optarg, NULL, 0);
@@ -89,6 +96,18 @@ static int do_crc(int argc, char *argv[])
 	printf("CRC32 for %s 0x%08lx ... 0x%08lx ==> 0x%08lx",
 			filename, (ulong)start, (ulong)start + total - 1, crc);
 
+	if (crcvarname) {
+		char *crcstr = asprintf("0x%lx", crc);
+		setenv(crcvarname, crcstr);
+		kfree(crcstr);
+	}
+
+	if (sizevarname) {
+		char *sizestr = asprintf("0x%lx", total);
+		setenv(sizevarname, sizestr);
+		kfree(sizestr);
+	}
+
 #ifdef CONFIG_CMD_CRC_CMP
 	if (vfilename) {
 		size = total;
@@ -118,6 +137,8 @@ BAREBOX_CMD_HELP_OPT ("-F FILE", "Use file to compare.")
 #endif
 BAREBOX_CMD_HELP_OPT ("-v CRC",  "Verify")
 BAREBOX_CMD_HELP_OPT ("-V FILE", "Verify with CRC read from FILE")
+BAREBOX_CMD_HELP_OPT  ("-r <var>",  "Set <var> to the checksum result\n")
+BAREBOX_CMD_HELP_OPT  ("-s <var>",  "Set <var> to the data size\n")
 BAREBOX_CMD_HELP_END
 
 BAREBOX_CMD_START(crc32)
-- 
2.1.4


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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] commands: crc: support setting environment variables
  2015-01-29 15:43 [PATCH] commands: crc: support setting environment variables Michael Grzeschik
@ 2015-01-30  7:56 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2015-01-30  7:56 UTC (permalink / raw)
  To: Michael Grzeschik; +Cc: barebox

On Thu, Jan 29, 2015 at 04:43:48PM +0100, Michael Grzeschik wrote:
> From: Jan Luebbe <jlu@pengutronix.de>
> 
> Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
> ---
>  commands/crc.c | 23 ++++++++++++++++++++++-
>  1 file changed, 22 insertions(+), 1 deletion(-)

Applied, thanks

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-01-30  7:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-29 15:43 [PATCH] commands: crc: support setting environment variables Michael Grzeschik
2015-01-30  7:56 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox