2008年8月23日土曜日

(FreeBSD) こんなkernel configファイルの書き方知らなかった

FreeBSDのメーリングリストを斜め読みしてたら、kernelのconfigファイル(/sys/i386/conf/にあるやつ)に、nooptionsというキーワードが入っているものを見つました。
たとえば普通のconfigファイルGENERICでは

options         NFS_ROOT

と書いてあったりする行が

nooptions         NFS_ROOT


のように書き換えられていたんです。



おおっ!私だったら"#"をつけてコメントアウトしちゃうんですが、nooptionsなんて書き方があったんですか。



さっそく、マニュアルでconfigを確認。「man config」したら、config(8)の「config -- build system configuration files」が出てきて、SEE ALSOに書いてあるconfig(5)を読めばよいらしいです。
「man 5 config」したら、「OpenSSL CONF library configuration files」なんてのが出てきちゃって、ありゃ?だったので、「man -M /usr/share/man 5 config」しました。



どうやら、nooptionsのほかにもno*なキーワードがあり、nocpu、nodevices、nomakeoptions、nodevicesが使えるようです。

nocpu cputype
    Remove the specified CPU from the list of previously selected
    CPUs.  This directive can be used to cancel the effect of cpu
    directives in files included using include.



nodevice name [, name [...]]
nodevices name [, name [...]]
    Remove the specified devices from the list of previously selected
    devices.  This directive can be used to cancel the effects of
    device or devices directives in files included using include.



nomakeoption name
nomakeoptions name
    Removes previously defined make(1) option name from the kernel
    build.  This directive can be used to cancel the effects of
    makeoption directives in files included using include.



nooption name [, name [...]]
nooptions name [, name [...]]
    Remove the specified kernel options from the list of previously
    defined options.  This directive can be used to cancel the
    effects of option or options directives in files included using
    include.

configファイルは、「include」で別ファイルを取り込むことができるんですが(使ったことない)、「#」でコメントアウトする方法では、includeしたファイルに書いてあった記述を無効にできません。
一方、「nodevices」など「no~」なキーワードを使えば、includesしたファイルにあった記述を無効にできる、とのこと。



なるほど。
いつも、GENERICファイルをコピーして、書き換えてたんですが、GENERICをincludeして、nodevicesなどを列挙したファイルを作ったほうがよさそうな気がしてきました。



cvsup、make buileworld、make buildkernelでバージョンアップを続けていると、いつのまにかGENERICに新しいキーワードが増えていることがあります。しかも、その新キーワードが必須だったりすることが、過去にありました。そうすると、使い続けてきたconfigファイルで作ったkernelでは起動しなくなったりするわけです。





「no~」というキーワードはいつから使えるようになってたのでしょうか。

http://www.freebsd.org/cgi/cvsweb.cgi/src/usr.sbin/config/config.5

を見ると、5年前のrevision 1.1ですでにnooptionというキーワードが見えますが、4年前のrevision 1.5のとき(6.0-RELEASEの時ですかね?old_RELENGなんとか、というタグは何者なんでしょうか)と、すでに現在のマニュアルに近い記述にはなっています。



いやぁ~知りませんでした。





1 件のコメント:

  1. 同じことをちょうど考えて調べていたところでした。なかなか情報が見つかりませんでしたので、大変参考になりました。
    貴重な情報ありがとうございました。

    返信削除