Results 1 to 6 of 6
hi friends,
Iam new to Kernel Programming.
I just started by a basic example given in the book
My Kernel Version is 2.6.24.2 and OS is Federo Core 9
example ...
- 05-20-2008 #1Just Joined!
- Join Date
- May 2008
- Posts
- 5
kernel programming starter
hi friends,
Iam new to Kernel Programming.
I just started by a basic example given in the book
My Kernel Version is 2.6.24.2 and OS is Federo Core 9
example program hello.c is
//////////////////////////////////////////////////////
#include <linux/module.h>
#include <linux/kernel.h>
int init_module(void)
{
printk("<1>Hello world 1.\n");
return 0;
}
void cleanup_module(void)
{
printk(KERN_ALERT "Goodbye world 1.\n");
}
--------------------------------------------------
makefile is
obj−m += hello.o
at command prompt i gave the command
make -C /usr/src/linux-`uname -r` SUBDIRS=$PWD modules
but the result is
make: Entering directory `/usr/src/linux−2.6.24.2
Building modules, stage 2.
MODPROBE 0 modules
make: Leaving directory `/usr/src/linux−2.6.24.2
its not creating the corresponding .ko files
plz help me where i have gone wrong
- 05-20-2008 #2Linux Newbie
- Join Date
- Mar 2008
- Location
- Hyderabad
- Posts
- 109
You forgot to add
module_init(init_module);
module_exit(cleanup_module);
at end of the c file.
- 05-20-2008 #3Just Joined!
- Join Date
- May 2008
- Posts
- 5
i tried what u have told
but still its giving the same output
- 05-20-2008 #4Linux Newbie
- Join Date
- Mar 2008
- Location
- Hyderabad
- Posts
- 109
Add
MODULE_LICENSE("GPL");
in your C file.
Make a Makefile in the same directory with the content
ifneq ($(KERNELRELEASE),)
obj-m := hello.o
else
KERNELDIR ?= <Your Kernel path>
PWD := $(shell pwd)
default:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
endif
and use make command to compile.
- 05-20-2008 #5Just Joined!
- Join Date
- May 2008
- Posts
- 5
thanks vijay
i got that . But inspite of giving the priority level as 1 . The output is getting
written to /var/log/messages file instead of console.
- 05-21-2008 #6Linux Newbie
- Join Date
- Mar 2008
- Location
- Hyderabad
- Posts
- 109
If you are expecting the result on X terminal then you are wrong.
Press Ctrl + Alt + F1 login and run thre program you will get your result.
Cheers


Reply With Quote
