LinuxQuestions.org
Visit the LQ Articles and Editorials section
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
 
LinkBack Search this Thread
Old 10-03-2009, 03:55 PM   #1
wizumwalt
LQ Newbie
 
Registered: Jan 2009
Posts: 11

Rep: Reputation: 0
printk() not outputting


For some reason, my printk()'s aren't putting anything out to my /var/log/messages file. I am running X so, as I understand it, messages won't appear in the terminals where I insmod() the module. But they should appear in /var/log/messages.

If I load my test module, I do get a message from /var/log/messages saying ....

Code:
Oct  3 14:50:04 Tux sudo:   whisper : TTY=pts/12 ; PWD=/home/whisper/test-mod/kernel/net/tm ; USER=root ; COMMAND=/sbin/insmod tm.ko
I've placed printk()'s in module_init func with KERN_INFO, and KERN_CRIT, and still don't see anything. I do see that w/ lsmod, my module is loaded.

Any ideas?
 
Old 10-04-2009, 09:38 AM   #2
estabroo
Senior Member
 
Registered: Jun 2008
Distribution: debian, ubuntu, sidux
Posts: 1,051
Blog Entries: 2

Rep: Reputation: 93
How are you loading your module? If you are using modprobe, are you putting your re-compiled module in the correct place and doing a depmod -a to rebuild the dependency file? What does your printk() look like, are you putting a \n at the end of the string, if not then it won't show up until later and it'll be mixed in with other messages.
 
Old 10-04-2009, 01:38 PM   #3
wizumwalt
LQ Newbie
 
Registered: Jan 2009
Posts: 11

Original Poster
Rep: Reputation: 0
I've got it down to as simple as this ...
Code:
 
static int __init my_init(void) {
    printk(KERN_INFO "my_init ...\n");

    // ...

    return 0;
}                                                             

static void __exit my_exit(void) {
    printk(KERN_INFO "my_exit ...\n");
}
 
Old 10-05-2009, 08:03 PM   #4
yaplej
Member
 
Registered: Apr 2009
Distribution: CentOS, Ubuntu
Posts: 116
Blog Entries: 1

Rep: Reputation: 22
I could not get "KERN_INFO" to work either. Try "KERN_ALERT", and see if it works.
 
Old 10-05-2009, 09:03 PM   #5
wizumwalt
LQ Newbie
 
Registered: Jan 2009
Posts: 11

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by yaplej View Post
I could not get "KERN_INFO" to work either. Try "KERN_ALERT", and see if it works.
Nope

Also, the values in my /proc/sys/kernel/printk file are:
1 4 1 7

So I changed the first value to 7, and I still didn't see messages in my /var/log/messages file, nor using dmesg.

Last edited by wizumwalt; 10-05-2009 at 10:58 PM.
 
Old 10-06-2009, 11:59 AM   #6
estabroo
Senior Member
 
Registered: Jun 2008
Distribution: debian, ubuntu, sidux
Posts: 1,051
Blog Entries: 2

Rep: Reputation: 93
are you sure your loading a current version of your module?
 
Old 10-06-2009, 09:57 PM   #7
wizumwalt
LQ Newbie
 
Registered: Jan 2009
Posts: 11

Original Poster
Rep: Reputation: 0
What else can you do to get your current module besides this ...

[code]
make
depmod -a
sudo insmod ./mymod.ko
[code]

Did you intend something other than './'?
 
Old 10-07-2009, 12:42 AM   #8
estabroo
Senior Member
 
Registered: Jun 2008
Distribution: debian, ubuntu, sidux
Posts: 1,051
Blog Entries: 2

Rep: Reputation: 93
Did you rmmod the old module before doing your insmod?
 
Old 10-07-2009, 07:20 PM   #9
wizumwalt
LQ Newbie
 
Registered: Jan 2009
Posts: 11

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by estabroo View Post
Did you rmmod the old module before doing your insmod?
Heh, yeah, I know that much. But still a no go for some reason. I don't understand this.

Last edited by wizumwalt; 10-07-2009 at 07:26 PM.
 
Old 10-08-2009, 08:02 PM   #10
estabroo
Senior Member
 
Registered: Jun 2008
Distribution: debian, ubuntu, sidux
Posts: 1,051
Blog Entries: 2

Rep: Reputation: 93
try KERN_WARN or KERN_CRIT, you can also check your syslog configuration, maybe its directly lower level stuff elsewhere
 
Old 10-09-2009, 12:04 PM   #11
wizumwalt
LQ Newbie
 
Registered: Jan 2009
Posts: 11

Original Poster
Rep: Reputation: 0
Yeah, tried those already, and the syslog-ng.conf file looks fine.
 
Old 11-19-2009, 04:01 AM   #12
Anisha Kaul
Senior Member
 
Registered: Dec 2008
Location: Gurgaon, India
Distribution: Slackware 13.1, OpenSuse 11.2
Posts: 4,202
Blog Entries: 14

Rep: Reputation: 625Reputation: 625Reputation: 625Reputation: 625Reputation: 625Reputation: 625
If you do not trust KERN_WARN, KERN_INFO or KERN_CRIT or anything similar to work properly, you can and should use printk without any of these,

i.e.
printk ("\nthank god\n");

Meanwhile can u show the exact code of your whole module !

Last edited by Anisha Kaul; 11-19-2009 at 04:04 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
printk(KERN_DEBUG ...) vs printk(...) Sergei Lavrov Linux - Kernel 2 03-25-2007 05:41 PM
Outputting to TV TurboChicken Linux - Hardware 10 03-05-2006 02:30 PM
outputting video to my tv aw76 Linux - General 1 12-20-2005 03:16 PM
trouble outputting to TV tradnbillies Linux - Hardware 0 10-09-2005 05:19 PM
Outputting from syslog... Alstare Slackware 0 11-27-2004 11:12 PM


All times are GMT -5. The time now is 08:57 AM.

Main Menu
 
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
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration