OSDN Git Service

(split) Import translated manuals from JM CVS Repository.
[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 .\" This is free documentation; you can redistribute it and/or
5 .\" modify it under the terms of the GNU General Public License as
6 .\" published by the Free Software Foundation; either version 2 of
7 .\" the License, or (at your option) any later version.
8 .\"
9 .\" The GNU General Public License's references to "object code"
10 .\" and "executables" are to be interpreted as the output of any
11 .\" document formatting or typesetting system, including
12 .\" intermediate and printed output.
13 .\"
14 .\" This manual is distributed in the hope that it will be useful,
15 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
16 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 .\" GNU General Public License for more details.
18 .\"
19 .\" You should have received a copy of the GNU General Public
20 .\" License along with this manual; if not, write to the Free
21 .\" Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111,
22 .\" USA.
23 .\"
24 .\" Modified, Sun Feb 26 15:08:05 1995, faith@cs.unc.edu
25 .\" 2007-12-17, Samuel Thibault <samuel.thibault@ens-lyon.org>:
26 .\"     document the VT_GETHIFONTMASK ioctl
27 .\" "
28 .TH VCS 4 2007-12-17 "Linux" "Linux Programmer's Manual"
29 .SH NAME
30 vcs, vcsa \- virtual console memory
31 .SH DESCRIPTION
32 \fI/dev/vcs0\fP is a character device with major number 7 and minor number
33 0, usually of mode 0644 and owner root.tty.
34 It refers to the memory of the currently
35 displayed virtual console terminal.
36 .LP
37 \fI/dev/vcs[1\-63]\fP are character devices for virtual console
38 terminals, they have major number 7 and minor number 1 to 63, usually
39 mode 0644 and owner root.tty.
40 \fI/dev/vcsa[0\-63]\fP are the same, but
41 using
42 .IR "unsigned short" s
43 (in host byte order) that include attributes,
44 and prefixed with four bytes giving the screen
45 dimensions and cursor position: \fIlines\fP, \fIcolumns\fP, \fIx\fP, \fIy\fP.
46 (\fIx\fP = \fIy\fP = 0 at the top left corner of the screen.)
47
48 When a 512-character font is loaded,
49 the 9th bit position can be fetched by applying the
50 .BR ioctl (2)
51 \fBVT_GETHIFONTMASK\fP operation
52 (available in Linux kernels 2.6.18 and above)
53 on \fI/dev/tty[1\-63]\fP;
54 the value is returned in the
55 .I "unsigned short"
56 pointed to by the third
57 .BR ioctl (2)
58 argument.
59 .PP
60 These devices replace the screendump
61 .BR ioctl (2)
62 operations of
63 .BR console (4),
64 so the system
65 administrator can control access using file system permissions.
66 .PP
67 The devices for the first eight virtual consoles may be created by:
68
69 .nf
70     for x in 0 1 2 3 4 5 6 7 8; do
71         mknod \-m 644 /dev/vcs$x c 7 $x;
72         mknod \-m 644 /dev/vcsa$x c 7 $[$x+128];
73     done
74     chown root:tty /dev/vcs*
75 .fi
76
77 No
78 .BR ioctl (2)
79 requests are supported.
80 .SH FILES
81 /dev/vcs[0\-63]
82 .br
83 /dev/vcsa[0\-63]
84 .\" .SH AUTHOR
85 .\" Andries Brouwer <aeb@cwi.nl>
86 .SH VERSIONS
87 Introduced with version 1.1.92 of the Linux kernel.
88 .SH EXAMPLE
89 You may do a screendump on vt3 by switching to vt1 and typing
90 \fIcat /dev/vcs3 >foo\fP.
91 Note that the output does not contain
92 newline characters, so some processing may be required, like
93 in \fIfold \-w 81 /dev/vcs3 | lpr\fP or (horrors)
94 \fIsetterm \-dump 3 \-file /proc/self/fd/1\fP.
95 .LP
96 The \fI/dev/vcsa0\fP device is used for Braille support.
97
98 This program displays the character and screen attributes under the
99 cursor of the second virtual console, then changes the background color
100 there:
101
102 .nf
103 #include <unistd.h>
104 #include <stdlib.h>
105 #include <stdio.h>
106 #include <fcntl.h>
107 #include <sys/ioctl.h>
108 #include <linux/vt.h>
109
110 int
111 main(void)
112 {
113     int fd;
114     char *device = "/dev/vcsa2";
115     char *console = "/dev/tty2";
116     struct {unsigned char lines, cols, x, y;} scrn;
117     unsigned short s;
118     unsigned short mask;
119     unsigned char ch, attrib;
120
121     fd = open(console, O_RDWR);
122     if (fd < 0) {
123         perror(console);
124         exit(EXIT_FAILURE);
125     }
126     if (ioctl(fd, VT_GETHIFONTMASK, &mask) < 0) {
127         perror("VT_GETHIFONTMASK");
128         exit(EXIT_FAILURE);
129     }
130     (void) close(fd);
131     fd = open(device, O_RDWR);
132     if (fd < 0) {
133         perror(device);
134         exit(EXIT_FAILURE);
135     }
136     (void) read(fd, &scrn, 4);
137     (void) lseek(fd, 4 + 2*(scrn.y*scrn.cols + scrn.x), 0);
138     (void) read(fd, &s, 2);
139     ch = s & 0xff;
140     if (attrib & mask)
141         ch |= 0x100;
142     attrib = ((s & ~mask) >> 8);
143     printf("ch=\(aq%c\(aq attrib=0x%02x\\n", ch, attrib);
144     attrib ^= 0x10;
145     (void) lseek(fd, \-1, 1);
146     (void) write(fd, &attrib, 1);
147     exit(EXIT_SUCCESS);
148 }
149 .fi
150 .SH "SEE ALSO"
151 .BR console (4),
152 .BR tty (4),
153 .BR ttyS (4),
154 .BR gpm (8)