|
/*************************/
test.c
/**************************/
#ifndef __KERNEL__
#define __KERNEL__
#endif
#ifndef
MODULE
#define MODULE
#endif
#include
<linux/init.h>
#include <linux/module.h>
#include
<linux/kernel.h>
#include "cheader.h"
static int w=7;
static int hello_init(void)
{
int i = dosth();
printk(KERN_ALERT "Hello,%d The fucking crazy world!\n",i);
return
0;
}
static void hello_exit(void)
{
printk(KERN_ALERT "Bye,%d The
fucking crazy world!\n",w);
}
module_init(hello_init);
module_exit(hello_exit);
module_param(w,int,S_IRUGO);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("albcamus");
/***********************************/
Makefile
/***********************************/
obj-m := t.o
t-objs := test.o file.o
KERNELBUILD :=
/lib/modules/2.6.33.7/build
default:
make -C $(KERNELBUILD) M=$(shell
pwd) modules
clean:
rm -f *.o .*.cmd *.ko *.mod.c
rm -rf
.tmp_versions
rm -rf modules.order
rm -rf Module.symvers
/***************************************/
cheader.h
/**************************************/
int dosth(void);
/**************************************/
#include "cheader.h"
int dosth(){
int i=1;
return ++i;
}
/**************************************/
#make
#insmod t.ko w=10
#rmmod t.ko
#vi /var/log/message
|Archiver|手机版|小黑屋|软路由 ( 渝ICP备15001194号-1|渝公网安备 50011602500124号 )
GMT+8, 2024-5-6 19:47 , Processed in 0.036496 second(s), 6 queries , Gzip On, Redis On.
Powered by Discuz! X3.5 Licensed
© 2001-2023 Discuz! Team.