1VCS(4)                     Linux Programmer's 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 of mode 0644 and owner root.tty.  It refers to  the  memory  of
11       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  owner  root.tty.  /dev/vcsa[0-63] are the same, but using unsigned
16       shorts (in host byte order) that include attributes, and prefixed  with
17       four  bytes  giving  the  screen dimensions and cursor position: lines,
18       columns, x, y.  (x = y = 0 at the top left corner of the screen.)
19
20       When a 512-character font is  loaded,  the  9th  bit  position  can  be
21       fetched  by applying the ioctl(2) VT_GETHIFONTMASK operation (available
22       in Linux kernels 2.6.18 and above)  on  /dev/tty[1-63];  the  value  is
23       returned  in  the unsigned short pointed to by the third ioctl(2) argu‐
24       ment.
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 version 1.1.92 of the Linux kernel.
46

EXAMPLE

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           xetterm -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 ch, attrib;
84
85           fd = open(console, O_RDWR);
86           if (fd < 0) {
87               perror(console);
88               exit(EXIT_FAILURE);
89           }
90           if (ioctl(fd, VT_GETHIFONTMASK, &mask) < 0) {
91               perror("VT_GETHIFONTMASK");
92               exit(EXIT_FAILURE);
93           }
94           (void) close(fd);
95           fd = open(device, O_RDWR);
96           if (fd < 0) {
97               perror(device);
98               exit(EXIT_FAILURE);
99           }
100           (void) read(fd, &scrn, 4);
101           (void) lseek(fd, 4 + 2*(scrn.y*scrn.cols + scrn.x), 0);
102           (void) read(fd, &s, 2);
103           ch = s & 0xff;
104           if (attrib & mask)
105               ch |= 0x100;
106           attrib = ((s & ~mask) >> 8);
107           printf("ch='%c' attrib=0x%02x\n", ch, attrib);
108           attrib ^= 0x10;
109           (void) lseek(fd, -1, 1);
110           (void) write(fd, &attrib, 1);
111           exit(EXIT_SUCCESS);
112       }
113

SEE ALSO

115       ioctl_console(2), tty(4), ttyS(4), gpm(8)
116

COLOPHON

118       This  page  is  part of release 4.15 of the Linux man-pages project.  A
119       description of the project, information about reporting bugs,  and  the
120       latest     version     of     this    page,    can    be    found    at
121       https://www.kernel.org/doc/man-pages/.
122
123
124
125Linux                             2017-05-03                            VCS(4)
Impressum