Skip to contentSkip to conversation

Add unlzma command

PATCH New Joe Hershberger 3 participants 5 messages Aug 17, 2012 – Sep 18, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 Add unlzma command

Provide access to the lzma decompressor from the command line.

---
 common/Makefile     |  3 +++
 common/cmd_unlzma.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 72 insertions(+)
 create mode 100644 common/cmd_unlzma.c
common/Makefile +3 -0
index 3d62775..b8568ba 100644
@@ -153,6 +153,9 @@ COBJS-$(CONFIG_CMD_TSI148) += cmd_tsi148.o
 COBJS-$(CONFIG_CMD_UBI) += cmd_ubi.o
 COBJS-$(CONFIG_CMD_UBIFS) += cmd_ubifs.o
 COBJS-$(CONFIG_CMD_UNIVERSE) += cmd_universe.o
+ifdef CONFIG_LZMA
+COBJS-$(CONFIG_CMD_UNLZMA) += cmd_unlzma.o
+endif
 COBJS-$(CONFIG_CMD_UNZIP) += cmd_unzip.o
 ifdef CONFIG_CMD_USB
 COBJS-y += cmd_usb.o
common/cmd_unlzma.c new file +69 -0

69 lines not on this page · raw message

Signature · 1 line
1.7.11.5
#1 lore raw

PATCH 2/2 Add unlzo command

Provide access to the lzo decompressor from the command line.

---
 common/Makefile    |  3 +++
 common/cmd_unlzo.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 68 insertions(+)
 create mode 100644 common/cmd_unlzo.c
common/Makefile +3 -0
index b8568ba..0793e50 100644
@@ -156,6 +156,9 @@ COBJS-$(CONFIG_CMD_UNIVERSE) += cmd_universe.o
 ifdef CONFIG_LZMA
 COBJS-$(CONFIG_CMD_UNLZMA) += cmd_unlzma.o
 endif
+ifdef CONFIG_LZO
+COBJS-$(CONFIG_CMD_UNLZO) += cmd_unlzo.o
+endif
 COBJS-$(CONFIG_CMD_UNZIP) += cmd_unzip.o
 ifdef CONFIG_CMD_USB
 COBJS-y += cmd_usb.o
common/cmd_unlzo.c new file +65 -0

65 lines not on this page · raw message

Signature · 1 line
1.7.11.5
#2 lore raw

PATCH 2/2 Add unlzo command

common/Makefile COBJS-$(CONFIG_CMD_UNIVERSE) += cmd_universe.o · line 161

Quoted 9 lines · On Friday 17 August 2012 16:59:44 Joe Hershberger wrote:
common/Makefile +3 -0
 
 ifdef CONFIG_LZMA
 COBJS-$(CONFIG_CMD_UNLZMA) += cmd_unlzma.o
 endif
+ifdef CONFIG_LZO
+COBJS-$(CONFIG_CMD_UNLZO) += cmd_unlzo.o
+endif

imo, these ifdefs shouldn't exist. the commands shouldn't get silently ignored because someone omitted an option. add an #ifdef check to the .c file and have it #error out if the necessary config options aren't defined.

common/cmd_unlzo.c

Quoted 4 lines
common/cmd_unlzo.c new file +1 -0
 
+int do_unlzo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])

static

common/cmd_unlzo.c line 52

Quoted 4 lines
common/cmd_unlzo.c new file +4 -0
+	ret = lzop_decompress((void *)src, src_len, (void *)dst, &dst_len);
+	if (ret != LZO_E_OK) {
+		printf("unlzo: uncompress or overwrite error %d\n", ret);
+		return -1;

how about returning ret ?

common/cmd_unlzo.c line 56

Quoted 2 lines
common/cmd_unlzo.c new file +2 -0
+	sprintf(buf, "%lX", (unsigned long) dst_len);
+	setenv("filesize", buf);

setenv_ulong() ?

common/cmd_unlzo.c line 65

Quoted 5 lines
common/cmd_unlzo.c new file +5 -0
+U_BOOT_CMD(
+	unlzo,	5,	1,	do_unlzo,
+	"unlzo a memory region",
+	"srcaddr srcsize dstaddr [dstsize]"
+);

isn't there a way you could "stream" this so you don't need the srcsize ? or does the lzop API not support that ?
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120817/e71f188e/attachment.pgp>

#3 lore raw

PATCH 2/2 Add unlzo command

Hi Mike,

Quoted 4 lines · Mike Frysinger
Quoted 3 lines · On Friday 17 August 2012 16:59:44 Joe Hershberger wrote:
common/Makefile +0 -0
Quoted 10 lines

common/Makefile COBJS-$(CONFIG_CMD_UNIVERSE) += cmd_universe.o · line 161

Quoted 6 lines

ifdef CONFIG_LZMA
COBJS-$(CONFIG_CMD_UNLZMA) += cmd_unlzma.o
endif

common/Makefile +3 -0
+ifdef CONFIG_LZO
+COBJS-$(CONFIG_CMD_UNLZO) += cmd_unlzo.o
+endif

imo, these ifdefs shouldn't exist. the commands shouldn't get silently ignored because someone omitted an option. add an #ifdef check to the .c file and have it #error out if the necessary config options aren't defined.

OK

Quoted 6 lines

common/cmd_unlzo.c

Quoted 4 lines
common/cmd_unlzo.c new file +1 -0
 
+int do_unlzo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])

static

OK

Quoted 6 lines

common/cmd_unlzo.c line 52

Quoted 4 lines
common/cmd_unlzo.c new file +4 -0
+     ret = lzop_decompress((void *)src, src_len, (void *)dst, &dst_len);
+     if (ret != LZO_E_OK) {
+             printf("unlzo: uncompress or overwrite error %d\n", ret);
+             return -1;

how about returning ret ?

OK

Quoted 4 lines

common/cmd_unlzo.c line 56

Quoted 2 lines
common/cmd_unlzo.c new file +2 -0
+     sprintf(buf, "%lX", (unsigned long) dst_len);
+     setenv("filesize", buf);

setenv_ulong() ?

OK

Quoted 8 lines

common/cmd_unlzo.c line 65

Quoted 5 lines
common/cmd_unlzo.c new file +5 -0
+U_BOOT_CMD(
+     unlzo,  5,      1,      do_unlzo,
+     "unlzo a memory region",
+     "srcaddr srcsize dstaddr [dstsize]"
+);

isn't there a way you could "stream" this so you don't need the srcsize ? or does the lzop API not support that ?

The lzo API uses the source size to check if the input is complete at the end of the file. I could pass in ~0 optionally and it would stop at the end. (It's not as clear how unlzma will handle it.)

So it would look like "unlzo srcaddr dstaddr [dstsize]"

Thanks,
-Joe

#4 lore raw

PATCH 1/2 Add unlzma command

In reply to Joe Hershberger
Quoted 1 line · On Friday 17 August 2012 16:59:43 Joe Hershberger wrote:

Provide access to the lzma decompressor from the command line.

same feedback for this file as the unlzo command feedback
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120817/a16107d4/attachment.pgp>