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.
This commit is contained in:
nik 2001-05-18 08:52:56 +00:00
parent b57f29c9d2
commit 844b5dbd3f
2 changed files with 28 additions and 0 deletions

View File

@ -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;

View File

@ -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