0

私は Linux の初心者で、カーネル モジュールのプログラミングについていくつか質問があります。ubuntu と C を使用して .ko ファイルを作成しています。プログラム /a が呼び出されるたびに /a の代わりにプログラム /b を実行するモジュールを作成しようとしています。任意のヒント?

また、printk (KERN_EMERG...) を使用しても、端末に出力されません。不足している設定はありますか、それともubuntuはそれを行いませんか?

どうもありがとう!

4

2 に答える 2

1

/proc/sys/kernel/printkコンソールに表示されるレベルを制御するの設定を変更する必要がある場合があります。からproc(5):

   /proc/sys/kernel/printk
          The four values in this file are console_loglevel,
          default_message_loglevel, minimum_console_level, and
          default_console_loglevel.  These values influence
          printk() behavior when printing or logging error
          messages.  See syslog(2) for more info on the
          different loglevels.  Messages with a higher priority
          than console_loglevel will be printed to the console.
          Messages without an explicit priority will be printed
          with priority default_message_level.
          minimum_console_loglevel is the minimum (highest)
          value to which console_loglevel can be set.
          default_console_loglevel is the default value for
          console_loglevel.

nice(2)値と同様に、値が小さいほど優先度が高いことに注意してください。

実行するexecve()for パスを作成する最も簡単な方法は、上にバインドマウントすることです:/foo/a/foo/b/foo/b/foo/a

mount -obind /foo/b /foo/a

カーネル モジュールは必要ありません。

カーネル モジュールでこれと同じタスクを実行すると、作業が大幅に増えます。LSM インターフェースは、ターゲットがいつ実行されているかを正確に把握するのに役立ちます。do_execve()出発点を探している場合fs/exec.cは、ここから読み始めてください。コードを読みやすくするためにctags、エディターの統合をインストールして実行し、使用方法を知っていることを確認してください。ctags

于 2012-05-03T01:08:29.557 に答える