OSDN Git Service

8d7ea553e7e41ba9cf5037d5a24a41428c023c4b
[linuxjm/LDP_man-pages.git] / draft / 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 .\"*******************************************************************
29 .\"
30 .\" This file was generated with po4a. Translate the source file.
31 .\"
32 .\"*******************************************************************
33 .TH VCS 4 2007\-12\-17 Linux "Linux Programmer's Manual"
34 .SH 名前
35 vcs, vcsa \- 仮想コンソールメモリ (virtual console memory)
36 .SH 説明
37 \fI/dev/vcs0\fP はメジャーナンバー (major number) 7、マイナーナンバー (minor number) 0
38 のキャラクターデバイス (character device) で、 通常、そのモードは 0644、オーナは root.tty である。
39 このデバイスファイル (device file) は 現在表示されている仮想コンソール端末のメモリを参照する。
40 .LP
41 \fB/dev/vcs[1\-63]\fP は仮想コンソール端末のための キャラクターデバイスで、メジャーナンバーが 7、マイナーナンバーが 1 から 63、
42 通常はモードが 0644、オーナーが root.tty である。 \fB/dev/vcsa[0\-63]\fP は \fB/dev/vcs[1\-63]\fP
43 と同様であるが、 属性を格納するのに (ホストバイトオーダの)  \fIunsigned short\fP
44 を使用している点、スクリーンのサイズ・カーソルの位置を表す 4 バイトの情報 \fIlines\fP, \fIcolumns\fP, \fIx\fP, \fIy\fP
45 (\fIx\fP =\fIy\fP = 0 が画面の左上) が先頭にある点が異なる。
46
47 512 文字から成るフォントをロードした場合、 9 ビット目の情報は \fI/dev/tty[1\-63]\fP に対して \fBioctl\fP(2)
48 \fBVT_GETHIFONTMASK\fP 操作を行うことで取得できる (\fBVT_GETHIFONTMASK\fP 操作はカーネル 2.6.18 以降の
49 Linux で 利用可能である)。 値は \fBioctl\fP(2)  の 3 番目の引き数が指す \fIunsigned short\fP
50 に格納されて返される。
51 .PP
52 これらのデバイスは \fBconsole\fP(4)  の screendump \fBioctl\fP(2)  を代替となる。
53 従って、システム管理者はファイルシステムパーミッション (filesystem permission) を使ってアクセスをコントロールできる。
54 .PP
55 最初の 8 つの仮想端末のためのデバイスは、次のようにして作る事ができる:
56
57 .nf
58     for x in 0 1 2 3 4 5 6 7 8; do
59         mknod \-m 644 /dev/vcs$x c 7 $x;
60         mknod \-m 644 /dev/vcsa$x c 7 $[$x+128];
61     done
62     chown root:tty /dev/vcs*
63 .fi
64
65 \fBioctl\fP(2)  による要求はサポートされない。
66 .SH ファイル
67 /dev/vcs[0\-63]
68 .br
69 .\" .SH AUTHOR
70 .\" Andries Brouwer <aeb@cwi.nl>
71 /dev/vcsa[0\-63]
72 .SH バージョン
73 Linux カーネルバージョン 1.1.92 で導入された。
74 .SH 例
75 vt3 のスクリーンダンプを実行するには、端末を vt1 に切替えて \fIcat /dev/vcs3 >foo\fP とタイプすればよい。
76 気を付けて欲しいのは、この出力は改行文字 (newline character) を 含んでいないという事である。 従って、\fIfold \-w 81
77 /dev/vcs3 | lpr\fP や (ぞっとするが) \fIsetterm \-dump 3 \-file /proc/self/fd/1\fP のような
78 何らかの処理が必要になるかもしれない。
79 .LP
80 \fI/dev/vcsa0\fP デバイスを使うことで、 ブライユ点字をサポートすることができる。
81
82 以下のプログラムは二つ目の仮想コンソールのカーソル位置のスクリーン属性と文字 を表示した後、カーソル位置の背景色を変更する :
83
84 .nf
85 #include <unistd.h>
86 #include <stdlib.h>
87 #include <stdio.h>
88 #include <fcntl.h>
89 #include <sys/ioctl.h>
90 #include <linux/vt.h>
91
92 int
93 main(void)
94 {
95     int fd;
96     char *device = "/dev/vcsa2";
97     char *console = "/dev/tty2";
98     struct {unsigned char lines, cols, x, y;} scrn;
99     unsigned short s;
100     unsigned short mask;
101     unsigned char ch, attrib;
102
103     fd = open(console, O_RDWR);
104     if (fd < 0) {
105         perror(console);
106         exit(EXIT_FAILURE);
107     }
108     if (ioctl(fd, VT_GETHIFONTMASK, &mask) < 0) {
109         perror("VT_GETHIFONTMASK");
110         exit(EXIT_FAILURE);
111     }
112     (void) close(fd);
113     fd = open(device, O_RDWR);
114     if (fd < 0) {
115         perror(device);
116         exit(EXIT_FAILURE);
117     }
118     (void) read(fd, &scrn, 4);
119     (void) lseek(fd, 4 + 2*(scrn.y*scrn.cols + scrn.x), 0);
120     (void) read(fd, &s, 2);
121     ch = s & 0xff;
122     if (attrib & mask)
123         ch |= 0x100;
124     attrib = ((s & ~mask) >> 8);
125     printf("ch=\(aq%c\(aq attrib=0x%02x\en", ch, attrib);
126     attrib ^= 0x10;
127     (void) lseek(fd, \-1, 1);
128     (void) write(fd, &attrib, 1);
129     exit(EXIT_SUCCESS);
130 }
131 .fi
132 .SH 関連項目
133 \fBconsole\fP(4), \fBtty\fP(4), \fBttyS\fP(4), \fBgpm\fP(8)