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.
";
        strcpy(page,s);
        *eof=1;
        return strlen(s);
}

int init_meng_proc(void)
{
        create_proc_read_entry("mengproc",0,NULL,meng_read_proc,NULL);
        return 0;
}
void exit_meng_proc(void)
{
        remove_proc_entry("mengproc",NULL);
}
module_init(init_meng_proc);
module_exit(exit_meng_proc);
原文地址:https://www.cnblogs.com/mengqingzhong/p/3746096.html