Welcome to Linux Forums! With a comprehensive Linux Forum, information on various types of Linux software and many Linux Reviews articles, we have all the knowledge you need a click away, or accessible via our knowledgeable members.
Write an article for LinuxForums Today! Win Great Prizes!
Find the answer to your Linux question:
New to Linux Forums? Register here for free!
    Linux Forums > GNU Linux Zone > The Linux Kernel > Where are my printk messages?

Forgot Password?
 The Linux Kernel   Compiling, theory, programming or other discussion about the linux kernel

Site Navigation
Linux Articles
Linux Forums
Linux Downloads
Linux Hosting
Free Magazines
Job Board
IRC Chat
RSS Feeds
Linux Forum Topics
Linux Forums
Your Distro
Linux Resources
GNU Linux Zone
The Community
Reply
 
Thread Tools Display Modes
Old 02-01-2009   #1 (permalink)
Just Joined!
 
Join Date: Jan 2009
Posts: 8
Where are my printk messages?

I'm using Slack 8.1 and succesfully compiled the helloworld module.

I can load the module with insmod, I can then see it loaded with lsmod and I can unload it with rmmod.

However, I never see my printk messages anywhere.
I tried doing a cat of /var/log/messages and /var/log/syslog but don't see my output.

I'm doing all this work via ssh if that makes any diference.

Chris

root@slack-8-1:/usr/src/hellomod# cat hello.c
#define MODULE
#define LINUX
#define __KERNEL__
#include <linux/module.h>
#include <linux/kernel.h>
MODULE_LICENSE("Dual BSD/GPL");

static int hello_init(void){
printk("<1> Hello Mod Init!\n");
return 0;
}

static void hello_exit(void){
printk(KERN_WARNING "Hello Mod Exit!\n");
}

module_init(hello_init);
module_exit(hello_exit);
root@slack-8-1:/usr/src/hellomod#
root@slack-8-1:/usr/src/hellomod# lsmod
Module Size Used by Not tainted
pcmcia_core 40896 0
ide-scsi 7456 0
eepro100 17264 1
root@slack-8-1:/usr/src/hellomod# insmod hello.o
root@slack-8-1:/usr/src/hellomod# lsmod
Module Size Used by Not tainted
hello 336 0 (unused)
pcmcia_core 40896 0
ide-scsi 7456 0
eepro100 17264 1
root@slack-8-1:/usr/src/hellomod# rmmod hello
root@slack-8-1:/usr/src/hellomod# ls mod
/bin/ls: mod: No such file or directory
root@slack-8-1:/usr/src/hellomod# lsmod
Module Size Used by Not tainted
pcmcia_core 40896 0
ide-scsi 7456 0
eepro100 17264 1
root@slack-8-1:/usr/src/hellomod#
chris123 is offline  



Reply With Quote
Old 02-02-2009   #2 (permalink)
Linux Enthusiast
 
gerard4143's Avatar
 
Join Date: Dec 2007
Location: Canada, Prince Edward Island
Posts: 618
Are you inserting this "hello world" module into a remote kernel? If you are then the printk results are probably on the remote machine...Hope this Helps Gerard4143

Welcome to the forums
gerard4143 is offline   Reply With Quote
Old 02-02-2009   #3 (permalink)
Just Joined!
 
Join Date: Jan 2009
Posts: 8
No, I'm inserting it right on the box I'm compiling it on.
chris123 is offline   Reply With Quote
Old 02-02-2009   #4 (permalink)
Linux Enthusiast
 
gerard4143's Avatar
 
Join Date: Dec 2007
Location: Canada, Prince Edward Island
Posts: 618
Quote:
Originally Posted by chris123 View Post
I'm doing all this work via ssh if that makes any diference.
If your compiling and inserting on a local machine...why are you using ssh...
gerard4143 is offline   Reply With Quote
Old 02-02-2009   #5 (permalink)
Just Joined!
 
Join Date: Jan 2009
Posts: 8
Becuase my wife demands I sit in the front room with her while she watches TV, but that's a whole other story.

Anyway, I just tried it right from the console and I still don't see them.

Chris
chris123 is offline   Reply With Quote
Old 02-02-2009   #6 (permalink)
Linux Enthusiast
 
gerard4143's Avatar
 
Join Date: Dec 2007
Location: Canada, Prince Edward Island
Posts: 618
I tried compiling your Hello world module and it worked...the message(s) appeared in the /var/log/messages file...kernel - 2.6.27.7-9-default x86_64 GNU/Linux

Code:
//#define MODULE
//#define LINUX
//#define __KERNEL__

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

MODULE_LICENSE("Dual BSD/GPL");

static int hello_init(void)
{
	printk("<1> Hello Mod Init!\n");
	return 0;
}

static void hello_exit(void)
{
	printk(KERN_WARNING "Hello Mod Exit!\n");
}

module_init(hello_init);
module_exit(hello_exit);
Makefile

Code:
obj-m += test.o

all:
	make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules

clean:
	make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
gerard4143 is offline   Reply With Quote
Old 02-12-2009   #7 (permalink)
Just Joined!
 
Join Date: Jan 2009
Location: Bangalore
Posts: 14
Where are my printk messages?

Hi

you printk messages will be in /var/log/messages/dmesg

or just type

dmesg
at the end you will see you printk message
umeshkmahindrakar is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

Free Magazines
A Newbie's Getting Started Guide to Linux
Learn the basics of the Linux operating systems. Get to know what it is all about, and familiarize yourself with the practical side. Basically, if you're a complete Linux newbie and looking for a quick and easy guide to get you started this is it.
subscribe
Run Your Own Web Server Using Linux & Apache - Free 191 Page Preview
Learn about everything you'll need to build and maintain your Linux servers, and to deploy Web applications to them.
subscribe
Open Source Security Myths Dispelled
Dispel the five major myths surrounding Open Source Security and gain the tools necessary to make a truly informed decision for your IT organization
subscribe
InformationWeek
InformationWeek is the only newsweekly you'll need to stay on top of the latest developments in information technology.
subscribe



All times are GMT. The time now is 11:44 AM.






© 2000 - - All Rights Reserved - Property of  MAS Media

Content Relevant URLs by vBSEO 3.3.1