summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authornik <nik@FreeBSD.org>2001-05-18 08:52:56 +0000
committernik <nik@FreeBSD.org>2001-05-18 08:52:56 +0000
commit288113e7a883fb602d402afb36dcb3622557dc49 (patch)
treec24af2c4620d7753503d3ed10c761a68f06eb10c /sys
parent85b499e6f868ac8c73b82e03d9db2515e623c786 (diff)
downloadFreeBSD-src-288113e7a883fb602d402afb36dcb3622557dc49.zip
FreeBSD-src-288113e7a883fb602d402afb36dcb3622557dc49.tar.gz
Add a new ioctl to syscons, CONS_SCRSHOT. Given a userland buffer, it
copies out the current contents of the video buffer for a syscons terminal, providing a snapshot of the text and attributes. Based heavily on work originally submitted by Joel Holveck <joelh@gnu.org> for 2.2.x almost 30 months ago, which I cleaned up a little, and forward ported to -current. See also the usr.bin/scrshot utility.
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/syscons/syscons.c18
-rw-r--r--sys/sys/consio.h10
2 files changed, 28 insertions, 0 deletions
diff --git a/sys/dev/syscons/syscons.c b/sys/dev/syscons/syscons.c
index da11de9..f3305c4 100644
--- a/sys/dev/syscons/syscons.c
+++ b/sys/dev/syscons/syscons.c
@@ -838,6 +838,24 @@ scioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
splx(s);
return 0;
+ case CONS_SCRSHOT: /* get a screen shot */
+ {
+ scrshot_t *ptr = (scrshot_t*)data;
+ s = spltty();
+ if (ISGRAPHSC(scp)) {
+ splx(s);
+ return EOPNOTSUPP;
+ }
+ if (scp->xsize != ptr->xsize || scp->ysize != ptr->ysize) {
+ splx(s);
+ return EINVAL;
+ }
+ copyout ((void*)scp->vtb.vtb_buffer, ptr->buf,
+ ptr->xsize * ptr->ysize * sizeof(u_int16_t));
+ splx(s);
+ return 0;
+ }
+
case VT_SETMODE: /* set screen switcher mode */
{
struct vt_mode *mode;
diff --git a/sys/sys/consio.h b/sys/sys/consio.h
index 7a9fb02..5cb599a 100644
--- a/sys/sys/consio.h
+++ b/sys/sys/consio.h
@@ -239,6 +239,16 @@ typedef struct vid_info vid_info_t;
/* release the current keyboard */
#define CONS_RELKBD _IO('c', 111)
+/* Snapshot the current video buffer */
+#define CONS_SCRSHOT _IOWR('c', 105, scrshot_t)
+
+struct scrshot {
+ int xsize;
+ int ysize;
+ u_int16_t* buf;
+};
+typedef struct scrshot scrshot_t;
+
/* get/set the current terminal emulator info. */
#define TI_NAME_LEN 32
#define TI_DESC_LEN 64
OpenPOWER on IntegriCloud