易截截图软件、单文件、免安装、纯绿色、仅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编程 (七) SDP协议

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

在Linux下安装和使用MySQL

1、下载MySQL的安装文件
安装MySQL需要下面两个文件:
MySQL-server-4.0.23-0.i386.rpm  
MySQL-client-4.0.23-0.i386.rpm
下载地址为:http://www.mysql.com/downloads/mysql-4.0.html,打开此网页,下拉网页找到“Linux x86 RPM downloads”项,找到
“Server”和“Client programs&rd ......

linux Bell 报警声音

Console 修改/etc/inputrc文件

set bell-style off
VIM 如果是在 console 模式下使用 vi/vim,一旦按错键会发出 bi 的一声,这样做可以提醒我们,但是很多时候会影响其他人工作、学习或者休息,如何关闭呢?
可以在 vi/vim 中使用
:set noeb
命令(其中 noeb 是 noerrorbells 的缩写) ......

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号