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