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 console(4),
27       so  the  system administrator can control access using file system per‐
28       missions.
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           old -w 81 /dev/vcs3 | lpr
56
57       or (horrors)
58
59           xetterm -dump 3 -file /proc/self/fd/1
60
61
62       The /dev/vcsa0 device is used for Braille support.
63
64       This  program  displays  the  character and screen attributes under the
65       cursor of the second virtual console, then changes the background color
66       there:
67
68       #include <unistd.h>
69       #include <stdlib.h>
70       #include <stdio.h>
71       #include <fcntl.h>
72       #include <sys/ioctl.h>
73       #include <linux/vt.h>
74
75       int
76       main(void)
77       {
78           int fd;
79           char *device = "/dev/vcsa2";
80           char *console = "/dev/tty2";
81           struct {unsigned char lines, cols, x, y;} scrn;
82           unsigned short s;
83           unsigned short mask;
84           unsigned char ch, attrib;
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), 0);
103           (void) read(fd, &s, 2);
104           ch = s & 0xff;
105           if (attrib & mask)
106               ch |= 0x100;
107           attrib = ((s & ~mask) >> 8);
108           printf("ch='%c' attrib=0x%02x\n", ch, attrib);
109           attrib ^= 0x10;
110           (void) lseek(fd, -1, 1);
111           (void) write(fd, &attrib, 1);
112           exit(EXIT_SUCCESS);
113       }
114

SEE ALSO

116       console(4), tty(4), ttyS(4), gpm(8)
117

COLOPHON

119       This  page  is  part of release 3.53 of the Linux man-pages project.  A
120       description of the project, and information about reporting  bugs,  can
121       be found at http://www.kernel.org/doc/man-pages/.
122
123
124
125Linux                             2007-12-17                            VCS(4)
Impressum