不能再简化

 #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. 【前端】从输入URL到页面加载完成的过程中都发生了什么事情

    把URL分割成几个部分:协议(http, https).网络地址(xxx.xxx.xxx.xxx).资源路径(/xxx/xxx.xx).端口号(默认80). 如果地址不是一个IP地址,通过DNS(域名 ...

  2. Mybatis映射文件

    Mapper XML 文件 MyBatis 的真正强大在于它的映射语句,也是它的魔力所在.由于它的异常强大,映射器的 XML 文件就显得相对简单.如果拿它跟具有相同功能的 JDBC 代码进行对比,你会 ...

  3. Django 步骤

    1. 初始化项目 django-admin startproject mysite2. 设置 settings 数据库配置, 必要时手动创建数据库3. 初始化数据库 python manage.py ...

  4. Latex环境安装

    安装latex环境 sudo apt-get install texlive-full 推荐使用texstudio编辑器,简单方便高效靠谱 sudo apt-get install texstudio ...

  5. VirtualBox虚拟机运行Ubuntu如何不卡

    VirtualBox虚拟机运行Ubuntu如何不卡 转自http://www.xuzefeng.com/post/85.html 上一篇文章<VirtualBox虚拟机安装Ubuntu详细教程& ...

  6. Codeforces 722C. Destroying Array

    C. Destroying Array time limit per test 1 second memory limit per test 256 megabytes input standard ...

  7. moq 的常用使用方法

    测试方法                             Console.WriteLine(mock.Object.GetCountThing()); 匹配参数   mock.Setup(x ...

  8. 巧用CSS3伪类选择器自定义checkbox和radio的样式

    由于原生的checkbox和radio的样式太简陋了,在设计页面的时候,设计师往往会设计自己的checkbox和radio样式.一半情况下,为了适应各个浏览器的兼容性,我们都会用其他的元素替代原生的c ...

  9. python走起之第十五话

    CSS Positioning(定位) 定位有时很棘手! 决定显示在前面的元素! 元素可以重叠! Positioning(定位) CSS定位属性允许你为一个元素定位.它也可以将一个元素放在另一个元素后 ...

  10. hdu-5525 Product(费马小定理)

    题目来源:http://bestcoder.hdu.edu.cn/contests/contest_chineseproblem.php?cid=644&pid=1003 前面用奇偶性约掉2, ...