Skip to content

Commit 3f4ef48

Browse files
npitregregkh
authored andcommitted
vt: fix scrollback flushing on background consoles
Commit a6dbe44 ("vt: perform safe console erase in the right order") provided fixes to an earlier commit by gathering all console scrollback flushing operations in a function of its own. This includes the invocation of vc_sw->con_switch() as previously done through a update_screen() call. That commit failed to carry over the con_is_visible() conditional though, as well as cursor handling, which caused problems when "\e[3J" was written to a background console. One could argue for preserving the call to update_screen(). However this does far more than we need, and it is best to remove scrollback assumptions from it. Instead let's gather the minimum needed to actually perform scrollback flushing properly in that one place. While at it, let's document the vc_sw->con_switch() side effect being relied upon. Signed-off-by: Nicolas Pitre <nico@fluxnic.net> Reported-and-tested-by: Lukas Wunner <lukas@wunner.de> Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/nycvar.YSQ.7.76.2001281205560.1655@knanqh.ubzr Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 1f69a12 commit 3f4ef48

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

drivers/tty/vt/vt.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -936,10 +936,21 @@ static void flush_scrollback(struct vc_data *vc)
936936
WARN_CONSOLE_UNLOCKED();
937937

938938
set_origin(vc);
939-
if (vc->vc_sw->con_flush_scrollback)
939+
if (vc->vc_sw->con_flush_scrollback) {
940940
vc->vc_sw->con_flush_scrollback(vc);
941-
else
941+
} else if (con_is_visible(vc)) {
942+
/*
943+
* When no con_flush_scrollback method is provided then the
944+
* legacy way for flushing the scrollback buffer is to use
945+
* a side effect of the con_switch method. We do it only on
946+
* the foreground console as background consoles have no
947+
* scrollback buffers in that case and we obviously don't
948+
* want to switch to them.
949+
*/
950+
hide_cursor(vc);
942951
vc->vc_sw->con_switch(vc);
952+
set_cursor(vc);
953+
}
943954
}
944955

945956
/*

0 commit comments

Comments
 (0)