pstore/platform: Use backend name for console registration
authorKees Cook <keescook@chromium.org>
Fri, 8 May 2020 16:26:28 +0000 (09:26 -0700)
committerKees Cook <keescook@chromium.org>
Sat, 30 May 2020 17:34:02 +0000 (10:34 -0700)
If the pstore backend changes, there's no indication in the logs what
the console is (it always says "pstore"). Instead, pass through the
active backend's name. (Also adjust the selftest to match.)

Link: https://lore.kernel.org/lkml/20200510202436.63222-5-keescook@chromium.org/
Link: https://lore.kernel.org/lkml/20200526135429.GQ12456@shao2-debian
Signed-off-by: Kees Cook <keescook@chromium.org>
fs/pstore/platform.c
tools/testing/selftests/pstore/pstore_tests

index 715396bef0eaba46731173a414bbf85d49502e18..e8690d8606e02284bbeb0c4bfe35fbaa4caad649 100644 (file)
@@ -514,13 +514,15 @@ static void pstore_console_write(struct console *con, const char *s, unsigned c)
 }
 
 static struct console pstore_console = {
-       .name   = "pstore",
        .write  = pstore_console_write,
        .index  = -1,
 };
 
 static void pstore_register_console(void)
 {
+       /* Show which backend is going to get console writes. */
+       strscpy(pstore_console.name, psinfo->name,
+               sizeof(pstore_console.name));
        /*
         * Always initialize flags here since prior unregister_console()
         * calls may have changed settings (specifically CON_ENABLED).
index 1cef54458aff916b2f00af33deef703cb3101ab0..2aa9a3852a84209bcab4fb8b45a5800dbed3e5be 100755 (executable)
@@ -10,7 +10,7 @@
 . ./common_tests
 
 prlog -n "Checking pstore console is registered ... "
-dmesg | grep -q "console \[pstore"
+dmesg | grep -Eq "console \[(pstore|${backend})"
 show_result $?
 
 prlog -n "Checking /dev/pmsg0 exists ... "