| 1 |
.\" Copyright (c) 1995 James R. Van Zandt <[email protected]> |
| 2 |
.\" Sat Feb 18 09:11:07 EST 1995 |
| 3 |
.\" |
| 4 |
.\" SPDX-License-Identifier: GPL-2.0-or-later |
| 5 |
.\" |
| 6 |
.\" Modified, Sun Feb 26 15:08:05 1995, [email protected] |
| 7 |
.\" 2007-12-17, Samuel Thibault <[email protected]>: |
| 8 |
.\" document the VT_GETHIFONTMASK ioctl |
| 9 |
.\" " |
| 10 |
.TH vcs 4 2024-06-15 "Linux man-pages 6.9.1" |
| 11 |
.SH NAME |
| 12 |
vcs, vcsa \- virtual console memory |
| 13 |
.SH DESCRIPTION |
| 14 |
.I /dev/vcs0 |
| 15 |
is a character device with major number 7 and minor number |
| 16 |
0, usually with mode 0644 and ownership root:tty. |
| 17 |
It refers to the memory of the currently |
| 18 |
displayed virtual console terminal. |
| 19 |
.P |
| 20 |
.I /dev/vcs[1\-63] |
| 21 |
are character devices for virtual console |
| 22 |
terminals, they have major number 7 and minor number 1 to 63, usually |
| 23 |
mode 0644 and ownership root:tty. |
| 24 |
.I /dev/vcsa[0\-63] |
| 25 |
are the same, but |
| 26 |
using |
| 27 |
.IR "unsigned short" s |
| 28 |
(in host byte order) that include attributes, |
| 29 |
and prefixed with four bytes giving the screen |
| 30 |
dimensions and cursor position: |
| 31 |
.IR lines , |
| 32 |
.IR columns , |
| 33 |
.IR x , |
| 34 |
.IR y . |
| 35 |
.RI ( x |
| 36 |
= |
| 37 |
.I y |
| 38 |
= 0 at the top left corner of the screen.) |
| 39 |
.P |
| 40 |
When a 512-character font is loaded, |
| 41 |
the 9th bit position can be fetched by applying the |
| 42 |
.BR ioctl (2) |
| 43 |
.B VT_GETHIFONTMASK |
| 44 |
operation |
| 45 |
(available since Linux 2.6.18) |
| 46 |
on |
| 47 |
.IR /dev/tty[1\-63] ; |
| 48 |
the value is returned in the |
| 49 |
.I "unsigned short" |
| 50 |
pointed to by the third |
| 51 |
.BR ioctl (2) |
| 52 |
argument. |
| 53 |
.P |
| 54 |
These devices replace the screendump |
| 55 |
.BR ioctl (2) |
| 56 |
operations of |
| 57 |
.BR ioctl_console (2), |
| 58 |
so the system |
| 59 |
administrator can control access using filesystem permissions. |
| 60 |
.P |
| 61 |
The devices for the first eight virtual consoles may be created by: |
| 62 |
.P |
| 63 |
.in +4n |
| 64 |
.EX |
| 65 |
for x in 0 1 2 3 4 5 6 7 8; do |
| 66 |
mknod \-m 644 /dev/vcs$x c 7 $x; |
| 67 |
mknod \-m 644 /dev/vcsa$x c 7 $[$x+128]; |
| 68 |
done |
| 69 |
chown root:tty /dev/vcs* |
| 70 |
.EE |
| 71 |
.in |
| 72 |
.P |
| 73 |
No |
| 74 |
.BR ioctl (2) |
| 75 |
requests are supported. |
| 76 |
.SH FILES |
| 77 |
.I /dev/vcs[0\-63] |
| 78 |
.br |
| 79 |
.I /dev/vcsa[0\-63] |
| 80 |
.\" .SH AUTHOR |
| 81 |
.\" Andries Brouwer <[email protected]> |
| 82 |
.SH VERSIONS |
| 83 |
Introduced with Linux 1.1.92. |
| 84 |
.SH EXAMPLES |
| 85 |
You may do a screendump on vt3 by switching to vt1 and typing |
| 86 |
.P |
| 87 |
.in +4n |
| 88 |
.EX |
| 89 |
cat /dev/vcs3 >foo |
| 90 |
.EE |
| 91 |
.in |
| 92 |
.P |
| 93 |
Note that the output does not contain |
| 94 |
newline characters, so some processing may be required, like |
| 95 |
in |
| 96 |
.P |
| 97 |
.in +4n |
| 98 |
.EX |
| 99 |
fold \-w 81 /dev/vcs3 | lpr |
| 100 |
.EE |
| 101 |
.in |
| 102 |
.P |
| 103 |
or (horrors) |
| 104 |
.P |
| 105 |
.in +4n |
| 106 |
.EX |
| 107 |
setterm \-dump 3 \-file /proc/self/fd/1 |
| 108 |
.EE |
| 109 |
.in |
| 110 |
.P |
| 111 |
The |
| 112 |
.I /dev/vcsa0 |
| 113 |
device is used for Braille support. |
| 114 |
.P |
| 115 |
This program displays the character and screen attributes under the |
| 116 |
cursor of the second virtual console, then changes the background color |
| 117 |
there: |
| 118 |
.P |
| 119 |
.EX |
| 120 |
#include <unistd.h> |
| 121 |
#include <stdlib.h> |
| 122 |
#include <stdio.h> |
| 123 |
#include <fcntl.h> |
| 124 |
#include <sys/ioctl.h> |
| 125 |
#include <linux/vt.h> |
| 126 |
\& |
| 127 |
int |
| 128 |
main(void) |
| 129 |
{ |
| 130 |
int fd; |
| 131 |
char *device = "/dev/vcsa2"; |
| 132 |
char *console = "/dev/tty2"; |
| 133 |
struct {unsigned char lines, cols, x, y;} scrn; |
| 134 |
unsigned short s; |
| 135 |
unsigned short mask; |
| 136 |
unsigned char attrib; |
| 137 |
int ch; |
| 138 |
\& |
| 139 |
fd = open(console, O_RDWR); |
| 140 |
if (fd < 0) { |
| 141 |
perror(console); |
| 142 |
exit(EXIT_FAILURE); |
| 143 |
} |
| 144 |
if (ioctl(fd, VT_GETHIFONTMASK, &mask) < 0) { |
| 145 |
perror("VT_GETHIFONTMASK"); |
| 146 |
exit(EXIT_FAILURE); |
| 147 |
} |
| 148 |
(void) close(fd); |
| 149 |
fd = open(device, O_RDWR); |
| 150 |
if (fd < 0) { |
| 151 |
perror(device); |
| 152 |
exit(EXIT_FAILURE); |
| 153 |
} |
| 154 |
(void) read(fd, &scrn, 4); |
| 155 |
(void) lseek(fd, 4 + 2*(scrn.y*scrn.cols + scrn.x), SEEK_SET); |
| 156 |
(void) read(fd, &s, 2); |
| 157 |
ch = s & 0xff; |
| 158 |
if (s & mask) |
| 159 |
ch |= 0x100; |
| 160 |
attrib = ((s & \[ti]mask) >> 8); |
| 161 |
printf("ch=%#03x attrib=%#02x\[rs]n", ch, attrib); |
| 162 |
s \[ha]= 0x1000; |
| 163 |
(void) lseek(fd, \-2, SEEK_CUR); |
| 164 |
(void) write(fd, &s, 2); |
| 165 |
exit(EXIT_SUCCESS); |
| 166 |
} |
| 167 |
.EE |
| 168 |
.SH SEE ALSO |
| 169 |
.BR ioctl_console (2), |
| 170 |
.BR tty (4), |
| 171 |
.BR ttyS (4), |
| 172 |
.BR gpm (8) |