linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Manuel Schölling" <manuel.schoelling@gmx.de>
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 19:56:58 +0000	[thread overview]
Message-ID: <1461009418-1795-3-git-send-email-manuel.schoelling@gmx.de> (raw)
In-Reply-To: <1461009418-1795-1-git-send-email-manuel.schoelling@gmx.de>

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 <manuel.schoelling@gmx.de>
---
 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 */
-- 
2.1.4


  parent reply	other threads:[~2016-04-18 19:56 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-18 19:56 [PATCH 0/2] Persistent scrollback buffers for all VGA consoles Manuel Schölling
2016-04-18 19:56 ` Manuel Schölling
2016-04-18 19:56   ` [PATCH 1/2] console: Add persistent " Manuel Schölling
2016-04-18 19:56   ` Manuel Schölling [this message]
2016-04-18 20:16     ` [PATCH 2/2] console: Add ioctl for flushing the scrollback buffer kbuild test robot
     [not found]   ` <1461009418-1795-1-git-send-email-manuel.schoelling-Mmb7MZpHnFY@public.gmane.org>
2016-04-18 20:38     ` [PATCH 0/2] Persistent scrollback buffers for all VGA consoles Jakub Wilk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1461009418-1795-3-git-send-email-manuel.schoelling@gmx.de \
    --to=manuel.schoelling@gmx.de \
    --cc=deller@gmx.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=jejb@parisc-linux.org \
    --cc=jslaby@suse.com \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-parisc@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=plagnioj@jcrosoft.com \
    --cc=sfr@canb.auug.org.au \
    --cc=thomas@winischhofer.net \
    --cc=tomi.valkeinen@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).