]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man4/vcs.4
dsp56k.4: ffix
[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
1765a0b0
MK
106.in +4n
107.EX
108cat /dev/vcs3 >foo
109.EE
110.in
2dad4c59 111.PP
1c44bd5b 112Note that the output does not contain
fea681da 113newline characters, so some processing may be required, like
42c3e947 114in
2dad4c59 115.PP
1765a0b0
MK
116.in +4n
117.EX
118fold \-w 81 /dev/vcs3 | lpr
119.EE
120.in
2dad4c59 121.PP
42c3e947 122or (horrors)
2dad4c59 123.PP
1765a0b0
MK
124.in +4n
125.EX
126setterm \-dump 3 \-file /proc/self/fd/1
127.EE
128.in
2dad4c59 129.PP
42c3e947
MK
130The
131.I /dev/vcsa0
132device is used for Braille support.
2dad4c59 133.PP
fea681da
MK
134This program displays the character and screen attributes under the
135cursor of the second virtual console, then changes the background color
136there:
2dad4c59 137.PP
010c75a2 138.EX
cf0a9ace
MK
139#include <unistd.h>
140#include <stdlib.h>
141#include <stdio.h>
142#include <fcntl.h>
a0d4bc1f
MK
143#include <sys/ioctl.h>
144#include <linux/vt.h>
fea681da 145
c13182ef
MK
146int
147main(void)
cf0a9ace
MK
148{
149 int fd;
150 char *device = "/dev/vcsa2";
a0d4bc1f 151 char *console = "/dev/tty2";
cf0a9ace 152 struct {unsigned char lines, cols, x, y;} scrn;
a0d4bc1f
MK
153 unsigned short s;
154 unsigned short mask;
40b1bfaa
ME
155 unsigned char attrib;
156 int ch;
fea681da 157
a0d4bc1f
MK
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);
cf0a9ace
MK
168 fd = open(device, O_RDWR);
169 if (fd < 0) {
170 perror(device);
c961c636 171 exit(EXIT_FAILURE);
9b336505 172 }
cf0a9ace 173 (void) read(fd, &scrn, 4);
40b1bfaa 174 (void) lseek(fd, 4 + 2*(scrn.y*scrn.cols + scrn.x), SEEK_SET);
a0d4bc1f
MK
175 (void) read(fd, &s, 2);
176 ch = s & 0xff;
40b1bfaa 177 if (s & mask)
a0d4bc1f
MK
178 ch |= 0x100;
179 attrib = ((s & ~mask) >> 8);
d1a71985 180 printf("ch=0x%03x attrib=0x%02x\en", ch, attrib);
40b1bfaa
ME
181 s ^= 0x1000;
182 (void) lseek(fd, \-2, SEEK_CUR);
183 (void) write(fd, &s, 2);
5bc8c34c 184 exit(EXIT_SUCCESS);
cf0a9ace 185}
010c75a2 186.EE
47297adb 187.SH SEE ALSO
d49a2220 188.BR ioctl_console (2),
fea681da 189.BR tty (4),
5278b416
MK
190.BR ttyS (4),
191.BR gpm (8)