5
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

デバイスファイル

5
Last updated at Posted at 2015-09-02

デバイスファイル

/dev/consoleとりあえずみてみた

  • メジャー番号とマイナー番号が入っているただの箱
  • catとかしてもなんか反応しなかった…
ls -lsa /dev/console 
0 crw-------  1 hoge  staff    0,   0  8 16 06:08 /dev/console
メジャー番号、マイナー番号どこで生成しているのだろうか
  • insmodっぽい
  • insmod ドライバファイル.o
    • そしたらドライバファイルの中のinsmodに対する関数が実行
    • その中でメジャー番号の確保,システムコールハンドラの登録、カーネルへの登録(対応表みたいなやつ)
  • insmodあと下のようなコマンドでメジャー番号をみつけて
cat /proc/devices | grep hoge
  • それを元にmknod メジャー番号 したような。

insmod

  • カーネルに対して動的リンクする
    • 動的リンク
      • メモリ再配置してカーネルの対応表を埋めてセクションをまとめる(.textとかその他もろもろ)

open

その後にopen()したような
プロセスとドライバのinodeを結んでファイルを開くようにfopみたいなドライバのオペレーションをfile構造体に設定して、ドライバの各関数を使用できるようにする。

5
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?