VCS(4) Linux Programmer’s Manual VCS(4)
名前
vcs, vcsa - 仮想コンソールメモリ (virtual console memory)
説明
/dev/vcs0 はメジャーナンバー (major number) 7、マイナーナンバー (minor
number) 0 のキャラクターデバイス (character device) で、通常、そのモ ー
ドは 0644、オーナは root.tty である。このデバイスファイル (device file)
は現在表示されている仮想コンソール端末のメモリを参照する。
/dev/vcs[1-63] は仮想コンソール端末のためのキャラクターデバイスで、メジ
ャーナンバーが 7、マイナーナンバーが 1 から 63、通常はモードが 0644、オ
ーナーが root.tty である。 /dev/vcsa[0-63] は /dev/vcs[1-63] と同様であ
るが、属性を格納するのに (ホストバイトオーダの) unsigned short を使用し
ている点、スクリーンのサイズ・カーソルの位置を表す 4 バ イ ト の 情 報
lines, columns, x, y (x =y = 0 が画面の左上) が先頭にある点が異なる。
512 文 字 か ら 成 る フ ォ ントをロードした場合、 9 ビット目の情報は
/dev/tty[1-63] に対して ioctl(2) VT_GETHIFONTMASK 操作を行うことで取 得
で きる (VT_GETHIFONTMASK 操作はカーネル 2.6.18 以降の Linux で利用可能
である)。値は ioctl(2) の 3 番目の引き数が指す unsigned short に格納 さ
れて返される。
これらのデバイスは console(4) の screendump ioctl(2) を代替となる。従っ
て、システム管理者はファイルシステムパーミッション (filesystem permis-
sion) を使ってアクセスをコントロールできる。
最初の 8 つの仮想端末のためのデバイスは、次のようにして作る事ができる:
for x in 0 1 2 3 4 5 6 7 8; do
mknod -m 644 /dev/vcs$x c 7 $x;
mknod -m 644 /dev/vcsa$x c 7 $[$x+128];
done
chown root:tty /dev/vcs*
ioctl(2) による要求はサポートされない。
ファイル
/dev/vcs[0-63]
/dev/vcsa[0-63]
バージョン
Linux カーネルバージョン 1.1.92 で導入された。
例
vt3 の ス ク リ ー ン ダンプを実行するには、端末を vt1 に切替えて cat
/dev/vcs3 >foo とタイプすればよい。気を付けて欲しいのは、この出力は改行
文 字 (newline character) を含んでいないという事である。従って、fold -w
81 /dev/vcs3 | lpr や ( ぞ っ と す る が) setterm -dump 3 -file
/proc/self/fd/1 のような何らかの処理が必要になるかもしれない。
/dev/vcsa0 デバイスを使うことで、ブライユ点字をサポートすることができる
。
以下のプログラムは二つ目の仮想コンソールのカーソル位置のスクリーン属 性
と文字を表示した後、カーソル位置の背景色を変更する :
#include
VCS(4) Linux Programmer’s Manual VCS(4)
NAME
vcs, vcsa - virtual console memory
DESCRIPTION
/dev/vcs0 is a character device with major number 7 and minor number 0,
usually of mode 0644 and owner root.tty. It refers to the memory of
the currently displayed virtual console terminal.
/dev/vcs[1-63] are character devices for virtual console terminals,
they have major number 7 and minor number 1 to 63, usually mode 0644
and owner root.tty. /dev/vcsa[0-63] are the same, but using unsigned
shorts (in host byte order) that include attributes, and prefixed with
four bytes giving the screen dimensions and cursor position: lines,
columns, x, y. (x = y = 0 at the top left corner of the screen.)
When a 512-character font is loaded, the 9th bit position can be
fetched by applying the ioctl(2) VT_GETHIFONTMASK operation (available
in Linux kernels 2.6.18 and above) on /dev/tty[1-63]; the value is
returned in the unsigned short pointed to by the third ioctl(2) argu-
ment.
These devices replace the screendump ioctl(2) operations of console(4),
so the system administrator can control access using file system per-
missions.
The devices for the first eight virtual consoles may be created by:
for x in 0 1 2 3 4 5 6 7 8; do
mknod -m 644 /dev/vcs$x c 7 $x;
mknod -m 644 /dev/vcsa$x c 7 $[$x+128];
done
chown root:tty /dev/vcs*
No ioctl(2) requests are supported.
FILES
/dev/vcs[0-63]
/dev/vcsa[0-63]
VERSIONS
Introduced with version 1.1.92 of the Linux kernel.
EXAMPLE
You may do a screendump on vt3 by switching to vt1 and typing cat
/dev/vcs3 >foo. Note that the output does not contain newline charac-
ters, so some processing may be required, like in fold -w 81 /dev/vcs3
| lpr or (horrors) setterm -dump 3 -file /proc/self/fd/1.
The /dev/vcsa0 device is used for Braille support.
This program displays the character and screen attributes under the
cursor of the second virtual console, then changes the background color
there:
#include
Copyright(C) linux-cmd.com All Rights Reserved. Author Takayuki Yukawa