]> git.sur5r.net Git - u-boot/commitdiff
unzip: return uncompressed size in `filesize', and print it.
authorWolfgang Denk <wd@denx.de>
Fri, 11 Feb 2011 19:20:51 +0000 (20:20 +0100)
committerWolfgang Denk <wd@denx.de>
Tue, 15 Feb 2011 20:46:39 +0000 (21:46 +0100)
The unzip command did not provide a way for the caller to get any
information about the uncompressed size.  To make it better usable in
scripts, we now store the uncompressed size in the `filesize'
variable, like we do when for example loading a file over the network
or when reading it from a file system.  Following that analogy, it is
only consequent to also print the size.

Signed-off-by: Wolfgang Denk <wd@denx.de>
common/cmd_mem.c

index ccf420a13279de51d215c487d11ae169bd12a3db..4b524cfc160396e7b64bc5424cbc4c525dfe8760 100644 (file)
@@ -1212,6 +1212,7 @@ int do_unzip ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
        unsigned long src, dst;
        unsigned long src_len = ~0UL, dst_len = ~0UL;
+       char buf[32];
 
        switch (argc) {
                case 4:
@@ -1225,7 +1226,14 @@ int do_unzip ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
                        return cmd_usage(cmdtp);
        }
 
-       return !!gunzip((void *) dst, dst_len, (void *) src, &src_len);
+       if (gunzip((void *) dst, dst_len, (void *) src, &src_len) != 0)
+               return 1;
+
+       printf("Uncompressed size: %ld = 0x%lX\n", src_len, src_len);
+       sprintf(buf, "%lX", src_len);
+       setenv("filesize", buf);
+
+       return 0;
 }
 #endif /* CONFIG_CMD_UNZIP */