From patchwork Mon Apr 18 19:56:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Manuel_Sch=C3=B6lling?= X-Patchwork-Id: 8874821 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7B8E59F441 for ; Mon, 18 Apr 2016 19:58:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6BB5A201BC for ; Mon, 18 Apr 2016 19:58:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 470B6201C8 for ; Mon, 18 Apr 2016 19:58:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751531AbcDRT6F (ORCPT ); Mon, 18 Apr 2016 15:58:05 -0400 Received: from mout.gmx.net ([212.227.17.20]:54487 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751126AbcDRT6D (ORCPT ); Mon, 18 Apr 2016 15:58:03 -0400 Received: from schoellingm.dzne.de ([37.201.194.187]) by mail.gmx.com (mrgmx102) with ESMTPSA (Nemesis) id 0MKKaI-1arh3p0AFy-001fsL; Mon, 18 Apr 2016 21:57:11 +0200 From: =?UTF-8?q?Manuel=20Sch=C3=B6lling?= To: gregkh@linuxfoundation.org Cc: jslaby@suse.com, thomas@winischhofer.net, plagnioj@jcrosoft.com, tomi.valkeinen@ti.com, jejb@parisc-linux.org, deller@gmx.de, manuel.schoelling@gmx.de, sfr@canb.auug.org.au, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, linux-fbdev@vger.kernel.org, linux-parisc@vger.kernel.org Subject: [PATCH 2/2] console: Add ioctl for flushing the scrollback buffer Date: Mon, 18 Apr 2016 21:56:58 +0200 Message-Id: <1461009418-1795-3-git-send-email-manuel.schoelling@gmx.de> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1461009418-1795-1-git-send-email-manuel.schoelling@gmx.de> References: <1461009418-1795-1-git-send-email-manuel.schoelling@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K0:ef4oYDY0YeY7/CCHW+afIrLpGpj7Bu7CEuuVn/CgsWaSXM8JIeT wFsw7KAXcQCnkvIG5WXBqThuCpDntUuhhU6EweDb548zjI/oP+GYlRkRbNsaTAjueNSkB6m itkA+I/fYHyI0dCiH3yMPBGAKVGDl1iavzXrFJaafeVUO7fZCWEIrPKCfzgSxOwMKb+3KUC uxYU4ai7AeP7Dl2NUOPBA== X-UI-Out-Filterresults: notjunk:1; V01:K0:4pJkZomzs4s=:MoFnkshfaectwitMNA5EwO JhKfwEKBiyGFZYrLo673ZrQg8VjfBbuwSfr5Js+hYlfJnMLkucZA1LBZyoVsCFVBjzivlaamD jQv4cGRIFfW5/0BU7gwE/enqG1UCP8DyLbyPPXGZ+PIZzttwQvgNFX7x0QB/eRVR9GuS6nJDs OX4kcSt4VPku5tKyqHhrMivp83Te4GSjr04LVjwK6HgrMpoAomrgXTDEuJiz/xp6Pv3jmM9yW hz/J9vZ2eecvaCYsV7Pp+dbdBUgsd56juE8pB1YtdlZxAtuiLsH9qyHeoZBdSUrGYM0IFIftJ A8f+ZFN/Lbx1vHA1WLvqcs77zZPWStPYHtAYY19HXLKQlR5d4HVVIi9TwoFnSbtYNJypBjAW6 VRQrarbs5q0Yep4WpfNPrL+ZXVKh45ziezoh7yxCELYBtb2rxyDj+glR+6NGOaoc/xySXaQv4 pUX+6yfeC8T4o5S59qNt2XzF4zBnlZl7RxyL9ccEgKf3A0AZ4+GFUcybWeSVYZ5q+kAHnGASk dX0Va+UEm2QowUWnptgHDRlWrDq2CITjYYzUVOCtinNjKzlIFpLtPUarnY+WC3eRSvFGTC4ce 1Wmu9/yK3rSd1zjvVxW0alWcEYx/TKfVmu8ZjqTofpFdt/3Nvvnl4Csq0xBJdWqqamRY1Opr7 iu9OFbxXFSFEn1KNTHxLu2lTG2r9lPEviKbfO4i2IHXyoRx2kmhXV+IvgtcSypG93aRMJWKga xna+OSFzvaEo8IuYqD5OwMbcOBFDXFHemqguTQxhbS68OelgdjYSinr6b73NefVDYqX+OPhod e38pWy4 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Tools like clear_console rely on the fact that scrollback history is flushed when switching back and forth between consoles. Persistent scrollback buffers for each console breaks this, so this patch adds a ioctl() callf for flushing the scrollback history. Signed-off-by: Manuel Schölling --- drivers/tty/vt/vt_ioctl.c | 20 ++++++++++++++++++++ drivers/usb/misc/sisusbvga/sisusb_con.c | 1 + drivers/video/console/dummycon.c | 1 + drivers/video/console/mdacon.c | 6 ++++++ drivers/video/console/newport_con.c | 1 + drivers/video/console/sticon.c | 7 +++++++ drivers/video/console/vgacon.c | 23 +++++++++++++++++++++++ include/linux/console.h | 1 + include/uapi/linux/vt.h | 1 + 9 files changed, 61 insertions(+) diff --git a/drivers/tty/vt/vt_ioctl.c b/drivers/tty/vt/vt_ioctl.c index 97d5a74..18adc23 100644 --- a/drivers/tty/vt/vt_ioctl.c +++ b/drivers/tty/vt/vt_ioctl.c @@ -903,6 +903,26 @@ int vt_ioctl(struct tty_struct *tty, break; } + /* + * flush the specified VT's scollback buffer + */ + case VT_FLUSH_SCROLLBACK: { + if (!perm) + return -EPERM; + if (arg == 0 || arg > MAX_NR_CONSOLES) + ret = -ENXIO; + else { + struct vc_data *data = vc_cons[arg-1].d; + + if (!data) + ret = -ENXIO; + else + ret = data->vc_sw->con_flush_scrollback(data); + } + + break; + } + case PIO_FONT: { if (!perm) return -EPERM; diff --git a/drivers/usb/misc/sisusbvga/sisusb_con.c b/drivers/usb/misc/sisusbvga/sisusb_con.c index ace3430..cc5fc10 100644 --- a/drivers/usb/misc/sisusbvga/sisusb_con.c +++ b/drivers/usb/misc/sisusbvga/sisusb_con.c @@ -1442,6 +1442,7 @@ static const struct consw sisusb_dummy_con = { .con_font_copy = SISUSBCONDUMMY, .con_set_palette = SISUSBCONDUMMY, .con_scrolldelta = SISUSBCONDUMMY, + .con_flush_scrollback = SISUSBCONDUMMY, }; int diff --git a/drivers/video/console/dummycon.c b/drivers/video/console/dummycon.c index 0efc52f..d2888e5 100644 --- a/drivers/video/console/dummycon.c +++ b/drivers/video/console/dummycon.c @@ -73,5 +73,6 @@ const struct consw dummy_con = { .con_font_copy = DUMMY, .con_set_palette = DUMMY, .con_scrolldelta = DUMMY, + .con_flush_scrollback = DUMMY, }; EXPORT_SYMBOL_GPL(dummy_con); diff --git a/drivers/video/console/mdacon.c b/drivers/video/console/mdacon.c index 296e945..10ebcbe 100644 --- a/drivers/video/console/mdacon.c +++ b/drivers/video/console/mdacon.c @@ -510,6 +510,11 @@ static int mdacon_scrolldelta(struct vc_data *c, int lines) return 0; } +static int mdacon_flush_scrollback(struct vc_data *c) +{ + return 0; +} + static void mdacon_cursor(struct vc_data *c, int mode) { if (mode == CM_ERASE) { @@ -579,6 +584,7 @@ static const struct consw mda_con = { .con_blank = mdacon_blank, .con_set_palette = mdacon_set_palette, .con_scrolldelta = mdacon_scrolldelta, + .con_flush_scrollback = mdacon_flush_scrollback, .con_build_attr = mdacon_build_attr, .con_invert_region = mdacon_invert_region, }; diff --git a/drivers/video/console/newport_con.c b/drivers/video/console/newport_con.c index bb4e962..d04183c 100644 --- a/drivers/video/console/newport_con.c +++ b/drivers/video/console/newport_con.c @@ -738,6 +738,7 @@ const struct consw newport_con = { .con_scrolldelta = newport_scrolldelta, .con_set_origin = DUMMY, .con_save_screen = DUMMY + .con_flush_scrollback = DUMMY, }; static int newport_probe(struct gio_device *dev, diff --git a/drivers/video/console/sticon.c b/drivers/video/console/sticon.c index 026fd12..46046d6 100644 --- a/drivers/video/console/sticon.c +++ b/drivers/video/console/sticon.c @@ -345,6 +345,12 @@ static void sticon_save_screen(struct vc_data *conp) { } +static int sticon_flush_scrollback(struct vc_data *c) +{ + return 0; +} + + static const struct consw sti_con = { .owner = THIS_MODULE, .con_startup = sticon_startup, @@ -360,6 +366,7 @@ static const struct consw sti_con = { .con_blank = sticon_blank, .con_set_palette = sticon_set_palette, .con_scrolldelta = sticon_scrolldelta, + .con_flush_scrollback = sticon_flush_scrollback, .con_set_origin = sticon_set_origin, .con_save_screen = sticon_save_screen, .con_build_attr = sticon_build_attr, diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c index 6c0b9ba..b5ea94f 100644 --- a/drivers/video/console/vgacon.c +++ b/drivers/video/console/vgacon.c @@ -379,12 +379,34 @@ static int vgacon_scrolldelta(struct vc_data *c, int lines) return 1; } + +/* flush the scrollback buffer of a console */ +static int vgacon_flush_scrollback(struct vc_data *c) +{ + size_t size = CONFIG_VGACON_SOFT_SCROLLBACK_SIZE * 1024; + struct vgacon_scrollback_info *vgacon_scrollback_prev; + + vgacon_scrollback_prev = vgacon_scrollback_cur; + vgacon_scrollback_cur = &vgacon_scrollbacks[c->vc_num]; + + if (vgacon_scrollback_cur != NULL) + vgacon_scrollback_reset(size); + + vgacon_scrollback_cur = vgacon_scrollback_prev; + + return 0; +} #else #define vgacon_scrollback_startup(...) do { } while (0) #define vgacon_scrollback_init(...) do { } while (0) #define vgacon_scrollback_update(...) do { } while (0) #define vgacon_switch_scrollback(...) do { } while (0) +static int vgacon_flush_scrollback(struct vc_data *c) +{ + return 0; +} + static void vgacon_restore_screen(struct vc_data *c) { if (c->vc_origin != c->vc_visible_origin) @@ -1492,6 +1514,7 @@ const struct consw vga_con = { .con_resize = vgacon_resize, .con_set_palette = vgacon_set_palette, .con_scrolldelta = vgacon_scrolldelta, + .con_flush_scrollback = vgacon_flush_scrollback, .con_set_origin = vgacon_set_origin, .con_save_screen = vgacon_save_screen, .con_build_attr = vgacon_build_attr, diff --git a/include/linux/console.h b/include/linux/console.h index e49cc1e..946ff20 100644 --- a/include/linux/console.h +++ b/include/linux/console.h @@ -49,6 +49,7 @@ struct consw { unsigned int); int (*con_set_palette)(struct vc_data *, unsigned char *); int (*con_scrolldelta)(struct vc_data *, int); + int (*con_flush_scrollback)(struct vc_data *); int (*con_set_origin)(struct vc_data *); void (*con_save_screen)(struct vc_data *); u8 (*con_build_attr)(struct vc_data *, u8, u8, u8, u8, u8, u8); diff --git a/include/uapi/linux/vt.h b/include/uapi/linux/vt.h index 978578b..b799541 100644 --- a/include/uapi/linux/vt.h +++ b/include/uapi/linux/vt.h @@ -83,5 +83,6 @@ struct vt_setactivate { }; #define VT_SETACTIVATE 0x560F /* Activate and set the mode of a console */ +#define VT_FLUSH_SCROLLBACK 0x5610 /* Flush the scrollback buffer */ #endif /* _UAPI_LINUX_VT_H */