Document VT_GETHIFONTMASK (new in 2.6.18) and add to example program;

attribute/text characters are in the host byte order.
This commit is contained in:
Michael Kerrisk 2007-12-17 14:52:20 +00:00
parent aedcbc663c
commit a0d4bc1f98
1 changed files with 41 additions and 12 deletions

View File

@ -22,8 +22,10 @@
.\" USA.
.\"
.\" Modified, Sun Feb 26 15:08:05 1995, faith@cs.unc.edu
.\" 2007-12-17, Samuel Thibault <samuel.thibault@ens-lyon.org>:
.\" document the VT_GETHIFONTMASK ioctl
.\" "
.TH VCS 4 1995-02-19 "Linux" "Linux Programmer's Manual"
.TH VCS 4 2007-12-17 "Linux" "Linux Programmer's Manual"
.SH NAME
vcs, vcsa \- virtual console memory
.SH DESCRIPTION
@ -36,13 +38,26 @@ displayed virtual console terminal.
terminals, they have major number 7 and minor number 1 to 63, usually
mode 0644 and owner root.tty.
\fI/dev/vcsa[0\-63]\fP are the same, but
including attributes, and prefixed with four bytes giving the screen
using unsigned shorts (in host byte order) that include attributes,
and prefixed with four bytes giving the screen
dimensions and cursor position: \fIlines\fP, \fIcolumns\fP, \fIx\fP, \fIy\fP.
(\fIx\fP = \fIy\fP = 0 at the top left corner of the screen.)
When a 512-character font is loaded,
the 9th bit position can be fetched by applying the
.BR ioctl (2)
\fBVT_GETHIFONTMASK\fP operation
(available in Linux kernels 2.6.18 and above)
on \fI/dev/tty[1\-63]\fP;
the value is returned in the
.I "unsigned short"
pointed to by the third
.BR ioctl (2)
argument.
.PP
These replace the screendump
.IR ioctl s
of
These devices replace the screendump
.BR ioctl (2)
operations of
.BR console (4),
so the system
administrator can control access using file system permissions.
@ -56,10 +71,6 @@ The devices for the first eight virtual consoles may be created by:
done
chown root:tty /dev/vcs*
.fi
No
.BR ioctl (2)
requests are supported.
.SH FILES
/dev/vcs[0\-63]
.br
@ -87,15 +98,30 @@ there:
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <linux/vt.h>
int
main(void)
{
int fd;
char *device = "/dev/vcsa2";
char *console = "/dev/tty2";
struct {unsigned char lines, cols, x, y;} scrn;
char ch, attrib;
unsigned short s;
unsigned short mask;
unsigned char ch, attrib;
fd = open(console, O_RDWR);
if (fd < 0) {
perror(console);
exit(EXIT_FAILURE);
}
if (ioctl(fd, VT_GETHIFONTMASK, &mask) < 0) {
perror("VT_GETHIFONTMASK");
exit(EXIT_FAILURE);
}
(void) close(fd);
fd = open(device, O_RDWR);
if (fd < 0) {
perror(device);
@ -103,8 +129,11 @@ main(void)
}
(void) read(fd, &scrn, 4);
(void) lseek(fd, 4 + 2*(scrn.y*scrn.cols + scrn.x), 0);
(void) read(fd, &ch, 1);
(void) read(fd, &attrib, 1);
(void) read(fd, &s, 2);
ch = s & 0xff;
if (attrib & mask)
ch |= 0x100;
attrib = ((s & ~mask) >> 8);
printf("ch='%c' attrib=0x%02x\\n", ch, attrib);
attrib ^= 0x10;
(void) lseek(fd, \-1, 1);