]>
Commit | Line | Data |
---|---|---|
fea681da MK |
1 | .\" Copyright (c) 1995 James R. Van Zandt <jrv@vanzandt.mv.com> |
2 | .\" Sat Feb 18 09:11:07 EST 1995 | |
3 | .\" | |
6a8d8745 | 4 | .\" %%%LICENSE_START(GPLv2+_doc_full) |
fea681da MK |
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 | |
c715f741 MK |
21 | .\" License along with this manual; if not, see |
22 | .\" <http://www.gnu.org/licenses/>. | |
6a8d8745 | 23 | .\" %%%LICENSE_END |
fea681da MK |
24 | .\" |
25 | .\" Modified, Sun Feb 26 15:08:05 1995, faith@cs.unc.edu | |
a0d4bc1f MK |
26 | .\" 2007-12-17, Samuel Thibault <samuel.thibault@ens-lyon.org>: |
27 | .\" document the VT_GETHIFONTMASK ioctl | |
fea681da | 28 | .\" " |
a0d4bc1f | 29 | .TH VCS 4 2007-12-17 "Linux" "Linux Programmer's Manual" |
fea681da MK |
30 | .SH NAME |
31 | vcs, vcsa \- virtual console memory | |
32 | .SH DESCRIPTION | |
8478ee02 | 33 | \fI/dev/vcs0\fP is a character device with major number 7 and minor number |
c13182ef MK |
34 | 0, usually of mode 0644 and owner root.tty. |
35 | It refers to the memory of the currently | |
fea681da MK |
36 | displayed virtual console terminal. |
37 | .LP | |
8478ee02 | 38 | \fI/dev/vcs[1\-63]\fP are character devices for virtual console |
fea681da | 39 | terminals, they have major number 7 and minor number 1 to 63, usually |
be7fff26 MK |
40 | mode 0644 and owner root.tty. |
41 | \fI/dev/vcsa[0\-63]\fP are the same, but | |
789b1721 MK |
42 | using |
43 | .IR "unsigned short" s | |
44 | (in host byte order) that include attributes, | |
a0d4bc1f | 45 | and prefixed with four bytes giving the screen |
fea681da MK |
46 | dimensions and cursor position: \fIlines\fP, \fIcolumns\fP, \fIx\fP, \fIy\fP. |
47 | (\fIx\fP = \fIy\fP = 0 at the top left corner of the screen.) | |
a0d4bc1f MK |
48 | |
49 | When a 512-character font is loaded, | |
9fb1e24a | 50 | the 9th bit position can be fetched by applying the |
a0d4bc1f MK |
51 | .BR ioctl (2) |
52 | \fBVT_GETHIFONTMASK\fP operation | |
53 | (available in Linux kernels 2.6.18 and above) | |
54 | on \fI/dev/tty[1\-63]\fP; | |
55 | the value is returned in the | |
56 | .I "unsigned short" | |
57 | pointed to by the third | |
58 | .BR ioctl (2) | |
59 | argument. | |
fea681da | 60 | .PP |
a0d4bc1f MK |
61 | These devices replace the screendump |
62 | .BR ioctl (2) | |
63 | operations of | |
60a90ecd MK |
64 | .BR console (4), |
65 | so the system | |
fea681da MK |
66 | administrator can control access using file system permissions. |
67 | .PP | |
68 | The devices for the first eight virtual consoles may be created by: | |
69 | ||
70 | .nf | |
c13182ef | 71 | for x in 0 1 2 3 4 5 6 7 8; do |
9b336505 MK |
72 | mknod \-m 644 /dev/vcs$x c 7 $x; |
73 | mknod \-m 644 /dev/vcsa$x c 7 $[$x+128]; | |
74 | done | |
75 | chown root:tty /dev/vcs* | |
fea681da | 76 | .fi |
a8abc303 MK |
77 | |
78 | No | |
79 | .BR ioctl (2) | |
80 | requests are supported. | |
2b2581ee MK |
81 | .SH FILES |
82 | /dev/vcs[0\-63] | |
83 | .br | |
84 | /dev/vcsa[0\-63] | |
d2dc6294 MK |
85 | .\" .SH AUTHOR |
86 | .\" Andries Brouwer <aeb@cwi.nl> | |
2b2581ee MK |
87 | .SH VERSIONS |
88 | Introduced with version 1.1.92 of the Linux kernel. | |
9b336505 | 89 | .SH EXAMPLE |
c13182ef | 90 | You may do a screendump on vt3 by switching to vt1 and typing |
1c44bd5b MK |
91 | \fIcat /dev/vcs3 >foo\fP. |
92 | Note that the output does not contain | |
fea681da | 93 | newline characters, so some processing may be required, like |
4d9b6984 MK |
94 | in \fIfold \-w 81 /dev/vcs3 | lpr\fP or (horrors) |
95 | \fIsetterm \-dump 3 \-file /proc/self/fd/1\fP. | |
fea681da MK |
96 | .LP |
97 | The \fI/dev/vcsa0\fP device is used for Braille support. | |
98 | ||
99 | This program displays the character and screen attributes under the | |
100 | cursor of the second virtual console, then changes the background color | |
101 | there: | |
102 | ||
103 | .nf | |
cf0a9ace MK |
104 | #include <unistd.h> |
105 | #include <stdlib.h> | |
106 | #include <stdio.h> | |
107 | #include <fcntl.h> | |
a0d4bc1f MK |
108 | #include <sys/ioctl.h> |
109 | #include <linux/vt.h> | |
fea681da | 110 | |
c13182ef MK |
111 | int |
112 | main(void) | |
cf0a9ace MK |
113 | { |
114 | int fd; | |
115 | char *device = "/dev/vcsa2"; | |
a0d4bc1f | 116 | char *console = "/dev/tty2"; |
cf0a9ace | 117 | struct {unsigned char lines, cols, x, y;} scrn; |
a0d4bc1f MK |
118 | unsigned short s; |
119 | unsigned short mask; | |
120 | unsigned char ch, attrib; | |
fea681da | 121 | |
a0d4bc1f MK |
122 | fd = open(console, O_RDWR); |
123 | if (fd < 0) { | |
124 | perror(console); | |
125 | exit(EXIT_FAILURE); | |
126 | } | |
127 | if (ioctl(fd, VT_GETHIFONTMASK, &mask) < 0) { | |
128 | perror("VT_GETHIFONTMASK"); | |
129 | exit(EXIT_FAILURE); | |
130 | } | |
131 | (void) close(fd); | |
cf0a9ace MK |
132 | fd = open(device, O_RDWR); |
133 | if (fd < 0) { | |
134 | perror(device); | |
c961c636 | 135 | exit(EXIT_FAILURE); |
9b336505 | 136 | } |
cf0a9ace MK |
137 | (void) read(fd, &scrn, 4); |
138 | (void) lseek(fd, 4 + 2*(scrn.y*scrn.cols + scrn.x), 0); | |
a0d4bc1f MK |
139 | (void) read(fd, &s, 2); |
140 | ch = s & 0xff; | |
141 | if (attrib & mask) | |
142 | ch |= 0x100; | |
143 | attrib = ((s & ~mask) >> 8); | |
f81fb444 | 144 | printf("ch=\(aq%c\(aq attrib=0x%02x\\n", ch, attrib); |
cf0a9ace MK |
145 | attrib ^= 0x10; |
146 | (void) lseek(fd, \-1, 1); | |
147 | (void) write(fd, &attrib, 1); | |
5bc8c34c | 148 | exit(EXIT_SUCCESS); |
cf0a9ace | 149 | } |
fea681da | 150 | .fi |
47297adb | 151 | .SH SEE ALSO |
fea681da MK |
152 | .BR console (4), |
153 | .BR tty (4), | |
5278b416 MK |
154 | .BR ttyS (4), |
155 | .BR gpm (8) |