Plan9で使われる特殊ファイル

このページでは、Plan9(Version3)で使われる特殊ファイルの概説を載せます。詳しくはマニュアルを見て下さい。

ls -lを実行するとこんな行が出てきます。UNIXと似ていますが、ちょっと違ってます。

cpu% ls -l
--rw-rw-rw- I 0 network bootes 0 Mar 3 03:54 arp
--rw-rw-rw- I 0 network bootes 0 Mar 3 03:54 bootp

赤字でかかれているのが特殊なデバイスが供給するファイルです。

/adm

cache
keys
keyfsが使う暗号化されたPlan9のキーファイル
keys.who
Plan9データベースを使用するユーザ
netkeys
keyfsが使う暗号化されたSevureNetのキーファイル
netkeys.who
SecureNetを使用するユーザ
timeconst
users
whois

/dev

authcheck
authenticate
authenticator
bintime

timeと同じものをバイナリフォーマットで返す
cons

キーボードから打ち込まれたキャラクタが格納されている。

コンソールスクリーンに表示
consctl

rawon:consをrawモードに変更
rawoff:consを通常モードに変更
cputime

現在のプロセスが使用しているuser mode, system call read elapsedtimeを返す。
drivers

ドライバーの一覧を返す
cpu% cat drivers
#/ root
#c cons
#P arch
#e env
#| pipe
#p proc
#M mnt
#s srv
#d dup
#r rtc
#D ssl
#B bridge
#l ether
#I ip
#i draw
#m mouse
#v vga
#S sd
#f floppy
#y i82365
#L lpt
#t ns16552
#G astar
fd0disk
floppyデバイス
fd0ctl

eject: イジェクト
reset: ドライブリセット format type: フォーマット
hostdomain

認証ドメインが格納されている。

認証ドメインを書き込むが、hostownerだけが書き込める。
hostowner

ローカルデバイスの持ち主の名前。具体的には、console loginしたユーザである。
key
null

0が返ってくる

捨て去る
pgrpid

プロセスグループ番号
pid

プロセス番号
ppid

親プロセス番号
random

乱数を返す
reboot
書 reboot: rebootを行う。
カーネルへのパス: 指定されたカーネルファイルでrebootする
host ownserだけが書き込み権限をもつ。
swap

swapとメモリの状況を返す
cpu% cat swap
1208/16963 memory 0/136800 swap
sysname

systemの名前を返す
sysstat

processor number, context switches, interrupts, system calls, page faults, TLB faults, TLB purges, load averageを返す
cpu% cat sysstat
          0    99843218   175251631    16954181      696505           0           0          88 

内容を全てリセットする
time

epoch(32bit), epoch(64bit), clock ticks, clock周波数を返す
cpu% cat time
 1023662323   1023662323554805173       276742551512942             133650979

epochからの時間として時間をセットする。
user

現在のユーザ名を返す
zero

0を無限に返す

/env

ここには環境変数がある。

/fd

ファイル識別子がある。ファイル識別子は固定されないが通常は下記の通り

0
読 標準入力
1
書 標準出力
2
書 標準エラー出力

/mnt

acme
apeselect
arch
cd
cons
consoles
doc
exportfs
keys
keyfsはここにマウントされたユーザのキーをデコードする
netkeys
plumb
rdb
term
wrap
wsys

/net

net.altもシステムによってはある

単独のファイル

arp

flush: 全てのエントリを削除
add type IP-addr Media-addr: IPのエントリを追加

cpu% cat arp
ether  OK       192.168.1.32     0060088b00c8                    
ether  OK       192.168.1.33     0060088b00c8                    
ether  OK       192.168.1.31     0050e4504768                    
ether  OK       192.168.1.1      00000eaa5356                    
bootp
iproute

4
IPv4 route
6
IPv6 route
i
local interface
b
broadcast address
u
local unicast address
m
multicast route
p
point-to-point route
cpu% cat iproute
0.0.0.0                  /96                      192.168.1.1              4    none   0
192.168.1.0              /120                     192.168.1.32             4i   ifc    0
192.168.1.0              /128                     192.168.1.0              4b   ifc    -
192.168.1.32             /128                     192.168.1.32             4u   ifc    0
192.168.1.33             /128                     192.168.1.33             4u   ifc    0
192.168.1.255            /128                     192.168.1.255            4b   ifc    -
255.255.255.255          /128                     255.255.255.255          4b   ifc    -
cpu% 

flush: 全てのルートの削除
tag string: Associate the tag, string, with all subsequent routes added via this file descriptor.よく分からない
add target mask nexthop: ルートの追加
remove target mask: ルートの削除
ipselftab

全ての自分自身の知っているアドレスを返す
cpu% cat ipselftab
192.168.1.0                      02 6b  
192.168.1.32                     01 6u  
192.168.1.33                     01 6u  
255.255.255.255                  02 6b  
192.168.1.255                    02 6b  
cpu% 
log
全ての現在開かれているIPのログを記録する
ndb

ndbの知っている情報を返す
cpu% cat ndb
ip=192.168.1.32 ipmask=/120 ipgw=192.168.1.1
cpu% 

/net/ethern

clone
[0-7]
0-7はカードのデバイス番号。一つのインタフェースにデフォルトでは4つのIPを割り振れる。
[0-7]/data

ネットワークからのパケットを読む
[0-7]/ctl

connect n: 接続コマンド。nはコマンドのタイプ

接続の番号(0-7)を返す
[0-7]/ifstats</dt>

カードの状態を返す
cpu% cat ifstats
interrupts: 107774
timer: 4121487 12715937
carrierlost: 0
sqeerrors: 0
multiplecolls: 1975
singlecollframes: 1436
latecollisions: 0
rxoverruns: 0
framesxmittedok: 104924
framesrcvdok: 96774
framesdeferred: 10625
bytesrcvdok: 41423586
bytesxmittedok: 63454150
badssd: 0
[0-7]/stats

カードの状態を返す
cpu% cat stats
in: 98122
out: 211161
crc errs: 5
overflows: 0
soft overflows: 0
framing errs: 0
buffer errs: 0
output errs: 0
prom: 0
addr: 0060088b00c8
[0-7]/type

Etherのパケットのタイプを返す

/net/ipifc

clone
新規インタフェースを作る場合に開く
stats

ステータスを返す
  1. forwarding status (0 and 2 mean forwarding off, 1 means on)
  2. default TTL
  3. input packets
  4. input header errors
  5. input address errors
  6. packets forwarded
  7. input packets for unknown protocols
  8. input packets discarded
  9. input packets delivered to higher level protocols
  10. output packets
  11. output packets discarded
  12. output packets with no route
  13. timed out fragments in reassembly queue
  14. requested reassemblies
  15. successful reassemblies
  16. failed reassemblies
  17. successful fragmentations
  18. unsuccessful fragmentations
  19. fragments created
cpu% cat stats
Forwarding: 0
DefaultTTL: 255
InReceives: 103600
InHdrErrors: 0
InAddrErrors: 0
ForwDatagrams: 0
InUnknownProtos: 0
InDiscards: 0
InDelivers: 103600
OutRequests: 115256
OutDiscards: 0
OutNoRoutes: 0
ReasmTimeout: 0
ReasmReqds: 0
ReasmOKs: 0
ReasmFails: 0
FragOKs: 0
FragFails: 0
FragCreates: 0
cpu% 

/net/[tcp|il|udp|gre|esp|icmp|rudp]

下記のプロトコルのスタックです

tcp
標準TCP
il
Plan9間(Infernoも)での通信プロトコル
udp
標準UDP
gre
general encapsulation protocol(?)
esp
encapsulation protocol for IPSEC
icmp
専らpingで使われるプロトコル
rudp
locally developed reliable datagram protocol based on UDP
clone

connect ipaddress!port!r local: 接続開始
announce X: Xへのアクセスを許可する
bind X: bind
backlog n: キューの長さ
ttl n: パケットのTTL
tos n: 出ていくパケットのタイプ
remote|local

remode/localのポート番号、IPアドレスなど
cpu% cat 67/remote
143.90.130.55!48999
cpu% cat 67/local
192.168.1.32!80
listen
ここをopenすることで通信が開始される>
tcp/ctl

hangup: 接続をクローズする
keepalive n: keepalive時間を設定する
udp/data

データを読み込む

データグラムを書き込む