From: Nick Warne <nick@linicks.net>
To: linux-kernel@vger.kernel.org, ilan_sk@netvision.net.il
Subject: Re: 'hello world' module
Date: Sat, 11 Jun 2005 16:53:34 +0100 [thread overview]
Message-ID: <200506111653.34161.nick@linicks.net> (raw)
Hi Ilan,
I don't know about the Oh Really! version, but this one taken from 'Beginning
Linux Programming' (forward by Alan Cox!) ISBN 1-861002-97-1 worked OK for
me.
2.4.31, GCC 3.4.4
Build like:
gcc -D__KERNEL__ -I/usr/src/linux/include -DMODULE -Wall -O2 -c hello.c -o
hello.o
Edit hello.c to suit:
#include <linux/module.h>
#if defined(CONFIG_SMP)
#define __SMP__
#endif
#if defined(CONFIG_MODVERSIONS)
#define MODVERSIONS
#include <linux/modversions.h>
#endif
#include <linux/kernel.h>
MODULE_AUTHOR ("Nick Warne <nick@linicks.net>");
MODULE_DESCRIPTION ("Hello Kernel! module");
MODULE_LICENSE("GPL");
int init_module(void)
{
printk(KERN_DEBUG "Hello, kernel!\n");
return 0;
}
void cleanup_module(void)
{
printk(KERN_DEBUG "Good-bye, kernel!\n");
}
bash-2.05b# insmod hello.o
bash-2.05b# dmesg | tail -n1
Hello, kernel!
bash-2.05b# lsmod
Module Size Used by Tainted: P
hello 320 0 (unused)
bash-2.05b# rmmod hello
bash-2.05b# dmesg | tail -n1
Good-bye, kernel!
Hope that helps.
Nick
--
"When you're chewing on life's gristle,
Don't grumble, Give a whistle..."
next reply other threads:[~2005-06-11 15:53 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-06-11 15:53 Nick Warne [this message]
-- strict thread matches above, loose matches on Subject: below --
2005-06-13 17:50 'hello world' module Nick Warne
2005-06-11 16:54 Nick Warne
2005-06-11 17:06 ` Jan Engelhardt
[not found] <4egz4-2tj-15@gated-at.bofh.it>
2005-06-11 16:25 ` Robert Hancock
2005-06-11 16:31 ` Jan Engelhardt
2005-06-11 12:11 Ilan S.
2005-06-11 18:17 ` Sam Ravnborg
2005-06-11 20:25 ` Jan Engelhardt
2005-06-12 19:17 ` Sam Ravnborg
2005-06-11 19:43 ` Jesper Juhl
2005-06-13 20:09 ` Edward Macfarlane Smith
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200506111653.34161.nick@linicks.net \
--to=nick@linicks.net \
--cc=ilan_sk@netvision.net.il \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox