LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 11-03-2007, 02:41 PM   #16
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 78

Quote:
Originally Posted by sniffer_raghav View Post
problem is that
printk is not giving message on the terminal
You are not in userspace.

printf() — print formatted strings to stdout (i.e., “the terminal”).

printk() — print formatted strings of a specific priority on the (circular) kernel log buffer.

It is up to you how to access the kernel log buffer. Some examples include using the dmesg utility, opening a userspace connection to /proc/kmsg, and using the userspace functions klogctl()/syslog().
 
Old 11-03-2007, 03:16 PM   #17
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 78
Quote:
Originally Posted by dale_chip View Post
but when i did cp makefile Makefile
it compiled succesfully.
When dealing with external module building, a makefile is usually the best way to go. If for some reason all built-ins in the kernel tree are not built, it may not assume KBUILD_EXTMOD and will instead try to build the module by descending into your directory and using your makefile (this method is used on page 24 of this book). Whenever this is done by the kernel build system, all makefiles should be named “Makefile” (other names include “Kbuild”).

If, for some reason, you want to continue using the one-liner, try appending the target “modules” to the command.
 
Old 11-03-2007, 03:27 PM   #18
itz2000
Member
 
Registered: Jul 2005
Distribution: Fedora fc4, fc7, Mandrake 10.1, mandriva06, suse 9.1, Slackware 10.2, 11.0, 12.0,1,2 (Current)]
Posts: 732

Rep: Reputation: 30
Quote:
Originally Posted by sniffer_raghav View Post
#include<linux/module.h>
#include<linux/kernel.h>
#include<linux/init.h>
static int hello3_data __initdata = 3;
static int __init hello_3_init(void)
{
printk(KERN_INFO "Hello, world %d\n", hello3_data);
return 0;
}
static void __exit hello_3_exit(void)
{
printk(KERN_INFO "Goodbye, world 3\n");
}
module_init(hello_3_init);
module_exit(hello_3_exit);

sir i have successfully compiled the above code but problem is that
printk is not giving message on the terminal ......
y is it so sir explain ...........
thank you..........
After you do insmod check out the dmesg
Code:
insmod MODULE-NAME
dmesg
it should be appear on last line the (module_init function)
and if you do
Code:
rmmod MODULE-NAME
dmesg
you'll receive on the last line the other message which is the module_exit function.

I hope it will help.
 
Old 11-11-2007, 03:43 PM   #19
knockout_artist
Member
 
Registered: Sep 2005
Distribution: fedora core 9
Posts: 324

Rep: Reputation: 33
.


Already answered
 
Old 11-15-2007, 06:09 AM   #20
sixerjman
Member
 
Registered: Sep 2004
Distribution: Debian Testing / Unstable
Posts: 180
Blog Entries: 1

Rep: Reputation: 32
Try the "Linux Kernel Module Programming Guide"

http://tldp.org/LDP/lkmpg/2.6/html/index.html
 
Old 11-15-2007, 07:44 PM   #21
madluther
Member
 
Registered: Aug 2004
Distribution: LFS
Posts: 350

Rep: Reputation: 31
A very good resource for Kernel Programming is http://kernelnewbies.org/

Mad.
 
Old 11-26-2007, 12:39 AM   #22
ravi_chobey
Member
 
Registered: Sep 2007
Location: Bangalore,India
Distribution: Fedora,Mandriva,Debian
Posts: 180

Rep: Reputation: 30
Thumbs up

pls use this command you will be getting the dsired output:

dmesg -c
dmesg

Ravi
 
Old 12-12-2007, 04:12 AM   #23
Ashok_mittal
Member
 
Registered: Dec 2007
Posts: 73

Rep: Reputation: 15
Cool check /var/tmp/message

Quote:
Originally Posted by sniffer_raghav View Post
#include<linux/module.h>
#include<linux/kernel.h>
#include<linux/init.h>
static int hello3_data __initdata = 3;
static int __init hello_3_init(void)
{
printk(KERN_INFO "Hello, world %d\n", hello3_data);
return 0;
}
static void __exit hello_3_exit(void)
{
printk(KERN_INFO "Goodbye, world 3\n");
}
module_init(hello_3_init);
module_exit(hello_3_exit);

sir i have successfully compiled the above code but problem is that
printk is not giving message on the terminal ......
y is it so sir explain ...........
thank you..........
You can this in /var/tmp/message.for print message on terminal include linux/tty.h and then instead of printk write console_print(....).
 
  


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
Kernel module programming Error : module not found coolguy_iiit Programming 1 07-30-2006 07:23 AM
Kernel module programming lokutas Programming 2 04-27-2004 02:26 AM
Kernel Module Programming in 2.6 KneeLess Programming 3 04-13-2004 02:27 PM
Kernel Module programming Config Programming 2 03-24-2004 04:48 PM
Kernel Module Programming Thomas.P Programming 1 11-10-2001 10:23 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 09:53 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