]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man4/vcs.4
getent.1, iconv.1, ldd.1, locale.1, localedef.1, memusage.1, memusagestat.1, pldd...
[thirdparty/man-pages.git] / man4 / vcs.4
CommitLineData
fea681da
MK
1.\" Copyright (c) 1995 James R. Van Zandt <jrv@vanzandt.mv.com>
2.\" Sat Feb 18 09:11:07 EST 1995
3.\"
1dd72f9c 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.\" "
9ba01802 29.TH VCS 4 2019-03-06 "Linux" "Linux Programmer's Manual"
fea681da
MK
30.SH NAME
31vcs, vcsa \- virtual console memory
32.SH DESCRIPTION
42c3e947
MK
33.I /dev/vcs0
34is a character device with major number 7 and minor number
6f5b156b 350, usually with mode 0644 and ownership root:tty.
c13182ef 36It refers to the memory of the currently
fea681da 37displayed virtual console terminal.
dd3568a1 38.PP
42c3e947
MK
39.I /dev/vcs[1\-63]
40are character devices for virtual console
fea681da 41terminals, they have major number 7 and minor number 1 to 63, usually
6f5b156b 42mode 0644 and ownership root:tty.
42c3e947
MK
43.IR /dev/vcsa[0\-63]
44are the same, but
789b1721
MK
45using
46.IR "unsigned short" s
47(in host byte order) that include attributes,
a0d4bc1f 48and prefixed with four bytes giving the screen
42c3e947
MK
49dimensions 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.)
2dad4c59 58.PP
a0d4bc1f 59When a 512-character font is loaded,
9fb1e24a 60the 9th bit position can be fetched by applying the
a0d4bc1f 61.BR ioctl (2)
42c3e947
MK
62.B VT_GETHIFONTMASK
63operation
a0d4bc1f 64(available in Linux kernels 2.6.18 and above)
51700fd7 65on
42c3e947 66.IR /dev/tty[1\-63] ;
a0d4bc1f
MK
67the value is returned in the
68.I "unsigned short"
69pointed to by the third
70.BR ioctl (2)
71argument.
fea681da 72.PP
a0d4bc1f
MK
73These devices replace the screendump
74.BR ioctl (2)
75operations of
d49a2220 76.BR ioctl_console (2),
60a90ecd 77so the system
9ee4a2b6 78administrator can control access using filesystem permissions.
fea681da
MK
79.PP
80The devices for the first eight virtual consoles may be created by:
2dad4c59 81.PP
010c75a2
MK
82.in +4n
83.EX
84for 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];
87done
88chown root:tty /dev/vcs*
89.EE
90.in
2dad4c59 91.PP
a8abc303
MK
92No
93.BR ioctl (2)
94requests are supported.
2b2581ee 95.SH FILES
f8327f60 96.I /dev/vcs[0\-63]
2b2581ee 97.br
f8327f60 98.I /dev/vcsa[0\-63]
d2dc6294
MK
99.\" .SH AUTHOR
100.\" Andries Brouwer <aeb@cwi.nl>
2b2581ee
MK
101.SH VERSIONS
102Introduced with version 1.1.92 of the Linux kernel.
9b336505 103.SH EXAMPLE
c13182ef 104You may do a screendump on vt3 by switching to vt1 and typing
2dad4c59 105.PP
42c3e947 106 cat /dev/vcs3 >foo
2dad4c59 107.PP
1c44bd5b 108Note that the output does not contain
fea681da 109newline characters, so some processing may be required, like
42c3e947 110in
2dad4c59 111.PP
b8a38e27 112 fold \-w 81 /dev/vcs3 | lpr
2dad4c59 113.PP
42c3e947 114or (horrors)
2dad4c59 115.PP
42c3e947 116 xetterm \-dump 3 \-file /proc/self/fd/1
2dad4c59 117.PP
42c3e947
MK
118The
119.I /dev/vcsa0
120device is used for Braille support.
2dad4c59 121.PP
fea681da
MK
122This program displays the character and screen attributes under the
123cursor of the second virtual console, then changes the background color
124there:
2dad4c59 125.PP
010c75a2 126.EX
cf0a9ace
MK
127#include <unistd.h>
128#include <stdlib.h>
129#include <stdio.h>
130#include <fcntl.h>
a0d4bc1f
MK
131#include <sys/ioctl.h>
132#include <linux/vt.h>
fea681da 133
c13182ef
MK
134int
135main(void)
cf0a9ace
MK
136{
137 int fd;
138 char *device = "/dev/vcsa2";
a0d4bc1f 139 char *console = "/dev/tty2";
cf0a9ace 140 struct {unsigned char lines, cols, x, y;} scrn;
a0d4bc1f
MK
141 unsigned short s;
142 unsigned short mask;
40b1bfaa
ME
143 unsigned char attrib;
144 int ch;
fea681da 145
a0d4bc1f
MK
146 fd = open(console, O_RDWR);
147 if (fd < 0) {
148 perror(console);
149 exit(EXIT_FAILURE);
150 }
151 if (ioctl(fd, VT_GETHIFONTMASK, &mask) < 0) {
152 perror("VT_GETHIFONTMASK");
153 exit(EXIT_FAILURE);
154 }
155 (void) close(fd);
cf0a9ace
MK
156 fd = open(device, O_RDWR);
157 if (fd < 0) {
158 perror(device);
c961c636 159 exit(EXIT_FAILURE);
9b336505 160 }
cf0a9ace 161 (void) read(fd, &scrn, 4);
40b1bfaa 162 (void) lseek(fd, 4 + 2*(scrn.y*scrn.cols + scrn.x), SEEK_SET);
a0d4bc1f
MK
163 (void) read(fd, &s, 2);
164 ch = s & 0xff;
40b1bfaa 165 if (s & mask)
a0d4bc1f
MK
166 ch |= 0x100;
167 attrib = ((s & ~mask) >> 8);
d1a71985 168 printf("ch=0x%03x attrib=0x%02x\en", ch, attrib);
40b1bfaa
ME
169 s ^= 0x1000;
170 (void) lseek(fd, \-2, SEEK_CUR);
171 (void) write(fd, &s, 2);
5bc8c34c 172 exit(EXIT_SUCCESS);
cf0a9ace 173}
010c75a2 174.EE
47297adb 175.SH SEE ALSO
d49a2220 176.BR ioctl_console (2),
fea681da 177.BR tty (4),
5278b416
MK
178.BR ttyS (4),
179.BR gpm (8)