1

私は単純な jiffies コードを書きましたが、rmmod を実行しようとすると、

ERROR: Removing 'jiffi_module': Device or resource busy

だから私は少し調査を行い、「永続的」の症状の下でlsmodを実行することで発見しました。これは、exit_functionが見つからないために引き起こされる問題です。

Module                  Size  Used by
jiffi_module            1027  0 **[permanent]**

実際、私のmakeファイルには、終了機能に関連する警告が表示されます

exit 関数が次のように定義されている場合の警告

static void __exit
jif_exit(void)
{
    remove_proc_entry("jif", NULL);
}

warning: data definition has no type or storage class
warning: type defaults to ‘int’ in declaration of ‘modile_exit’
warning: parameter names (without types) in function declaration
warning: ‘jif_exit’ defined but not used

__exit を削除すると、少なくとも jif_exit が識別されるように見えるため、表示される警告は次のとおりです。

warning: data definition has no type or storage class
warning: type defaults to ‘int’ in declaration of ‘modile_exit’
warning: parameter names (without types) in function declaration

以下を読んで、このカーネルモジュールが2.6.39で永続的にマークされているのはなぜですか

それは問題であるgccの不一致について話しますか?誰かがそれ以上デバッグできないのを手伝ってもらえますか? 永続的でないようにモジュールを適切にロードする方法はありますか?

4

1 に答える 1

1

カーネル モジュールは、終了関数が定義されていpermanentない場合、(アンロードできません)とマークされます。

exit関数は引数を受け入れず、何も返さず、定義済みの名前で定義する必要があります

void cleanup_module(void)
{
    ...
}

または任意の名前ですが、module_exitマクロで登録されています

void <func_name>(void)
{
    ...
}

module_exit(<func_name>);

exit関数のstatic__exitおよびその他の属性はオプションです。

于 2015-11-01T16:14:37.733 に答える