diff options
author | Ahmad Fatoum <a.fatoum@pengutronix.de> | 2022-08-08 08:56:39 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2022-08-08 13:18:38 +0200 |
commit | 22f4933e1914f6c97c3b9ecf796f0439d51fd6df (patch) | |
tree | 1d9228a280ed365e0ac258ac57536aaa8c4c19d4 /commands | |
parent | 728174bc2e4c38830562decd13a8f1dae9b1df06 (diff) | |
download | barebox-22f4933e1914f6c97c3b9ecf796f0439d51fd6df.tar.gz |
commands: of_dump: support limiting size of printed properties
FIT images can have properties with very long values. Make it possible
to use of_dump to inspect them by adding a -P option that restricts
how much of the value is printed.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20220808065639.453483-2-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'commands')
-rw-r--r-- | commands/devinfo.c | 2 | ||||
-rw-r--r-- | commands/of_dump.c | 15 |
2 files changed, 12 insertions, 5 deletions
diff --git a/commands/devinfo.c b/commands/devinfo.c index 32fd55ebd5..e171ecc62c 100644 --- a/commands/devinfo.c +++ b/commands/devinfo.c @@ -104,7 +104,7 @@ static int do_devinfo(int argc, char *argv[]) #ifdef CONFIG_OFDEVICE if (dev->device_node) { printf("Device node: %s\n", dev->device_node->full_name); - of_print_nodes(dev->device_node, 0); + of_print_nodes(dev->device_node, 0, ~0); } #endif } diff --git a/commands/of_dump.c b/commands/of_dump.c index 6f36b31514..c2ca8485cd 100644 --- a/commands/of_dump.c +++ b/commands/of_dump.c @@ -39,9 +39,10 @@ static int do_of_dump(int argc, char *argv[]) char *dtbfile = NULL; size_t size; const char *nodename; + unsigned maxpropsize = ~0; int names_only = 0, properties_only = 0; - while ((opt = getopt(argc, argv, "Ff:np")) > 0) { + while ((opt = getopt(argc, argv, "Ff:npP:")) > 0) { switch (opt) { case 'f': dtbfile = optarg; @@ -55,6 +56,11 @@ static int do_of_dump(int argc, char *argv[]) case 'p': properties_only = 1; break; + case 'P': + ret = kstrtouint(optarg, 0, &maxpropsize); + if (ret) + return ret; + break; default: return COMMAND_ERROR_USAGE; } @@ -120,9 +126,9 @@ static int do_of_dump(int argc, char *argv[]) if (names_only && !properties_only) of_print_nodenames(node); else if (properties_only && !names_only) - of_print_properties(node); + of_print_properties(node, maxpropsize); else - of_print_nodes(node, 0); + of_print_nodes(node, 0, maxpropsize); out: if (of_free) @@ -137,12 +143,13 @@ BAREBOX_CMD_HELP_OPT ("-f dtb", "work on dtb instead of internal devicetree") BAREBOX_CMD_HELP_OPT ("-F", "return fixed devicetree") BAREBOX_CMD_HELP_OPT ("-n", "Print node names only, no properties") BAREBOX_CMD_HELP_OPT ("-p", "Print properties only, no child nodes") +BAREBOX_CMD_HELP_OPT ("-P len", "print only len property bytes") BAREBOX_CMD_HELP_END BAREBOX_CMD_START(of_dump) .cmd = do_of_dump, BAREBOX_CMD_DESC("dump devicetree nodes") - BAREBOX_CMD_OPTS("[-fFnp] [NODE]") + BAREBOX_CMD_OPTS("[-fFnpP] [NODE]") BAREBOX_CMD_GROUP(CMD_GRP_MISC) BAREBOX_CMD_COMPLETE(devicetree_file_complete) BAREBOX_CMD_HELP(cmd_of_dump_help) |