不能再简化

 #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 OS Terminal 几个快捷键

    在Mac系统中几个键位组合可以使Terminal的操作更加灵活方便. 1.将光标移动到行首:ctrl + a 2.将光标移动到行尾:ctrl + e 3.清除屏幕:            ctrl + ...

  2. PowerShell添加或修改注册表开机启动项脚本

    代码如下: $name = Read-Host "请输入开机启动项的名字(随便起)" $value = Read-Host "请输入开机启动项的值" try{ ...

  3. org.eclipse.swt.custom.StyledText.getScrollbarsMode()I

    错误: org.eclipse.swt.custom.StyledText.getScrollbarsMode()I 解决方法: 1 卸载,并手工清除myeclipse全部文件 2 重新安装myecl ...

  4. 微信小程序-表单

    wxml <view> 按钮: <button size="{{buttom.size}}" type="{{buttom.type}}" p ...

  5. QAbstractItemView::setRootIndex(const QModelIndex & index) 失效

    问题: 在逻辑中使用了, QAbstractItemView::setRootIndex(const QModelIndex & index), 第一次设置生效, view 进入了model ...

  6. Jenkins console输出乱码???

    jenkins console输出乱码??? 在jenkins中job执行shell,console中出现乱码如下: [WARNING] /home/mtime/data/jenkins/worksp ...

  7. 特许金融分析师 (CFA) 持证人现在一般在做什么工作?职业分布是怎样的?

    特许金融分析师 (CFA) 持证人现在一般在做什么工作?职业分布是怎样的?  陈雨桐 1. 全球范围: 根据 CFA 协会 2014 年 6 月的报告: CFA Institute has over ...

  8. CSRF token 无法被验证. ----Yii连接数据库后数据库错误日志报错

    CSRF token 无法被验证. 我使用的是mongodb+ yii1.1 What is CSRF, please see the details here.  http://en.wikiped ...

  9. ubuntu16 修改apache端口号

    p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px "Hannotate SC" } span.s1 { } (1)apach ...

  10. flask笔记3-模板

    flask框架使用jinja2模板引擎.简单的说,模板就是一个纯html文件中夹杂着占位符,在渲染模板时用真实变量值替换占位符,就形成了最终的前台页面. 1.模板存放位置: 默认情况下,flask在根 ...