LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-15-2003, 03:03 AM   #1
unicorn21
LQ Newbie
 
Registered: Dec 2003
Location: Brisbane
Posts: 5

Rep: Reputation: 0
writing driver modules


Hi!
I am having trouble with the first stage of my mission.
I am trying to compile some code to make a beginners module.
When I compile it I get some errors.
1)
It doesn't know what KERN_INFO is
I looked at the /usr/include/linux/kernel.h and it only has 1 sysinfo struct in there.
I did a search on the kernel.h file and other ones I found had the #defines in them which is how I knew what to write. I added this line into my own source file which removed the error...
#define KERN_INFO "<6>"
2) I compile it 'gcc -c driver.c' #and it happily creates a driver.o file
I then go 'insmod -f ./driver.o'

Warning: kernel-module version mismatch
./driver.o was compiled for kernel version 2.4.9-9
while this kernel is version 2.4.20-24.8

Am I doing this right?

#define MODULE
#include <linux/module.h>
#include <linux/kernel.h>

int init_module(void)
{
printk(KERN_INFO "Hello, world\n");
return 0;
}

void cleanup_module(void)
{
printk(KERN_INFO "Goodbye cruel world\n");
}

I am running Redhat 8.0 with 2.4.20-24 kernel & Redhat 9 2.4.20-8
Has anyone tryed this before?
 
Old 12-15-2003, 01:01 PM   #2
h/w
Senior Member
 
Registered: Mar 2003
Location: New York, NY
Distribution: Debian Testing
Posts: 1,286

Rep: Reputation: 46
heres a previous post -
http://www.linuxquestions.org/questi...hreadid=125248
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Writing Modules djgerbavore Programming 4 05-20-2005 03:58 PM
writing driver alice95089 Linux - Software 0 04-06-2005 03:55 AM
writing modules for 2.6 afrodocter Linux - Software 0 06-20-2004 08:55 PM
Writing my own wireless driver? saajii Linux - Wireless Networking 3 05-16-2004 10:22 PM
Writing Driver Software dr_who Linux - Networking 3 09-18-2003 08:01 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:46 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration