commit f06ec64f dmesg; support level names (e.g. --console-level=alert) introduced an off-by-one error. The kernel will print messages with a *higher* level than the console-level. The bug made it impossible to set the level for debugging, like it is documented in e.g Documentation/networking/netconsole.txt : nemi:/tmp# dmesg -n 8 dmesg: unknown level '8' And attempting to set the "emerg" level would result in an invalid 0 value: nemi:/tmp# dmesg -n emerg dmesg: klogctl failed: Invalid argument Restoring the old behaviour for numeric levels, and mapping the level names so that "dmesg -n debug" behaves as expected: logging everything at level "debug" and higher. Signed-off-by: Bjørn Mork <bjorn@xxxxxxx> --- sys-utils/dmesg.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/sys-utils/dmesg.c b/sys-utils/dmesg.c index 0ee03ee..fe39256 100644 --- a/sys-utils/dmesg.c +++ b/sys-utils/dmesg.c @@ -232,19 +232,23 @@ static void __attribute__((__noreturn__)) usage(FILE *out) */ static int parse_level(const char *str, size_t len) { + int offset = 0; + if (!str) return -1; - if (!len) + if (!len) { len = strlen(str); + offset = 1; + } errno = 0; if (isdigit(*str)) { char *end = NULL; - long x = strtol(str, &end, 10); + long x = strtol(str, &end, 10) - offset; if (!errno && end && end > str && (size_t) (end - str) == len && x >= 0 && (size_t) x < ARRAY_SIZE(level_names)) - return x; + return x + offset; } else { size_t i; @@ -252,7 +256,7 @@ static int parse_level(const char *str, size_t len) const char *n = level_names[i].name; if (strncasecmp(str, n, len) == 0 && *(n + len) == '\0') - return i; + return i + offset; } } -- 1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe util-linux" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html