OSDN Git Service

8956b4ad2a512734d6e07dc2945a0dda3ad1f027
[linuxjm/LDP_man-pages.git] / original / man4 / vcs.4
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 2007-12-17 "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 of mode 0644 and owner root.tty.
36 It refers to the memory of the currently
37 displayed virtual console terminal.
38 .LP
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 owner 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
55 =
56 .I y
57 = 0 at the top left corner of the screen.)
58
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)
65 on
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 console (4),
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
82 .nf
83     for x in 0 1 2 3 4 5 6 7 8; do
84         mknod \-m 644 /dev/vcs$x c 7 $x;
85         mknod \-m 644 /dev/vcsa$x c 7 $[$x+128];
86     done
87     chown root:tty /dev/vcs*
88 .fi
89
90 No
91 .BR ioctl (2)
92 requests are supported.
93 .SH FILES
94 /dev/vcs[0\-63]
95 .br
96 /dev/vcsa[0\-63]
97 .\" .SH AUTHOR
98 .\" Andries Brouwer <aeb@cwi.nl>
99 .SH VERSIONS
100 Introduced with version 1.1.92 of the Linux kernel.
101 .SH EXAMPLE
102 You may do a screendump on vt3 by switching to vt1 and typing
103
104     cat /dev/vcs3 >foo
105
106 Note that the output does not contain
107 newline characters, so some processing may be required, like
108 in
109
110     old \-w 81 /dev/vcs3 | lpr
111
112 or (horrors)
113
114     xetterm \-dump 3 \-file /proc/self/fd/1
115
116 .LP
117 The
118 .I /dev/vcsa0
119 device is used for Braille support.
120
121 This program displays the character and screen attributes under the
122 cursor of the second virtual console, then changes the background color
123 there:
124
125 .nf
126 #include <unistd.h>
127 #include <stdlib.h>
128 #include <stdio.h>
129 #include <fcntl.h>
130 #include <sys/ioctl.h>
131 #include <linux/vt.h>
132
133 int
134 main(void)
135 {
136     int fd;
137     char *device = "/dev/vcsa2";
138     char *console = "/dev/tty2";
139     struct {unsigned char lines, cols, x, y;} scrn;
140     unsigned short s;
141     unsigned short mask;
142     unsigned char ch, attrib;
143
144     fd = open(console, O_RDWR);
145     if (fd < 0) {
146         perror(console);
147         exit(EXIT_FAILURE);
148     }
149     if (ioctl(fd, VT_GETHIFONTMASK, &mask) < 0) {
150         perror("VT_GETHIFONTMASK");
151         exit(EXIT_FAILURE);
152     }
153     (void) close(fd);
154     fd = open(device, O_RDWR);
155     if (fd < 0) {
156         perror(device);
157         exit(EXIT_FAILURE);
158     }
159     (void) read(fd, &scrn, 4);
160     (void) lseek(fd, 4 + 2*(scrn.y*scrn.cols + scrn.x), 0);
161     (void) read(fd, &s, 2);
162     ch = s & 0xff;
163     if (attrib & mask)
164         ch |= 0x100;
165     attrib = ((s & ~mask) >> 8);
166     printf("ch=\(aq%c\(aq attrib=0x%02x\\n", ch, attrib);
167     attrib ^= 0x10;
168     (void) lseek(fd, \-1, 1);
169     (void) write(fd, &attrib, 1);
170     exit(EXIT_SUCCESS);
171 }
172 .fi
173 .SH SEE ALSO
174 .BR console (4),
175 .BR tty (4),
176 .BR ttyS (4),
177 .BR gpm (8)
178 .SH COLOPHON
179 This page is part of release 3.64 of the Linux
180 .I man-pages
181 project.
182 A description of the project,
183 and information about reporting bugs,
184 can be found at
185 \%http://www.kernel.org/doc/man\-pages/.