Line | Count | Source |
1 | | // SPDX-License-Identifier: GPL-2.0+ |
2 | | /* |
3 | | * Copyright (C) 2017 Masahiro Yamada <yamada.masahiro@socionext.com> |
4 | | */ |
5 | | |
6 | | #include <command.h> |
7 | | #include <gzip.h> |
8 | | #include <malloc.h> |
9 | | |
10 | | #include "config_data_gz.h" |
11 | | #include "config_data_size.h" |
12 | | |
13 | | static int do_config(struct cmd_tbl *cmdtp, int flag, int argc, |
14 | | char *const argv[]) |
15 | 0 | { |
16 | 0 | char *dst; |
17 | 0 | unsigned long len = data_size; |
18 | 0 | int ret = CMD_RET_SUCCESS; |
19 | |
|
20 | 0 | dst = malloc(data_size + 1); |
21 | 0 | if (!dst) |
22 | 0 | return CMD_RET_FAILURE; |
23 | | |
24 | 0 | ret = gunzip(dst, data_size, (unsigned char *)data_gz, &len); |
25 | 0 | if (ret) { |
26 | 0 | printf("failed to uncompress .config data\n"); |
27 | 0 | ret = CMD_RET_FAILURE; |
28 | 0 | goto free; |
29 | 0 | } |
30 | | |
31 | 0 | dst[data_size] = 0; |
32 | 0 | puts(dst); |
33 | |
|
34 | 0 | free: |
35 | 0 | free(dst); |
36 | |
|
37 | 0 | return ret; |
38 | 0 | } |
39 | | |
40 | | U_BOOT_CMD( |
41 | | config, 1, 1, do_config, |
42 | | "print .config", |
43 | | "" |
44 | | ); |