私はいくつかのSDKを試しましたが、今のところ進歩はありますが、 insmodが返します0(成功)とlsmodはそれらを示していますが、printkもcreate_proc_entryも動作しません....しかし、私はセクション.gnu.linkonce.this_moduleを見ました:モジュール名を除く - 有用な情報はありません - セクションは0x0カーネルモジュールがロードされていない(しかし、insmodは0を返します)
セクション.gnu.linkonce.this_moduleのデバイスサイズがネイティブの.koファイルであることが判明しました。これは8バイトになりますが、セクションが構造モジュールへの一時的な読み込み情報として使用されているという事実によると私の意見に関係なく...
https://ufile.io/eco1sいくつかのファイルがあります:khelloworld.ko - 私のhelloworldモジュール - procfsエントリを作成しようとしました。khelloworld.ko - rootfs(/tmp/test.file)のネイティブモジュールにファイルを作成しようとしました:xt_mark.ko md5.ko cbc。 KO
私はカーネルのコンフィギュレーションを持っていない - しかし、私はそのモジュールをコンパイルする必要があります...私は唯一のバージョン
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/proc_fs.h> /* Necessary because we use the proc fs */
#include <linux/init.h> /* Needed for the macros */
#define procfs_name "khelloworld"
MODULE_LICENSE("GPL");
MODULE_INFO(vermagic, "2.6.32.68 mod_unload MIPS32_R2 32BIT ");
MODULE_AUTHOR ("XAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
struct proc_dir_entry *Our_Proc_File;
static int
procfile_read(char *buffer,
char **buffer_location,
off_t offset, int buffer_length, int *eof, void *data);
static int __init khelloworld_init(void) {
printk(KERN_INFO "try to create /proc \n");
Our_Proc_File = create_proc_entry(procfs_name, 0644, NULL);
if (Our_Proc_File == NULL) {
remove_proc_entry(procfs_name, NULL);
printk(KERN_ALERT "Error: Could not initialize /proc/%s\n",
procfs_name);
return -ENOMEM;
}
Our_Proc_File->read_proc = procfile_read;
Our_Proc_File->owner = THIS_MODULE;
Our_Proc_File->mode = S_IFREG | S_IRUGO;
Our_Proc_File->uid = 0;
Our_Proc_File->gid = 0;
Our_Proc_File->size = 37;
printk(KERN_INFO "/proc/%s created\n", procfs_name);
return 3; /* everything is ok */
}
static void __exit khelloworld_exit(void) {
remove_proc_entry(procfs_name, NULL);
printk(KERN_INFO "/proc/%s removed\n", procfs_name);
}
module_init(khelloworld_init);
module_exit(khelloworld_exit);
int
procfile_read(char *buffer,
char **buffer_location,
off_t offset, int buffer_length, int *eof, void *data)
{
int ret;
printk(KERN_INFO "procfile_read (/proc/%s) called\n", procfs_name);
/*
* We give all of our information in one go, so if the
* user asks us if we have more information the
* answer should always be no.
*
* This is important because the standard read
* function from the library would continue to issue
* the read system call until the kernel replies
* that it has no more information, or until its
* buffer is filled.
*/
if (offset > 0) {
/* we have finished to read, return 0 */
ret = 0;
} else {
/* fill the buffer, return the buffer size */
ret = sprintf(buffer, "HelloWorld!\n");
}
return ret;
}
ようこそスタックオーバーフロー!ここでは、問題のコードやその他の情報(ビルドログなど)を**リンクされていない**質問の投稿自体に含めます。あなたの質問を編集して、その問題を修正してください。 – Tsyvarev