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. .\" USA.
.\" .\"
.\" Modified, Sun Feb 26 15:08:05 1995, faith@cs.unc.edu .\" 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 .SH NAME
vcs, vcsa \- virtual console memory vcs, vcsa \- virtual console memory
.SH DESCRIPTION .SH DESCRIPTION
@ -36,13 +38,26 @@ displayed virtual console terminal.
terminals, they have major number 7 and minor number 1 to 63, usually terminals, they have major number 7 and minor number 1 to 63, usually
mode 0644 and owner root.tty. mode 0644 and owner root.tty.
\fI/dev/vcsa[0\-63]\fP are the same, but \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. 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.) (\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 .PP
These replace the screendump These devices replace the screendump
.IR ioctl s .BR ioctl (2)
of operations of
.BR console (4), .BR console (4),
so the system so the system
administrator can control access using file system permissions. 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 done
chown root:tty /dev/vcs* chown root:tty /dev/vcs*
.fi .fi
No
.BR ioctl (2)
requests are supported.
.SH FILES .SH FILES
/dev/vcs[0\-63] /dev/vcs[0\-63]
.br .br
@ -87,15 +98,30 @@ there:
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <fcntl.h> #include <fcntl.h>
#include <sys/ioctl.h>
#include <linux/vt.h>
int int
main(void) main(void)
{ {
int fd; int fd;
char *device = "/dev/vcsa2"; char *device = "/dev/vcsa2";
char *console = "/dev/tty2";
struct {unsigned char lines, cols, x, y;} scrn; 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); fd = open(device, O_RDWR);
if (fd < 0) { if (fd < 0) {
perror(device); perror(device);
@ -103,8 +129,11 @@ main(void)
} }
(void) read(fd, &scrn, 4); (void) read(fd, &scrn, 4);
(void) lseek(fd, 4 + 2*(scrn.y*scrn.cols + scrn.x), 0); (void) lseek(fd, 4 + 2*(scrn.y*scrn.cols + scrn.x), 0);
(void) read(fd, &ch, 1); (void) read(fd, &s, 2);
(void) read(fd, &attrib, 1); ch = s & 0xff;
if (attrib & mask)
ch |= 0x100;
attrib = ((s & ~mask) >> 8);
printf("ch='%c' attrib=0x%02x\\n", ch, attrib); printf("ch='%c' attrib=0x%02x\\n", ch, attrib);
attrib ^= 0x10; attrib ^= 0x10;
(void) lseek(fd, \-1, 1); (void) lseek(fd, \-1, 1);