18c2ecf20Sopenharmony_ciNOTE:
28c2ecf20Sopenharmony_ciThis is a version of Documentation/process/stable-api-nonsense.rst into Japanese.
38c2ecf20Sopenharmony_ciThis document is maintained by IKEDA, Munehiro <m-ikeda@ds.jp.nec.com>
48c2ecf20Sopenharmony_ciand the JF Project team <http://www.linux.or.jp/JF/>.
58c2ecf20Sopenharmony_ciIf you find any difference between this document and the original file
68c2ecf20Sopenharmony_cior a problem with the translation,
78c2ecf20Sopenharmony_ciplease contact the maintainer of this file or JF project.
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ciPlease also note that the purpose of this file is to be easier to read
108c2ecf20Sopenharmony_cifor non English (read: Japanese) speakers and is not intended as a
118c2ecf20Sopenharmony_cifork. So if you have any comments or updates of this file, please try
128c2ecf20Sopenharmony_cito update the original English file first.
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ciLast Updated: 2007/07/18
158c2ecf20Sopenharmony_ci==================================
168c2ecf20Sopenharmony_ciこれは、
178c2ecf20Sopenharmony_cilinux-2.6.22-rc4/Documentation/process/stable-api-nonsense.rst の和訳
188c2ecf20Sopenharmony_ciです。
198c2ecf20Sopenharmony_ci翻訳団体: JF プロジェクト < http://www.linux.or.jp/JF/ >
208c2ecf20Sopenharmony_ci翻訳日 : 2007/06/11
218c2ecf20Sopenharmony_ci原著作者: Greg Kroah-Hartman < greg at kroah dot com >
228c2ecf20Sopenharmony_ci翻訳者 : 池田 宗広 < m-ikeda at ds dot jp dot nec dot com >
238c2ecf20Sopenharmony_ci校正者 : Masanori Kobayashi さん < zap03216 at nifty dot ne dot jp >
248c2ecf20Sopenharmony_ci          Seiji Kaneko さん < skaneko at a2 dot mbn dot or dot jp >
258c2ecf20Sopenharmony_ci==================================
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_ciLinux カーネルのドライバインターフェース
308c2ecf20Sopenharmony_ci(あなたの質問すべてに対する回答とその他諸々)
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_ciGreg Kroah-Hartman <greg at kroah dot com>
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ciこの文書は、なぜ Linux ではバイナリカーネルインターフェースが定義
368c2ecf20Sopenharmony_ciされていないのか、またはなぜ不変のカーネルインターフェースを持たな
378c2ecf20Sopenharmony_ciいのか、ということを説明するために書かれた。ここでの話題は「カーネ
388c2ecf20Sopenharmony_ciル内部の」インターフェースについてであり、ユーザー空間とのインター
398c2ecf20Sopenharmony_ciフェースではないことを理解してほしい。カーネルとユーザー空間とのイ
408c2ecf20Sopenharmony_ciンターフェースとはアプリケーションプログラムが使用するものであり、
418c2ecf20Sopenharmony_ciつまりシステムコールのインターフェースがこれに当たる。これは今まで
428c2ecf20Sopenharmony_ci長きに渡り、かつ今後も「まさしく」不変である。私は確か 0.9 か何か
438c2ecf20Sopenharmony_ciより前のカーネルを使ってビルドした古いプログラムを持っているが、そ
448c2ecf20Sopenharmony_ciれは最新の 2.6 カーネルでもきちんと動作する。ユーザー空間とのイン
458c2ecf20Sopenharmony_ciターフェースは、ユーザーとアプリケーションプログラマが不変性を信頼
468c2ecf20Sopenharmony_ciしてよいものの一つである。
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ci要旨
508c2ecf20Sopenharmony_ci----
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ciあなたは不変のカーネルインターフェースが必要だと考えているかもしれ
538c2ecf20Sopenharmony_ciないが、実際のところはそうではない。あなたは必要としているものが分
548c2ecf20Sopenharmony_ciかっていない。あなたが必要としているものは安定して動作するドライバ
558c2ecf20Sopenharmony_ciであり、それはドライバがメインのカーネルツリーに含まれる場合のみ得
568c2ecf20Sopenharmony_ciることができる。ドライバがメインのカーネルツリーに含まれていると、
578c2ecf20Sopenharmony_ci他にも多くの良いことがある。それは、Linux をより強固で、安定な、成
588c2ecf20Sopenharmony_ci熟したオペレーティングシステムにすることができるということだ。これ
598c2ecf20Sopenharmony_ciこそ、そもそもあなたが Linux を使う理由のはずだ。
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_ciはじめに
638c2ecf20Sopenharmony_ci--------
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_ciカーネル内部のインターフェース変更を心配しなければならないドライバ
668c2ecf20Sopenharmony_ciを書きたいなどというのは、変わり者だけだ。この世界のほとんどの人は、
678c2ecf20Sopenharmony_ciそのようなドライバがどんなインターフェースを使っているかなど知らな
688c2ecf20Sopenharmony_ciいし、そんなドライバのことなど全く気にもかけていない。
698c2ecf20Sopenharmony_ci
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_ciまず初めに、クローズソースとか、ソースコードの隠蔽とか、バイナリの
728c2ecf20Sopenharmony_ciみが配布される使い物にならない代物[訳注(1)]とか、実体はバイナリ
738c2ecf20Sopenharmony_ciコードでそれを読み込むためのラッパー部分のみソースコードが公開され
748c2ecf20Sopenharmony_ciているとか、その他用語は何であれ GPL の下にソースコードがリリース
758c2ecf20Sopenharmony_ciされていないカーネルドライバに関する法的な問題について、私は「いか
768c2ecf20Sopenharmony_ciなる議論も」行うつもりがない。法的な疑問があるのならば、プログラマ
778c2ecf20Sopenharmony_ciである私ではなく、弁護士に相談して欲しい。ここでは単に、技術的な問
788c2ecf20Sopenharmony_ci題について述べることにする。(法的な問題を軽視しているわけではない。
798c2ecf20Sopenharmony_ciそれらは実際に存在するし、あなたはそれをいつも気にかけておく必要が
808c2ecf20Sopenharmony_ciある)
818c2ecf20Sopenharmony_ci
828c2ecf20Sopenharmony_ci訳注(1)
838c2ecf20Sopenharmony_ci「使い物にならない代物」の原文は "blob"
848c2ecf20Sopenharmony_ci
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_ciさてここでは、バイナリカーネルインターフェースについてと、ソースレ
878c2ecf20Sopenharmony_ciベルでのインターフェースの不変性について、という二つの話題を取り上
888c2ecf20Sopenharmony_ciげる。この二つは互いに依存する関係にあるが、まずはバイナリインター
898c2ecf20Sopenharmony_ciフェースについて議論を行いやっつけてしまおう。
908c2ecf20Sopenharmony_ci
918c2ecf20Sopenharmony_ci
928c2ecf20Sopenharmony_ciバイナリカーネルインターフェース
938c2ecf20Sopenharmony_ci--------------------------------
948c2ecf20Sopenharmony_ci
958c2ecf20Sopenharmony_ciもしソースレベルでのインターフェースが不変ならば、バイナリインター
968c2ecf20Sopenharmony_ciフェースも当然のように不変である、というのは正しいだろうか?正しく
978c2ecf20Sopenharmony_ciない。Linux カーネルに関する以下の事実を考えてみてほしい。
988c2ecf20Sopenharmony_ci  - あなたが使用するCコンパイラのバージョンによって、カーネル内部
998c2ecf20Sopenharmony_ci    の構造体の配置構造は異なったものになる。また、関数は異なった方
1008c2ecf20Sopenharmony_ci    法でカーネルに含まれることになるかもしれない(例えばインライン
1018c2ecf20Sopenharmony_ci    関数として扱われたり、扱われなかったりする)。個々の関数がどの
1028c2ecf20Sopenharmony_ci    ようにコンパイルされるかはそれほど重要ではないが、構造体のパデ
1038c2ecf20Sopenharmony_ci    ィングが異なるというのは非常に重要である。
1048c2ecf20Sopenharmony_ci  - あなたがカーネルのビルドオプションをどのように設定するかによっ
1058c2ecf20Sopenharmony_ci    て、カーネルには広い範囲で異なった事態が起こり得る。
1068c2ecf20Sopenharmony_ci      - データ構造は異なるデータフィールドを持つかもしれない
1078c2ecf20Sopenharmony_ci      - いくつかの関数は全く実装されていない状態になり得る
1088c2ecf20Sopenharmony_ci        (例:SMP向けではないビルドでは、いくつかのロックは中身が
1098c2ecf20Sopenharmony_ci          カラにコンパイルされる)
1108c2ecf20Sopenharmony_ci      - カーネル内のメモリは、異なった方法で配置され得る。これはビ
1118c2ecf20Sopenharmony_ci        ルドオプションに依存している。
1128c2ecf20Sopenharmony_ci  - Linux は様々な異なるプロセッサアーキテクチャ上で動作する。
1138c2ecf20Sopenharmony_ci    あるアーキテクチャ用のバイナリドライバを、他のアーキテクチャで
1148c2ecf20Sopenharmony_ci    正常に動作させる方法はない。
1158c2ecf20Sopenharmony_ci
1168c2ecf20Sopenharmony_ci
1178c2ecf20Sopenharmony_ciある特定のカーネル設定を使用し、カーネルをビルドしたのと正確に同じ
1188c2ecf20Sopenharmony_ciCコンパイラを使用して単にカーネルモジュールをコンパイルするだけで
1198c2ecf20Sopenharmony_ciも、あなたはこれらいくつもの問題に直面することになる。ある特定の
1208c2ecf20Sopenharmony_ciLinux ディストリビューションの、ある特定のリリースバージョン用にモ
1218c2ecf20Sopenharmony_ciジュールを提供しようと思っただけでも、これらの問題を引き起こすには
1228c2ecf20Sopenharmony_ci十分である。にも関わらず Linux ディストリビューションの数と、サ
1238c2ecf20Sopenharmony_ciポートするディストリビューションのリリース数を掛け算し、それら一つ
1248c2ecf20Sopenharmony_ci一つについてビルドを行ったとしたら、今度はリリースごとのビルドオプ
1258c2ecf20Sopenharmony_ciションの違いという悪夢にすぐさま悩まされることになる。また、ディス
1268c2ecf20Sopenharmony_ciトリビューションの各リリースバージョンには、異なるハードウェア(プ
1278c2ecf20Sopenharmony_ciロセッサタイプや種々のオプション)に対応するため、何種類かのカーネ
1288c2ecf20Sopenharmony_ciルが含まれているということも理解して欲しい。従って、ある一つのリ
1298c2ecf20Sopenharmony_ciリースバージョンだけのためにモジュールを作成する場合でも、あなたは
1308c2ecf20Sopenharmony_ci何バージョンものモジュールを用意しなければならない。
1318c2ecf20Sopenharmony_ci
1328c2ecf20Sopenharmony_ci
1338c2ecf20Sopenharmony_ci信じて欲しい。このような方法でサポートを続けようとするなら、あなた
1348c2ecf20Sopenharmony_ciはいずれ正気を失うだろう。遠い昔、私はそれがいかに困難なことか、身
1358c2ecf20Sopenharmony_ciをもって学んだのだ・・・
1368c2ecf20Sopenharmony_ci
1378c2ecf20Sopenharmony_ci
1388c2ecf20Sopenharmony_ci不変のカーネルソースレベルインターフェース
1398c2ecf20Sopenharmony_ci------------------------------------------
1408c2ecf20Sopenharmony_ci
1418c2ecf20Sopenharmony_ciメインカーネルツリーに含まれていない Linux カーネルドライバを継続
1428c2ecf20Sopenharmony_ciしてサポートしていこうとしている人たちとの議論においては、これは極
1438c2ecf20Sopenharmony_ciめて「引火性の高い」話題である。[訳注(2)]
1448c2ecf20Sopenharmony_ci
1458c2ecf20Sopenharmony_ci訳注(2)
1468c2ecf20Sopenharmony_ci「引火性の高い」の原文は "volatile"。
1478c2ecf20Sopenharmony_civolatile には「揮発性の」「爆発しやすい」という意味の他、「変わり
1488c2ecf20Sopenharmony_ciやすい」「移り気な」という意味がある。
1498c2ecf20Sopenharmony_ci「(この話題は)爆発的に激しい論争を巻き起こしかねない」ということ
1508c2ecf20Sopenharmony_ciを、「(カーネルのソースレベルインターフェースは)移ろい行くもので
1518c2ecf20Sopenharmony_ciある」ということを連想させる "volatile" という単語で表現している。
1528c2ecf20Sopenharmony_ci
1538c2ecf20Sopenharmony_ci
1548c2ecf20Sopenharmony_ciLinux カーネルの開発は継続的に速いペースで行われ、決して歩みを緩め
1558c2ecf20Sopenharmony_ciることがない。その中でカーネル開発者達は、現状のインターフェースに
1568c2ecf20Sopenharmony_ciあるバグを見つけ、より良い方法を考え出す。彼らはやがて、現状のイン
1578c2ecf20Sopenharmony_ciターフェースがより正しく動作するように修正を行う。その過程で関数の
1588c2ecf20Sopenharmony_ci名前は変更されるかもしれず、構造体は大きく、または小さくなるかもし
1598c2ecf20Sopenharmony_ciれず、関数の引数は検討しなおされるかもしれない。そのような場合、引
1608c2ecf20Sopenharmony_ciき続き全てが正常に動作するよう、カーネル内でこれらのインターフェー
1618c2ecf20Sopenharmony_ciスを使用している個所も全て同時に修正される。
1628c2ecf20Sopenharmony_ci
1638c2ecf20Sopenharmony_ci
1648c2ecf20Sopenharmony_ci具体的な例として、カーネル内の USB インターフェースを挙げる。USB
1658c2ecf20Sopenharmony_ciサブシステムはこれまでに少なくとも3回の書き直しが行われ、その結果
1668c2ecf20Sopenharmony_ciインターフェースが変更された。これらの書き直しはいくつかの異なった
1678c2ecf20Sopenharmony_ci問題を修正するために行われた。
1688c2ecf20Sopenharmony_ci  - 同期的データストリームが非同期に変更された。これにより多数のド
1698c2ecf20Sopenharmony_ci    ライバを単純化でき、全てのドライバのスループットが向上した。今
1708c2ecf20Sopenharmony_ci    やほとんど全ての USB デバイスは、考えられる最高の速度で動作し
1718c2ecf20Sopenharmony_ci    ている。
1728c2ecf20Sopenharmony_ci  - USB ドライバが USB サブシステムのコアから行う、データパケット
1738c2ecf20Sopenharmony_ci    用のメモリ確保方法が変更された。これに伴い、いくつもの文書化さ
1748c2ecf20Sopenharmony_ci    れたデッドロック条件を回避するため、全ての USB ドライバはより
1758c2ecf20Sopenharmony_ci    多くの情報を USB コアに提供しなければならないようになっている。
1768c2ecf20Sopenharmony_ci
1778c2ecf20Sopenharmony_ci
1788c2ecf20Sopenharmony_ciこのできごとは、数多く存在するクローズソースのオペレーティングシス
1798c2ecf20Sopenharmony_ciテムとは全く対照的だ。それらは長期に渡り古い USB インターフェース
1808c2ecf20Sopenharmony_ciをメンテナンスしなければならない。古いインターフェースが残ることで、
1818c2ecf20Sopenharmony_ci新たな開発者が偶然古いインターフェースを使い、正しくない方法で開発
1828c2ecf20Sopenharmony_ciを行ってしまう可能性が生じる。これによりシステムの安定性は危険にさ
1838c2ecf20Sopenharmony_ciらされることになる。
1848c2ecf20Sopenharmony_ci
1858c2ecf20Sopenharmony_ci
1868c2ecf20Sopenharmony_ci上に挙げたどちらの例においても、開発者達はその変更が重要かつ必要で
1878c2ecf20Sopenharmony_ciあることに合意し、比較的楽にそれを実行した。もし Linux がソースレ
1888c2ecf20Sopenharmony_ciベルでインターフェースの不変性を保証しなければならないとしたら、新
1898c2ecf20Sopenharmony_ciしいインターフェースを作ると同時に、古い、問題のある方を今後ともメ
1908c2ecf20Sopenharmony_ciンテナンスするという余計な仕事を USB の開発者にさせなければならな
1918c2ecf20Sopenharmony_ciい。Linux の USB 開発者は、自分の時間を使って仕事をしている。よっ
1928c2ecf20Sopenharmony_ciて、価値のない余計な仕事を報酬もなしに実行しろと言うことはできない。
1938c2ecf20Sopenharmony_ci
1948c2ecf20Sopenharmony_ci
1958c2ecf20Sopenharmony_ciセキュリティ問題も、Linux にとっては非常に重要である。ひとたびセキ
1968c2ecf20Sopenharmony_ciュリティに関する問題が発見されれば、それは極めて短期間のうちに修正
1978c2ecf20Sopenharmony_ciされる。セキュリティ問題の発生を防ぐための修正は、カーネルの内部イ
1988c2ecf20Sopenharmony_ciンターフェースの変更を何度も引き起こしてきた。その際同時に、変更さ
1998c2ecf20Sopenharmony_ciれたインターフェースを使用する全てのドライバもまた変更された。これ
2008c2ecf20Sopenharmony_ciにより問題が解消し、将来偶然に問題が再発してしまわないことが保証さ
2018c2ecf20Sopenharmony_ciれる。もし内部インターフェースの変更が許されないとしたら、このよう
2028c2ecf20Sopenharmony_ciにセキュリティ問題を修正し、将来再発しないことを保証することなど不
2038c2ecf20Sopenharmony_ci可能なのだ。
2048c2ecf20Sopenharmony_ci
2058c2ecf20Sopenharmony_ci
2068c2ecf20Sopenharmony_ciカーネルのインターフェースは時が経つにつれクリーンナップを受ける。
2078c2ecf20Sopenharmony_ci誰も使っていないインターフェースは削除される。これにより、可能な限
2088c2ecf20Sopenharmony_ciりカーネルが小さく保たれ、現役の全てのインターフェースが可能な限り
2098c2ecf20Sopenharmony_ciテストされることを保証しているのだ。(使われていないインターフェー
2108c2ecf20Sopenharmony_ciスの妥当性をテストすることは不可能と言っていいだろう)
2118c2ecf20Sopenharmony_ci
2128c2ecf20Sopenharmony_ci
2138c2ecf20Sopenharmony_ci
2148c2ecf20Sopenharmony_ciこれから何をすべきか
2158c2ecf20Sopenharmony_ci-----------------------
2168c2ecf20Sopenharmony_ci
2178c2ecf20Sopenharmony_ciでは、もしメインのカーネルツリーに含まれない Linux カーネルドライ
2188c2ecf20Sopenharmony_ciバがあったとして、あなたは、つまり開発者は何をするべきだろうか?全
2198c2ecf20Sopenharmony_ciてのディストリビューションの全てのカーネルバージョン向けにバイナリ
2208c2ecf20Sopenharmony_ciのドライバを供給することは悪夢であり、カーネルインターフェースの変
2218c2ecf20Sopenharmony_ci更を追いかけ続けることもまた過酷な仕事だ。
2228c2ecf20Sopenharmony_ci
2238c2ecf20Sopenharmony_ci
2248c2ecf20Sopenharmony_ci答えは簡単。そのドライバをメインのカーネルツリーに入れてしまえばよ
2258c2ecf20Sopenharmony_ciい。(ここで言及しているのは、GPL に従って公開されるドライバのこと
2268c2ecf20Sopenharmony_ciだということに注意してほしい。あなたのコードがそれに該当しないなら
2278c2ecf20Sopenharmony_ciば、さよなら。幸運を祈ります。ご自分で何とかしてください。Andrew
2288c2ecf20Sopenharmony_ciと Linus からのコメント<Andrew と Linus のコメントへのリンクをこ
2298c2ecf20Sopenharmony_ciこに置く>をどうぞ)ドライバがメインツリーに入れば、カーネルのイン
2308c2ecf20Sopenharmony_ciターフェースが変更された場合、変更を行った開発者によってドライバも
2318c2ecf20Sopenharmony_ci修正されることになるだろう。あなたはほとんど労力を払うことなしに、
2328c2ecf20Sopenharmony_ci常にビルド可能できちんと動作するドライバを手に入れることができる。
2338c2ecf20Sopenharmony_ci
2348c2ecf20Sopenharmony_ci
2358c2ecf20Sopenharmony_ciドライバをメインのカーネルツリーに入れると、非常に好ましい以下の効
2368c2ecf20Sopenharmony_ci果がある。
2378c2ecf20Sopenharmony_ci  - ドライバの品質が向上する一方で、(元の開発者にとっての)メンテ
2388c2ecf20Sopenharmony_ci    ナンスコストは下がる。
2398c2ecf20Sopenharmony_ci  - あなたのドライバに他の開発者が機能を追加してくれる。
2408c2ecf20Sopenharmony_ci  - 誰かがあなたのドライバにあるバグを見つけ、修正してくれる。
2418c2ecf20Sopenharmony_ci  - 誰かがあなたのドライバにある改善点を見つけてくれる。
2428c2ecf20Sopenharmony_ci  - 外部インターフェースが変更されドライバの更新が必要になった場合、
2438c2ecf20Sopenharmony_ci    誰かがあなたの代わりに更新してくれる。
2448c2ecf20Sopenharmony_ci  - ドライバを入れてくれとディストロに頼まなくても、そのドライバは
2458c2ecf20Sopenharmony_ci    全ての Linux ディストリビューションに自動的に含まれてリリース
2468c2ecf20Sopenharmony_ci    される。
2478c2ecf20Sopenharmony_ci
2488c2ecf20Sopenharmony_ci
2498c2ecf20Sopenharmony_ciLinux では、他のどのオペレーティングシステムよりも数多くのデバイス
2508c2ecf20Sopenharmony_ciが「そのまま」使用できるようになった。また Linux は、どのオペレー
2518c2ecf20Sopenharmony_ciティングシステムよりも数多くのプロセッサアーキテクチャ上でそれらの
2528c2ecf20Sopenharmony_ciデバイスを使用することができるようにもなった。このように、Linux の
2538c2ecf20Sopenharmony_ci開発モデルは実証されており、今後も間違いなく正しい方向へと進んでい
2548c2ecf20Sopenharmony_ciくだろう。:)
2558c2ecf20Sopenharmony_ci
2568c2ecf20Sopenharmony_ci
2578c2ecf20Sopenharmony_ci
2588c2ecf20Sopenharmony_ci------
2598c2ecf20Sopenharmony_ci
2608c2ecf20Sopenharmony_ciこの文書の初期の草稿に対し、Randy Dunlap, Andrew Morton, David
2618c2ecf20Sopenharmony_ciBrownell, Hanna Linder, Robert Love, Nishanth Aravamudan から査読
2628c2ecf20Sopenharmony_ciと助言を頂きました。感謝申し上げます。
2638c2ecf20Sopenharmony_ci
264