LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 08-19-2011, 09:18 PM   #1
mei0fei
Member
 
Registered: Jul 2011
Posts: 38

Rep: Reputation: Disabled
where is hello world?


I am doing some example code for modules:

/*
* hello-3.c - Illustrating the __init, __initdata and __exit macros.
*/
#include <linux/module.h> /* Needed by all modules */
#include <linux/kernel.h> /* Needed for KERN_INFO */
#include <linux/init.h> /* Needed for the macros */

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);

and I add this module in kernel:

mei@ubuntu:~/module$ sudo insmod hello-3.ko
mei@ubuntu:~/module$ cat /proc/modules |grep hello
hello_3 12395 0 - Live 0x00000000 (P)
mei@ubuntu:~/module$ sudo rmmod hello-3.ko
mei@ubuntu:~/module$

no "Hello, world 3" print out.
no "Goodbye, world 3" print out.

and I can't find KERN_INFO in kernel.h
 
Old 08-20-2011, 01:54 AM   #2
bsat
Member
 
Registered: Feb 2009
Posts: 347

Rep: Reputation: 72
run the command "dmesg" to see the output. These prints go to the kernel logs and are not visible on the terminal when you are in the graphical mode.
 
1 members found this post helpful.
Old 08-20-2011, 01:57 AM   #3
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
KERN_INFO is in printk.h. Grepping for KERN_INFO in the headers in the include/linux directory would have told you that. Also, you should really post code within [code] tags, to preserve indentation and improve readability.
 
2 members found this post helpful.
  


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
World of warcraft for Linux.(This is a forum for people who want world of warcraft..) darkstarbyte Linux - Games 17 09-05-2011 02:30 AM
Hello World! zeroquaranta LinuxQuestions.org Member Intro 1 02-18-2010 12:12 PM
Hello, World mbwhitley LinuxQuestions.org Member Intro 5 02-18-2010 08:58 AM
Hello from all over the world :-) endorphin LinuxQuestions.org Member Intro 1 02-03-2010 02:00 AM
world writeable files will not stay world writeable antken Mandriva 1 03-02-2004 05:04 PM

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

All times are GMT -5. The time now is 03:05 PM.

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