易截截图软件、单文件、免安装、纯绿色、仅160KB

linux内核模块编程之符号导出

很简单的一个程序,sub模块提供两个函数sub_integer,add_integer,并将其导出到内核符号表中,sub_test模块对这两个函数进行调用。这算是自己写的第一个内核模块程序吧,纪念一下.
sub.c:
#include<linux/init.h>
#include<linux/kernel.h>
#include<linux/module.h>
MODULE_LICENSE("Dual BSD/GPL");
//int add_integar(int,int);
//int sub_integar(int,int);
int add_integer(int a,int b){
return a+b;
}
int sub_integer(int a,int b){
return a-b;
}
int __init mod_init(){
printk(KERN_ALERT "the first module program");
return 0;
}
void __exit mod_exit(){
printk(KERN_ALERT "i like u");
}
EXPORT_SYMBOL(add_integer);
EXPORT_SYMBOL(sub_integer);
module_init(mod_init);
module_exit(mod_exit);
sub_test.c:
#include<linux/module.h>
#include<linux/kernel.h>
#include<linux/init.h>
MODULE_LICENSE("Dual BSD/GPL");
extern int sub_integer(int,int);
extern int add_integer(int,int);
int __init test1(void){
int a=sub_integer(3,1);
int b=add_integer(2,2);
printk(KERN_ALERT"sub:%d\nadd:%d\n",a,b);
return 0;
}
void __exit test2(void){
printk(KERN_ALERT"bybye\n");
}
module_init(test1);
module_exit(test2);
对这两个函数的引用应该有比extern更好的方式,要是都extern就太麻烦了


相关文档:

实战Linux Bluetooth编程(三) HCI层编程

1. HCI层协议概述:
HCI提供一套统一的方法来访问Bluetooth底层。如图所示:
从图上可以看出,Host Controller Interface(HCI)  就是用来沟通Host和Module。Host通常就是PC, Module则是以各种物理连接形式(USB,serial,pc-card等)连接到PC上的bluetooth Dongle。
在Host这一端:application,SDP,L2cap等协议 ......

实战Linux Bluetooth编程 (七) SDP协议

Service Discovery Protocol(SDP)提供一种能力,让应用程序有方法发现哪种服务可用以及这种服务的特性。
服务发现协议(SDP或Bluetooth SDP)在蓝牙协议栈中对蓝牙环境中的应用程序有特殊的含意,发现哪个服务是可用的和确定这些可用服务的特征。SDP定义了bluetooth client发现可用bluetooth server服务和它们的特征的方法。 ......

Linux环境下MySQL的安装

1、下载MySQL免安装版/二进制版软件(不用编译)
文件格式:MYSQL-VERSION-OS.tar.gz
 
2、创建MySQL组,建立MySQL用户并加入到mysql组中
(不同版本的Unix中,groupadd和useradd的语法可能会稍有不同。)
#groupadd mysql
#useradd -g mysql mysql
 
3、进入目录/usr/local,解压缩免安装版,并在 ......

linux 之 ifconfig 命令!

一般在linux下查看网络配置可以使用ifconfig命令,可以显示当前网卡的基本配置信息。
终端输入ifconfig 会出现一下内容:
eth0
Link encap:Ethernet HWaddr 00:0C:29:0C:4B:0F
inet addr:192.168.37.128 Bcast:192.168.37.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:33 er ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号