From 844b5dbd3fc1247644948e6055ecc0cb017eee3b Mon Sep 17 00:00:00 2001 From: nik Date: Fri, 18 May 2001 08:52:56 +0000 Subject: [PATCH] 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 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. --- sys/dev/syscons/syscons.c | 18 ++++++++++++++++++ sys/sys/consio.h | 10 ++++++++++ 2 files changed, 28 insertions(+) diff --git a/sys/dev/syscons/syscons.c b/sys/dev/syscons/syscons.c index da11de91c9a4..f3305c4eb8e9 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 7a9fb0241b80..5cb599aaf953 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