OSDN Git Service

e26337c4c970e73b203cfa88b577197c6e535236
[linuxjm/LDP_man-pages.git] / release / 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 .\" Japanese Version Copyright (c) 1996,1997,1998 ISHIKAWA Mutsumi
29 .\"         all rights reserved.
30 .\" Translated Tue Feb 6 16:30:31 JST 1997
31 .\"         by ISHIKAWA Mutsumi <ishikawa@linux.or.jp>
32 .\"
33 .\" Japanese Version Last Modified Sun Jan 11 03:55:54 1998
34 .\"     by ISHIKAWA Mutsumi <ishikawa@linux.or.jp>
35 .\" Updated Sat Feb 10 23:17:30 JST 2001
36 .\"     by Yuichi SATO <sato@complex.eng.hokudai.ac.jp>
37 .\" Updated 2008-02-12, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v2.77
38 .\"
39 .\" WORD:       virtual console         仮想コンソール
40 .\" WORD:       memory                  メモリ
41 .\" WORD:       permission              パーミッション
42 .\" WORD:       prefix                  プレフィックス
43 .\" WORD:       screen                  スクリーン
44 .\" WORD:       cursor                  カーソル
45 .\" WORD:       Braille                 ブライユ点字
46 .\"
47 .TH VCS 4 2007-12-17 "Linux" "Linux Programmer's Manual"
48 .SH 名前
49 vcs, vcsa \- 仮想コンソールメモリ (virtual console memory)
50 .SH 説明
51 \fI/dev/vcs0\fP はメジャーナンバー (major number) 7、マイナーナンバー
52 (minor number) 0 のキャラクターデバイス (character device) で、
53 通常、そのモードは 0644、オーナは root.tty である。
54 このデバイスファイル (device file) は
55 現在表示されている仮想コンソール端末のメモリを参照する。
56 .LP
57 \fB/dev/vcs[1\-63]\fP は仮想コンソール端末のための
58 キャラクターデバイスで、メジャーナンバーが 7、マイナーナンバーが 1 から 63、
59 通常はモードが 0644、オーナーが root.tty である。
60 \fB/dev/vcsa[0\-63]\fP は \fB/dev/vcs[1\-63]\fP と同様であるが、
61 属性を格納するのに (ホストバイトオーダの)
62 .I "unsigned short"
63 を使用している点、スクリーンのサイズ・カーソルの位置を表す
64 4 バイトの情報
65 \fIlines\fP, \fIcolumns\fP, \fIx\fP, \fIy\fP
66 (\fIx\fP =\fIy\fP = 0 が画面の左上) が先頭にある点が異なる。
67
68 512 文字から成るフォントをロードした場合、
69 9 ビット目の情報は \fI/dev/tty[1\-63]\fP に対して
70 .BR ioctl (2)
71 \fBVT_GETHIFONTMASK\fP 操作を行うことで取得できる
72 (\fBVT_GETHIFONTMASK\fP 操作はカーネル 2.6.18 以降の Linux で
73 利用可能である)。
74 値は
75 .BR ioctl (2)
76 の 3 番目の引き数が指す
77 .I "unsigned short"
78 に格納されて返される。
79 .PP
80 これらのデバイスは
81 .BR console (4)
82 の screendump
83 .BR ioctl (2)
84 を代替となる。
85 従って、システム管理者はファイルシステムパーミッション
86 (filesystem permission) を使ってアクセスをコントロールできる。
87 .PP
88 最初の 8 つの仮想端末のためのデバイスは、次のようにして作る事ができる:
89
90 .nf
91     for x in 0 1 2 3 4 5 6 7 8; do
92         mknod \-m 644 /dev/vcs$x c 7 $x;
93         mknod \-m 644 /dev/vcsa$x c 7 $[$x+128];
94     done
95     chown root:tty /dev/vcs*
96 .fi
97
98 .BR ioctl (2)
99 による要求はサポートされない。
100 .SH ファイル
101 /dev/vcs[0\-63]
102 .br
103 /dev/vcsa[0\-63]
104 .\" .SH 著者
105 .\" Andries Brouwer <aeb@cwi.nl>
106 .SH バージョン
107 Linux カーネルバージョン 1.1.92 で導入された。
108 .SH 例
109 vt3 のスクリーンダンプを実行するには、端末を vt1 に切替えて
110 \fIcat /dev/vcs3 >foo\fP とタイプすればよい。
111 気を付けて欲しいのは、この出力は改行文字 (newline character) を
112 含んでいないという事である。
113 従って、\fIfold \-w 81 /dev/vcs3 | lpr\fP や
114 (ぞっとするが) \fIsetterm \-dump 3 \-file /proc/self/fd/1\fP のような
115 何らかの処理が必要になるかもしれない。
116 .LP
117 \fI/dev/vcsa0\fP デバイスを使うことで、
118 ブライユ点字をサポートすることができる。
119
120 以下のプログラムは二つ目の仮想コンソールのカーソル位置のスクリーン属性と文字
121 を表示した後、カーソル位置の背景色を変更する :
122
123 .nf
124 #include <unistd.h>
125 #include <stdlib.h>
126 #include <stdio.h>
127 #include <fcntl.h>
128 #include <sys/ioctl.h>
129 #include <linux/vt.h>
130
131 int
132 main(void)
133 {
134     int fd;
135     char *device = "/dev/vcsa2";
136     char *console = "/dev/tty2";
137     struct {unsigned char lines, cols, x, y;} scrn;
138     unsigned short s;
139     unsigned short mask;
140     unsigned char ch, attrib;
141
142     fd = open(console, O_RDWR);
143     if (fd < 0) {
144         perror(console);
145         exit(EXIT_FAILURE);
146     }
147     if (ioctl(fd, VT_GETHIFONTMASK, &mask) < 0) {
148         perror("VT_GETHIFONTMASK");
149         exit(EXIT_FAILURE);
150     }
151     (void) close(fd);
152     fd = open(device, O_RDWR);
153     if (fd < 0) {
154         perror(device);
155         exit(EXIT_FAILURE);
156     }
157     (void) read(fd, &scrn, 4);
158     (void) lseek(fd, 4 + 2*(scrn.y*scrn.cols + scrn.x), 0);
159     (void) read(fd, &s, 2);
160     ch = s & 0xff;
161     if (attrib & mask)
162         ch |= 0x100;
163     attrib = ((s & ~mask) >> 8);
164     printf("ch=\(aq%c\(aq attrib=0x%02x\\n", ch, attrib);
165     attrib ^= 0x10;
166     (void) lseek(fd, \-1, 1);
167     (void) write(fd, &attrib, 1);
168     exit(EXIT_SUCCESS);
169 }
170 .fi
171 .SH 関連項目
172 .BR console (4),
173 .BR tty (4),
174 .BR ttyS (4),
175 .BR gpm (8)