Linux 设备驱动程序 proc seq
不能再简化
#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的更多相关文章
- Linux 设备驱动程序 proc
不能再简化了 #include<linux/module.h> #include<linux/init.h> #include<linux/proc_fs.h> i ...
- Linux设备驱动程序 第三版 读书笔记(一)
Linux设备驱动程序 第三版 读书笔记(一) Bob Zhang 2017.08.25 编写基本的Hello World模块 #include <linux/init.h> #inclu ...
- Linux设备驱动程序学习之分配内存
内核为设备驱动提供了一个统一的内存管理接口,所以模块无需涉及分段和分页等问题. 我已经在第一个scull模块中使用了 kmalloc 和 kfree 来分配和释放内存空间. kmalloc 函数内幕 ...
- Linux设备驱动程序学习----3.模块的编译和装载
模块的编译和装载 更多内容请参考Linux设备驱动程序学习----目录 1. 设置测试系统 第1步,要先从kernel.org的镜像网站上获取一个主线内核,并安装到自己的系统中,因为学习驱动程序的编写 ...
- 嵌入式Linux设备驱动程序:在运行时读取驱动程序状态
嵌入式Linux设备驱动程序:在运行时读取驱动程序状态 Embedded Linux device drivers: Reading driver state at runtime 在运行时了解驱动程 ...
- 嵌入式Linux设备驱动程序:编写内核设备驱动程序
嵌入式Linux设备驱动程序:编写内核设备驱动程序 Embedded Linux device drivers: Writing a kernel device driver 编写内核设备驱动程序 最 ...
- linux设备驱动程序该添加哪些头文件以及驱动常用头文件介绍(转)
原文链接:http://blog.chinaunix.net/uid-22609852-id-3506475.html 驱动常用头文件介绍 #include <linux/***.h> 是 ...
- 【转】linux设备驱动程序中的阻塞机制
原文网址:http://www.cnblogs.com/geneil/archive/2011/12/04/2275272.html 阻塞与非阻塞是设备访问的两种方式.在写阻塞与非阻塞的驱动程序时,经 ...
- 教你写Linux设备驱动程序:一个简短的教程
教你写Linux设备驱动程序:一个简短的教程 http://blog.chinaunix.net/uid-20799298-id-99675.html
随机推荐
- Android 进程常驻----native保活5.0以下方案推演过程以及代码
正文: 今天继续昨天,一鼓作气,争取这个礼拜全部写完. 上一篇文章留了一个别人的github链接,他里面的native保活实现方案也是大多数公司采用的方案. 我们先来讲一下他的方案. 他是首先开启一个 ...
- Windows普通窗口程序
2015-10-09 12:55:38 KWindow.h #pragma once #include <windows.h> class KWindow { virtual void O ...
- ABAP SPLIT
注意: 假定'\'为分隔符 * '1'会分成1部分,值为1 * 分隔符之前的即使是空白或没有,也算一部分. 最后一个分隔符之后的,若有值会算一部分.若没有值,则不会算 比如'\1\'会分成2部分 '\ ...
- ABAP宏--Macros
定义语法 DEFINE macro. ... &1 ... &9 ... END-OF-DEFINITION. 调用语法: macro [p1 p2 ... ]. 最多时能有9参数 例 ...
- sql-按周输出每月的周日期范围
--日期参数,此处可以建立存储过程,接收月份,计算月开始结束时间或者直接接受开始与结束时间 declare @begDate datetime = '2014-06-01' declare @endD ...
- python之初级学习
一.python安装 1.下载安装包(本人使用python3.5.1) https://www.python.org/downloads/ 2.安装python-3.5.1.exe 本人下载的是pyt ...
- MVC架构 使用FastReport
1.Web.config文件 添加配置 <httpHandlers> <add path="FastReport.Export.axd" verb="* ...
- linux运行级别
也许大家偶然会发现/sbin里有个init命令.你知道它是如何使用的吗? 如果你不喜欢使用图形登录方式,如何能够让用户在控制台下运行startx命令呢? 有时你要维护服务器,暂时不希望别的用户登录系统 ...
- Maven教程
找了一个很详细的maven教程 收藏下 学习网址:http://www.yiibai.com/maven/
- mySQL 50个查询系列
http://bubufx.com/detail-1749088.html http://www.jb51.net/article/67932.htm Student(S#,Sname,Sage,Ss ...