Blame man4/vcs.4

Packit 7cfc04
.\" Copyright (c) 1995 James R. Van Zandt <jrv@vanzandt.mv.com>
Packit 7cfc04
.\" Sat Feb 18 09:11:07 EST 1995
Packit 7cfc04
.\"
Packit 7cfc04
.\" %%%LICENSE_START(GPLv2+_DOC_FULL)
Packit 7cfc04
.\" This is free documentation; you can redistribute it and/or
Packit 7cfc04
.\" modify it under the terms of the GNU General Public License as
Packit 7cfc04
.\" published by the Free Software Foundation; either version 2 of
Packit 7cfc04
.\" the License, or (at your option) any later version.
Packit 7cfc04
.\"
Packit 7cfc04
.\" The GNU General Public License's references to "object code"
Packit 7cfc04
.\" and "executables" are to be interpreted as the output of any
Packit 7cfc04
.\" document formatting or typesetting system, including
Packit 7cfc04
.\" intermediate and printed output.
Packit 7cfc04
.\"
Packit 7cfc04
.\" This manual is distributed in the hope that it will be useful,
Packit 7cfc04
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 7cfc04
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 7cfc04
.\" GNU General Public License for more details.
Packit 7cfc04
.\"
Packit 7cfc04
.\" You should have received a copy of the GNU General Public
Packit 7cfc04
.\" License along with this manual; if not, see
Packit 7cfc04
.\" <http://www.gnu.org/licenses/>.
Packit 7cfc04
.\" %%%LICENSE_END
Packit 7cfc04
.\"
Packit 7cfc04
.\" Modified, Sun Feb 26 15:08:05 1995, faith@cs.unc.edu
Packit 7cfc04
.\" 2007-12-17, Samuel Thibault <samuel.thibault@ens-lyon.org>:
Packit 7cfc04
.\"     document the VT_GETHIFONTMASK ioctl
Packit 7cfc04
.\" "
Packit 7cfc04
.TH VCS 4 2017-05-03 "Linux" "Linux Programmer's Manual"
Packit 7cfc04
.SH NAME
Packit 7cfc04
vcs, vcsa \- virtual console memory
Packit 7cfc04
.SH DESCRIPTION
Packit 7cfc04
.I /dev/vcs0
Packit 7cfc04
is a character device with major number 7 and minor number
Packit 7cfc04
0, usually of mode 0644 and owner root.tty.
Packit 7cfc04
It refers to the memory of the currently
Packit 7cfc04
displayed virtual console terminal.
Packit 7cfc04
.PP
Packit 7cfc04
.I /dev/vcs[1\-63]
Packit 7cfc04
are character devices for virtual console
Packit 7cfc04
terminals, they have major number 7 and minor number 1 to 63, usually
Packit 7cfc04
mode 0644 and owner root.tty.
Packit 7cfc04
.IR /dev/vcsa[0\-63]
Packit 7cfc04
are the same, but
Packit 7cfc04
using
Packit 7cfc04
.IR "unsigned short" s
Packit 7cfc04
(in host byte order) that include attributes,
Packit 7cfc04
and prefixed with four bytes giving the screen
Packit 7cfc04
dimensions and cursor position:
Packit 7cfc04
.IR lines ,
Packit 7cfc04
.IR columns ,
Packit 7cfc04
.IR x ,
Packit 7cfc04
.IR y .
Packit 7cfc04
.RI ( x
Packit 7cfc04
=
Packit 7cfc04
.I y
Packit 7cfc04
= 0 at the top left corner of the screen.)
Packit 7cfc04
.PP
Packit 7cfc04
When a 512-character font is loaded,
Packit 7cfc04
the 9th bit position can be fetched by applying the
Packit 7cfc04
.BR ioctl (2)
Packit 7cfc04
.B VT_GETHIFONTMASK
Packit 7cfc04
operation
Packit 7cfc04
(available in Linux kernels 2.6.18 and above)
Packit 7cfc04
on
Packit 7cfc04
.IR /dev/tty[1\-63] ;
Packit 7cfc04
the value is returned in the
Packit 7cfc04
.I "unsigned short"
Packit 7cfc04
pointed to by the third
Packit 7cfc04
.BR ioctl (2)
Packit 7cfc04
argument.
Packit 7cfc04
.PP
Packit 7cfc04
These devices replace the screendump
Packit 7cfc04
.BR ioctl (2)
Packit 7cfc04
operations of
Packit 7cfc04
.BR ioctl_console (2),
Packit 7cfc04
so the system
Packit 7cfc04
administrator can control access using filesystem permissions.
Packit 7cfc04
.PP
Packit 7cfc04
The devices for the first eight virtual consoles may be created by:
Packit 7cfc04
.PP
Packit 7cfc04
.in +4n
Packit 7cfc04
.EX
Packit 7cfc04
for x in 0 1 2 3 4 5 6 7 8; do
Packit 7cfc04
    mknod \-m 644 /dev/vcs$x c 7 $x;
Packit 7cfc04
    mknod \-m 644 /dev/vcsa$x c 7 $[$x+128];
Packit 7cfc04
done
Packit 7cfc04
chown root:tty /dev/vcs*
Packit 7cfc04
.EE
Packit 7cfc04
.in
Packit 7cfc04
.PP
Packit 7cfc04
No
Packit 7cfc04
.BR ioctl (2)
Packit 7cfc04
requests are supported.
Packit 7cfc04
.SH FILES
Packit 7cfc04
.I /dev/vcs[0\-63]
Packit 7cfc04
.br
Packit 7cfc04
.I /dev/vcsa[0\-63]
Packit 7cfc04
.\" .SH AUTHOR
Packit 7cfc04
.\" Andries Brouwer <aeb@cwi.nl>
Packit 7cfc04
.SH VERSIONS
Packit 7cfc04
Introduced with version 1.1.92 of the Linux kernel.
Packit 7cfc04
.SH EXAMPLE
Packit 7cfc04
You may do a screendump on vt3 by switching to vt1 and typing
Packit 7cfc04
.PP
Packit 7cfc04
    cat /dev/vcs3 >foo
Packit 7cfc04
.PP
Packit 7cfc04
Note that the output does not contain
Packit 7cfc04
newline characters, so some processing may be required, like
Packit 7cfc04
in
Packit 7cfc04
.PP
Packit 7cfc04
    fold \-w 81 /dev/vcs3 | lpr
Packit 7cfc04
.PP
Packit 7cfc04
or (horrors)
Packit 7cfc04
.PP
Packit 7cfc04
    xetterm \-dump 3 \-file /proc/self/fd/1
Packit 7cfc04
.PP
Packit 7cfc04
The
Packit 7cfc04
.I /dev/vcsa0
Packit 7cfc04
device is used for Braille support.
Packit 7cfc04
.PP
Packit 7cfc04
This program displays the character and screen attributes under the
Packit 7cfc04
cursor of the second virtual console, then changes the background color
Packit 7cfc04
there:
Packit 7cfc04
.PP
Packit 7cfc04
.EX
Packit 7cfc04
#include <unistd.h>
Packit 7cfc04
#include <stdlib.h>
Packit 7cfc04
#include <stdio.h>
Packit 7cfc04
#include <fcntl.h>
Packit 7cfc04
#include <sys/ioctl.h>
Packit 7cfc04
#include <linux/vt.h>
Packit 7cfc04
Packit 7cfc04
int
Packit 7cfc04
main(void)
Packit 7cfc04
{
Packit 7cfc04
    int fd;
Packit 7cfc04
    char *device = "/dev/vcsa2";
Packit 7cfc04
    char *console = "/dev/tty2";
Packit 7cfc04
    struct {unsigned char lines, cols, x, y;} scrn;
Packit 7cfc04
    unsigned short s;
Packit 7cfc04
    unsigned short mask;
Packit 7cfc04
    unsigned char ch, attrib;
Packit 7cfc04
Packit 7cfc04
    fd = open(console, O_RDWR);
Packit 7cfc04
    if (fd < 0) {
Packit 7cfc04
        perror(console);
Packit 7cfc04
        exit(EXIT_FAILURE);
Packit 7cfc04
    }
Packit 7cfc04
    if (ioctl(fd, VT_GETHIFONTMASK, &mask) < 0) {
Packit 7cfc04
        perror("VT_GETHIFONTMASK");
Packit 7cfc04
        exit(EXIT_FAILURE);
Packit 7cfc04
    }
Packit 7cfc04
    (void) close(fd);
Packit 7cfc04
    fd = open(device, O_RDWR);
Packit 7cfc04
    if (fd < 0) {
Packit 7cfc04
        perror(device);
Packit 7cfc04
        exit(EXIT_FAILURE);
Packit 7cfc04
    }
Packit 7cfc04
    (void) read(fd, &scrn, 4);
Packit 7cfc04
    (void) lseek(fd, 4 + 2*(scrn.y*scrn.cols + scrn.x), 0);
Packit 7cfc04
    (void) read(fd, &s, 2);
Packit 7cfc04
    ch = s & 0xff;
Packit 7cfc04
    if (attrib & mask)
Packit 7cfc04
        ch |= 0x100;
Packit 7cfc04
    attrib = ((s & ~mask) >> 8);
Packit 7cfc04
    printf("ch=\(aq%c\(aq attrib=0x%02x\\n", ch, attrib);
Packit 7cfc04
    attrib ^= 0x10;
Packit 7cfc04
    (void) lseek(fd, \-1, 1);
Packit 7cfc04
    (void) write(fd, &attrib, 1);
Packit 7cfc04
    exit(EXIT_SUCCESS);
Packit 7cfc04
}
Packit 7cfc04
.EE
Packit 7cfc04
.SH SEE ALSO
Packit 7cfc04
.BR ioctl_console (2),
Packit 7cfc04
.BR tty (4),
Packit 7cfc04
.BR ttyS (4),
Packit 7cfc04
.BR gpm (8)
Packit 7cfc04
.SH COLOPHON
Packit 7cfc04
This page is part of release 4.15 of the Linux
Packit 7cfc04
.I man-pages
Packit 7cfc04
project.
Packit 7cfc04
A description of the project,
Packit 7cfc04
information about reporting bugs,
Packit 7cfc04
and the latest version of this page,
Packit 7cfc04
can be found at
Packit 7cfc04
\%https://www.kernel.org/doc/man\-pages/.