기존 장치 (mips arch)에 몇 가지 기능을 추가했습니다. 몇 가지 SDK를 시험해 보았습니다. 현재로서는 몇 가지 진도가 있지만, insmod returns 0 (성공) 및 lsmod 보여줍니다하지만 printk 또는 create_proc_entry 작동하지 않습니다 ....하지만 섹션 .gnu.linkonce.this_module 본 : 모듈 이름 제외 - 유용한 정보가 없습니다 - 섹션은 0x0으로 채워집니다.커널 모듈이로드되지 않았지만 (insmod는 0을 반환합니다.)
섹션 .gnu.linkonce.this_module의 디바이스 크기가 .ko 파일의 원시 .ko 파일에서 8 바이트로 작다는 것을 알았지 만,이 섹션이 구조 모듈에 대한 임시로드 정보로 사용된다는 사실에 따르면 내 의견에 상관 없습니다 ...
https://ufile.io/eco1s 여러 파일이 있습니다. khelloworld.ko - 내 helloworld 모듈 - procfs 항목을 작성하십시오. khelloworld.ko - rootfs (/tmp/test.file) 기본 모듈에 파일을 작성하십시오. xt_mark.ko md5.ko cbc. 코
나는 커널 구성이없는 -하지만 난
#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