malloc.3: Clarify that realloc() may move the memory block
[man-pages.git] / man4 / vcs.4
blob827798130db7a084ce24ec1f0e7d9265c146fdd0
1 .\" Copyright (c) 1995 James R. Van Zandt <jrv@vanzandt.mv.com>
2 .\" Sat Feb 18 09:11:07 EST 1995
3 .\"
4 .\" %%%LICENSE_START(GPLv2+_DOC_FULL)
5 .\" This is free documentation; you can redistribute it and/or
6 .\" modify it under the terms of the GNU General Public License as
7 .\" published by the Free Software Foundation; either version 2 of
8 .\" the License, or (at your option) any later version.
9 .\"
10 .\" The GNU General Public License's references to "object code"
11 .\" and "executables" are to be interpreted as the output of any
12 .\" document formatting or typesetting system, including
13 .\" intermediate and printed output.
14 .\"
15 .\" This manual is distributed in the hope that it will be useful,
16 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
17 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 .\" GNU General Public License for more details.
19 .\"
20 .\" You should have received a copy of the GNU General Public
21 .\" License along with this manual; if not, see
22 .\" <http://www.gnu.org/licenses/>.
23 .\" %%%LICENSE_END
24 .\"
25 .\" Modified, Sun Feb 26 15:08:05 1995, faith@cs.unc.edu
26 .\" 2007-12-17, Samuel Thibault <samuel.thibault@ens-lyon.org>:
27 .\"     document the VT_GETHIFONTMASK ioctl
28 .\" "
29 .TH VCS 4 2020-11-01 "Linux" "Linux Programmer's Manual"
30 .SH NAME
31 vcs, vcsa \- virtual console memory
32 .SH DESCRIPTION
33 .I /dev/vcs0
34 is a character device with major number 7 and minor number
35 0, usually with mode 0644 and ownership root:tty.
36 It refers to the memory of the currently
37 displayed virtual console terminal.
38 .PP
39 .I /dev/vcs[1\-63]
40 are character devices for virtual console
41 terminals, they have major number 7 and minor number 1 to 63, usually
42 mode 0644 and ownership root:tty.
43 .IR /dev/vcsa[0\-63]
44 are the same, but
45 using
46 .IR "unsigned short" s
47 (in host byte order) that include attributes,
48 and prefixed with four bytes giving the screen
49 dimensions and cursor position:
50 .IR lines ,
51 .IR columns ,
52 .IR x ,
53 .IR y .
54 .RI ( x
56 .I y
57 = 0 at the top left corner of the screen.)
58 .PP
59 When a 512-character font is loaded,
60 the 9th bit position can be fetched by applying the
61 .BR ioctl (2)
62 .B VT_GETHIFONTMASK
63 operation
64 (available in Linux kernels 2.6.18 and above)
66 .IR /dev/tty[1\-63] ;
67 the value is returned in the
68 .I "unsigned short"
69 pointed to by the third
70 .BR ioctl (2)
71 argument.
72 .PP
73 These devices replace the screendump
74 .BR ioctl (2)
75 operations of
76 .BR ioctl_console (2),
77 so the system
78 administrator can control access using filesystem permissions.
79 .PP
80 The devices for the first eight virtual consoles may be created by:
81 .PP
82 .in +4n
83 .EX
84 for x in 0 1 2 3 4 5 6 7 8; do
85     mknod \-m 644 /dev/vcs$x c 7 $x;
86     mknod \-m 644 /dev/vcsa$x c 7 $[$x+128];
87 done
88 chown root:tty /dev/vcs*
89 .EE
90 .in
91 .PP
93 .BR ioctl (2)
94 requests are supported.
95 .SH FILES
96 .I /dev/vcs[0\-63]
97 .br
98 .I /dev/vcsa[0\-63]
99 .\" .SH AUTHOR
100 .\" Andries Brouwer <aeb@cwi.nl>
101 .SH VERSIONS
102 Introduced with version 1.1.92 of the Linux kernel.
103 .SH EXAMPLES
104 You may do a screendump on vt3 by switching to vt1 and typing
106 .in +4n
108 cat /dev/vcs3 >foo
112 Note that the output does not contain
113 newline characters, so some processing may be required, like
116 .in +4n
118 fold \-w 81 /dev/vcs3 | lpr
122 or (horrors)
124 .in +4n
126 setterm \-dump 3 \-file /proc/self/fd/1
131 .I /dev/vcsa0
132 device is used for Braille support.
134 This program displays the character and screen attributes under the
135 cursor of the second virtual console, then changes the background color
136 there:
139 #include <unistd.h>
140 #include <stdlib.h>
141 #include <stdio.h>
142 #include <fcntl.h>
143 #include <sys/ioctl.h>
144 #include <linux/vt.h>
147 main(void)
149     int fd;
150     char *device = "/dev/vcsa2";
151     char *console = "/dev/tty2";
152     struct {unsigned char lines, cols, x, y;} scrn;
153     unsigned short s;
154     unsigned short mask;
155     unsigned char attrib;
156     int ch;
158     fd = open(console, O_RDWR);
159     if (fd < 0) {
160         perror(console);
161         exit(EXIT_FAILURE);
162     }
163     if (ioctl(fd, VT_GETHIFONTMASK, &mask) < 0) {
164         perror("VT_GETHIFONTMASK");
165         exit(EXIT_FAILURE);
166     }
167     (void) close(fd);
168     fd = open(device, O_RDWR);
169     if (fd < 0) {
170         perror(device);
171         exit(EXIT_FAILURE);
172     }
173     (void) read(fd, &scrn, 4);
174     (void) lseek(fd, 4 + 2*(scrn.y*scrn.cols + scrn.x), SEEK_SET);
175     (void) read(fd, &s, 2);
176     ch = s & 0xff;
177     if (s & mask)
178         ch |= 0x100;
179     attrib = ((s & \(timask) >> 8);
180     printf("ch=%#03x attrib=%#02x\en", ch, attrib);
181     s \(ha= 0x1000;
182     (void) lseek(fd, \-2, SEEK_CUR);
183     (void) write(fd, &s, 2);
184     exit(EXIT_SUCCESS);
187 .SH SEE ALSO
188 .BR ioctl_console (2),
189 .BR tty (4),
190 .BR ttyS (4),
191 .BR gpm (8)