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

SEE ALSO

107       console(4), tty(4), ttyS(4), gpm(8)
108

COLOPHON

110       This  page  is  part of release 3.22 of the Linux man-pages project.  A
111       description of the project, and information about reporting  bugs,  can
112       be found at http://www.kernel.org/doc/man-pages/.
113
114
115
116Linux                             2007-12-17                            VCS(4)
Impressum