1vcs(4)                     Kernel Interfaces Manual                     vcs(4)
2
3
4

NAME

6       vcs, vcsa - virtual console memory
7

DESCRIPTION

9       /dev/vcs0 is a character device with major number 7 and minor number 0,
10       usually with mode 0644 and ownership root:tty.  It refers to the memory
11       of the currently displayed virtual console terminal.
12
13       /dev/vcs[1-63]  are  character  devices  for virtual console terminals,
14       they have major number 7 and minor number 1 to 63,  usually  mode  0644
15       and  ownership  root:tty.   /dev/vcsa[0-63] are the same, but using un‐
16       signed shorts (in host byte order) that include  attributes,  and  pre‐
17       fixed with four bytes giving the screen dimensions and cursor position:
18       lines, columns, x, y.  (x = y =  0  at  the  top  left  corner  of  the
19       screen.)
20
21       When  a  512-character  font  is  loaded,  the  9th bit position can be
22       fetched by applying the ioctl(2) VT_GETHIFONTMASK operation  (available
23       since Linux 2.6.18) on /dev/tty[1-63]; the value is returned in the un‐
24       signed short pointed to by the third ioctl(2) argument.
25
26       These devices replace the screendump ioctl(2) operations of  ioctl_con‐
27       sole(2),  so the system administrator can control access using filesys‐
28       tem permissions.
29
30       The devices for the first eight virtual consoles may be created by:
31
32           for x in 0 1 2 3 4 5 6 7 8; do
33               mknod -m 644 /dev/vcs$x c 7 $x;
34               mknod -m 644 /dev/vcsa$x c 7 $[$x+128];
35           done
36           chown root:tty /dev/vcs*
37
38       No ioctl(2) requests are supported.
39

FILES

41       /dev/vcs[0-63]
42       /dev/vcsa[0-63]
43

VERSIONS

45       Introduced with Linux 1.1.92.
46

EXAMPLES

48       You may do a screendump on vt3 by switching to vt1 and typing
49
50           cat /dev/vcs3 >foo
51
52       Note that the output does not contain newline characters, so some  pro‐
53       cessing may be required, like in
54
55           fold -w 81 /dev/vcs3 | lpr
56
57       or (horrors)
58
59           setterm -dump 3 -file /proc/self/fd/1
60
61       The /dev/vcsa0 device is used for Braille support.
62
63       This  program  displays  the  character and screen attributes under the
64       cursor of the second virtual console, then changes the background color
65       there:
66
67       #include <unistd.h>
68       #include <stdlib.h>
69       #include <stdio.h>
70       #include <fcntl.h>
71       #include <sys/ioctl.h>
72       #include <linux/vt.h>
73
74       int
75       main(void)
76       {
77           int fd;
78           char *device = "/dev/vcsa2";
79           char *console = "/dev/tty2";
80           struct {unsigned char lines, cols, x, y;} scrn;
81           unsigned short s;
82           unsigned short mask;
83           unsigned char attrib;
84           int ch;
85
86           fd = open(console, O_RDWR);
87           if (fd < 0) {
88               perror(console);
89               exit(EXIT_FAILURE);
90           }
91           if (ioctl(fd, VT_GETHIFONTMASK, &mask) < 0) {
92               perror("VT_GETHIFONTMASK");
93               exit(EXIT_FAILURE);
94           }
95           (void) close(fd);
96           fd = open(device, O_RDWR);
97           if (fd < 0) {
98               perror(device);
99               exit(EXIT_FAILURE);
100           }
101           (void) read(fd, &scrn, 4);
102           (void) lseek(fd, 4 + 2*(scrn.y*scrn.cols + scrn.x), SEEK_SET);
103           (void) read(fd, &s, 2);
104           ch = s & 0xff;
105           if (s & mask)
106               ch |= 0x100;
107           attrib = ((s & ~mask) >> 8);
108           printf("ch=%#03x attrib=%#02x\n", ch, attrib);
109           s ^= 0x1000;
110           (void) lseek(fd, -2, SEEK_CUR);
111           (void) write(fd, &s, 2);
112           exit(EXIT_SUCCESS);
113       }
114

SEE ALSO

116       ioctl_console(2), tty(4), ttyS(4), gpm(8)
117
118
119
120Linux man-pages 6.05              2023-05-03                            vcs(4)
Impressum