Linux 设备驱动程序 proc

时间:2023-03-09 04:01:09
Linux 设备驱动程序  proc

不能再简化了

#include<linux/module.h>
#include<linux/init.h> #include<linux/proc_fs.h> int meng_read_proc(char*page,char**start,off_t offset,int count,int*eof,void*data)
{
char*s="Hello. This is meng proc file.\n";
strcpy(page,s);
*eof=;
return strlen(s);
} int init_meng_proc(void)
{
create_proc_read_entry("mengproc",,NULL,meng_read_proc,NULL);
return ;
}
void exit_meng_proc(void)
{
remove_proc_entry("mengproc",NULL);
}
module_init(init_meng_proc);
module_exit(exit_meng_proc);