不能再简化

 #include<linux/module.h>
#include<linux/init.h> #include<linux/seq_file.h>
#include<linux/fs.h>
#include <linux/proc_fs.h>
void * meng_seq_start(struct seq_file*s,loff_t*pos)
{
if(*pos>)
return NULL;
return pos;
} void * meng_seq_next(struct seq_file*s,void *v,loff_t*pos)
{
(*pos)++;
if(*pos>)
return NULL;
return pos;
} void meng_seq_stop(struct seq_file*s,void *v)
{
}
char *meng_seq_data[]={"Hello.\n","This meng seq proc file.\n"}; int meng_seq_show(struct seq_file*s,void *v)
{
seq_printf(s,meng_seq_data[*((int*)v)]);
return ;
}
struct seq_operations meng_seq_ops={
.start=meng_seq_start,
.next=meng_seq_next,
.stop=meng_seq_stop,
.show=meng_seq_show
};
int meng_seq_proc_seq_open(struct inode*inode,struct file*file)
{
return seq_open(file,&meng_seq_ops);
} struct file_operations meng_seq_proc_ops=
{
.owner=THIS_MODULE,
.open=meng_seq_proc_seq_open,
.read=seq_read,
.llseek=seq_lseek,
.release=seq_release
}; int meng_seq_proc_init(void)
{
struct proc_dir_entry *entry=create_proc_entry("mengprocseq",,NULL);
if(entry)
entry->proc_fops=&meng_seq_proc_ops;
return ;
} void meng_seq_proc_exit(void)
{
remove_proc_entry("mengprocseq",NULL);
} module_init(meng_seq_proc_init);
module_exit(meng_seq_proc_exit);

Linux 设备驱动程序 proc seq的更多相关文章

  1. Linux 设备驱动程序 proc

    不能再简化了 #include<linux/module.h> #include<linux/init.h> #include<linux/proc_fs.h> i ...

  2. Linux设备驱动程序 第三版 读书笔记(一)

    Linux设备驱动程序 第三版 读书笔记(一) Bob Zhang 2017.08.25 编写基本的Hello World模块 #include <linux/init.h> #inclu ...

  3. Linux设备驱动程序学习之分配内存

    内核为设备驱动提供了一个统一的内存管理接口,所以模块无需涉及分段和分页等问题. 我已经在第一个scull模块中使用了 kmalloc 和 kfree 来分配和释放内存空间. kmalloc 函数内幕 ...

  4. Linux设备驱动程序学习----3.模块的编译和装载

    模块的编译和装载 更多内容请参考Linux设备驱动程序学习----目录 1. 设置测试系统 第1步,要先从kernel.org的镜像网站上获取一个主线内核,并安装到自己的系统中,因为学习驱动程序的编写 ...

  5. 嵌入式Linux设备驱动程序:在运行时读取驱动程序状态

    嵌入式Linux设备驱动程序:在运行时读取驱动程序状态 Embedded Linux device drivers: Reading driver state at runtime 在运行时了解驱动程 ...

  6. 嵌入式Linux设备驱动程序:编写内核设备驱动程序

    嵌入式Linux设备驱动程序:编写内核设备驱动程序 Embedded Linux device drivers: Writing a kernel device driver 编写内核设备驱动程序 最 ...

  7. linux设备驱动程序该添加哪些头文件以及驱动常用头文件介绍(转)

    原文链接:http://blog.chinaunix.net/uid-22609852-id-3506475.html 驱动常用头文件介绍 #include <linux/***.h> 是 ...

  8. 【转】linux设备驱动程序中的阻塞机制

    原文网址:http://www.cnblogs.com/geneil/archive/2011/12/04/2275272.html 阻塞与非阻塞是设备访问的两种方式.在写阻塞与非阻塞的驱动程序时,经 ...

  9. 教你写Linux设备驱动程序:一个简短的教程

    教你写Linux设备驱动程序:一个简短的教程 http://blog.chinaunix.net/uid-20799298-id-99675.html

随机推荐

  1. Mac 快捷键

    总结一下: Ctrl + 关机:弹出关机提示 Ctrl + Opt + 关机 : 正常关机快捷键 Cmd + Opt + 关机 :休眠 Ctrl + Cmd + 关机:重启 Shift + Ctrl ...

  2. RMQ

    1.概念: RMQ(Range Minimum/Maximum Query),即区间最值查询,是指这样一个问题:对于长度为n的数列A,回答若干询问RMQ(A,i,j)(i,j<=n),返回数列A ...

  3. php set_time_limit()用法测试详解

    在php中set_time_limit函数是用来限制页面执行时间的,如我想把一个php页面的执行时间定义为5秒就可以set_time_limit(5)了.   一个php脚本通过crontab每5分钟 ...

  4. python两种生成md5的方法

    一. 使用md5包 import md5 src = 'this is a md5 test.' m1 = md5.new() m1.update(src) print m1.hexdigest() ...

  5. iframe在浏览器中session失效问题

    iis中右击项目属性http头 添加一个http头 X-UA-Compatible 自定义http头值 IE=EmulateIE7 这样设置后就可以了

  6. 两个平行div之间有间隙

    两个平行的div使用 display: inline-block 会导致元素之间有空隙解决方法: 父元素设置 font-size: 0;

  7. 慕课网__CSS__vertical align

  8. hibernate一级缓存的源码初窥

    hibernate的一级缓存的存在使得hibernate可以在操作实体化对象的时候减少对于数据库的访问.hibernate的一级缓存实际上就是指的session缓存,它的生命周期和session相同. ...

  9. 【A Global Line Matching Algorithm for 2D Laser Scan Matching in Regular Environment】

    只看了前面的部分,灭有看实验,觉得整体风格比较傻白甜,与我的想法不谋而合.简单明了,用起来应该比较方便. 初步探测:如果有直线,就给线性插值一下. 分级聚类:利用简单的阈值给聚类了一下,分成了段段. ...

  10. Evolutionary Computing: Assignments

    Assignment 1: TSP Travel Salesman Problem Assignment 2: TTP Travel Thief Problem The goal is to find ...