summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorTom Rini <[email protected]>2026-07-21 13:52:00 -0600
committerTom Rini <[email protected]>2026-07-21 13:52:00 -0600
commit72d780b5ccc0644f935eb48fdffb92b1177c4fb3 (patch)
tree91cd97e0baf5c6897d020b78193991a94c445cd3 /cmd
parent85667122fb5fa215315a633335efc27ecd195b21 (diff)
parentd408eb2bc5a4675e11d7b77943553386d039bafc (diff)
Merge patch series "some string cleanup, and a tweak of the "config" command"
Rasmus Villemoes <[email protected]> says: This started by me wanting something like what patch 8 does. That wasn't too hard, except we had no strcasestr(), and also our regex engine (which I didn't really want to pull into the mix anyway) doesn't have a flag that requests case-insensitive matching. So I wanted to add strcasestr(), but then I stumbled on a bunch of stuff that should be cleaned up in str-land. Link: https://lore.kernel.org/r/[email protected]
Diffstat (limited to 'cmd')
-rw-r--r--cmd/config.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/cmd/config.c b/cmd/config.c
index f0d2033c61f..22115e9b1da 100644
--- a/cmd/config.c
+++ b/cmd/config.c
@@ -6,6 +6,7 @@
#include <command.h>
#include <gzip.h>
#include <malloc.h>
+#include <linux/string.h>
#include "config_data_gz.h"
#include "config_data_size.h"
@@ -29,7 +30,23 @@ static int do_config(struct cmd_tbl *cmdtp, int flag, int argc,
}
dst[data_size] = 0;
- puts(dst);
+ if (argc > 1) {
+ const char *s = argv[1];
+ char *b = dst, *e = dst + data_size, *n;
+
+ while (b < e) {
+ n = strchrnul(b, '\n');
+ *n = '\0';
+
+ if (strcasestr(b, s)) {
+ puts(b);
+ puts("\n");
+ }
+ b = n + 1;
+ }
+ } else {
+ puts(dst);
+ }
free:
free(dst);
@@ -38,7 +55,10 @@ free:
}
U_BOOT_CMD(
- config, 1, 1, do_config,
+ config, 2, 1, do_config,
"print .config",
- ""
+ "[str]\n"
+ "\n"
+ "When the optional argument is given, only lines containing\n"
+ "that string are printed. Matching is case-insensitive."
);