diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2023-06-12 13:57:35 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2023-06-13 08:42:08 +0200 |
commit | 8db1f82c8aed218477b2cdf0e4b2c7e0122116cd (patch) | |
tree | 145d5f48b5e414e1ce2c34b75bf8613158d67dee /commands | |
parent | adadd6c0fcfd6b11076e0110497dd7ecdb44f99c (diff) | |
download | barebox-8db1f82c8aed218477b2cdf0e4b2c7e0122116cd.tar.gz barebox-8db1f82c8aed218477b2cdf0e4b2c7e0122116cd.tar.xz |
dmesg: allow loglevels specified as numbers
In Linux dmesg loglevels can be specified as strings or as numbers.
Do likewise in barebox.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'commands')
-rw-r--r-- | commands/dmesg.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/commands/dmesg.c b/commands/dmesg.c index 0d46353fb5..4cd88e3189 100644 --- a/commands/dmesg.c +++ b/commands/dmesg.c @@ -13,6 +13,16 @@ static int str_to_loglevel(const char *str) { + int ret; + unsigned long level; + + ret = kstrtoul(str, 10, &level); + if (!ret) { + if (level > MSG_VDEBUG) + goto unknown; + return level; + } + if (!strcmp(str, "vdebug")) return MSG_VDEBUG; if (!strcmp(str, "debug")) @@ -31,7 +41,7 @@ static int str_to_loglevel(const char *str) return MSG_ALERT; if (!strcmp(str, "emerg")) return MSG_EMERG; - +unknown: printf("dmesg: unknown loglevel %s\n", str); return -EINVAL; |