proc_creat_test

#include <linux/init.h>
#include <linux/module.h>


#include <linux/seq_file.h>
#include <linux/proc_fs.h>
static int mytest_proc_show(struct seq_file *seq, void *v)
{
 seq_puts(seq,"yang_cf22\n");
 return 0;
}
static int mytest_proc_open(struct inode *inode,struct file *filp)
{
        return single_open(filp,mytest_proc_show,NULL);
}
static const struct file_operations mytest_proc_fops = {
 .open  = mytest_proc_open,
 .read  = seq_read,
 .llseek  = seq_lseek,
 .release = single_release,
};
static void mytest_protc_crate(void)
{
    proc_create("my_proc_test2",0444,NULL,&mytest_proc_fops);
}


static int __init hello_init(void)
{
    printk("<0> Hello, world!\n");
    mytest_protc_crate();
    return 0;
}


static void __exit hello_exit(void)
{
    printk("<0> Hello, exit!\n");
}


module_init(hello_init);
module_exit(hello_exit);
MODULE_LICENSE("Dual BSD/GPL");

猜你喜欢

转载自blog.csdn.net/yangchaofeng001/article/details/46808005