]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man4/vcs.4
getent.1, _syscall.2, acct.2, adjtimex.2, bdflush.2, brk.2, cacheflush.2, getsid...
[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.\"
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
31vcs, 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
340, usually of mode 0644 and owner root.tty.
35It refers to the memory of the currently
fea681da
MK
36displayed virtual console terminal.
37.LP
8478ee02 38\fI/dev/vcs[1\-63]\fP are character devices for virtual console
fea681da 39terminals, they have major number 7 and minor number 1 to 63, usually
be7fff26
MK
40mode 0644 and owner root.tty.
41\fI/dev/vcsa[0\-63]\fP are the same, but
789b1721
MK
42using
43.IR "unsigned short" s
44(in host byte order) that include attributes,
a0d4bc1f 45and prefixed with four bytes giving the screen
fea681da
MK
46dimensions 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
49When a 512-character font is loaded,
9fb1e24a 50the 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)
54on \fI/dev/tty[1\-63]\fP;
55the value is returned in the
56.I "unsigned short"
57pointed to by the third
58.BR ioctl (2)
59argument.
fea681da 60.PP
a0d4bc1f
MK
61These devices replace the screendump
62.BR ioctl (2)
63operations of
60a90ecd
MK
64.BR console (4),
65so the system
fea681da
MK
66administrator can control access using file system permissions.
67.PP
68The 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
78No
79.BR ioctl (2)
80requests 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
88Introduced with version 1.1.92 of the Linux kernel.
9b336505 89.SH EXAMPLE
c13182ef 90You may do a screendump on vt3 by switching to vt1 and typing
1c44bd5b
MK
91\fIcat /dev/vcs3 >foo\fP.
92Note that the output does not contain
fea681da 93newline characters, so some processing may be required, like
4d9b6984
MK
94in \fIfold \-w 81 /dev/vcs3 | lpr\fP or (horrors)
95\fIsetterm \-dump 3 \-file /proc/self/fd/1\fP.
fea681da
MK
96.LP
97The \fI/dev/vcsa0\fP device is used for Braille support.
98
99This program displays the character and screen attributes under the
100cursor of the second virtual console, then changes the background color
101there:
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
111int
112main(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)