Find the answer to your Linux question:
Results 1 to 7 of 7
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 ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    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#

  2. #2
    Linux Enthusiast gerard4143's Avatar
    Join Date
    Dec 2007
    Location
    Canada, Prince Edward Island
    Posts
    714
    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

  3. #3
    Just Joined!
    Join Date
    Jan 2009
    Posts
    8
    No, I'm inserting it right on the box I'm compiling it on.

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Enthusiast gerard4143's Avatar
    Join Date
    Dec 2007
    Location
    Canada, Prince Edward Island
    Posts
    714
    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...

  6. #5
    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

  7. #6
    Linux Enthusiast gerard4143's Avatar
    Join Date
    Dec 2007
    Location
    Canada, Prince Edward Island
    Posts
    714
    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

  8. #7
    Just Joined!
    Join Date
    Jan 2009
    Location
    Bangalore
    Posts
    15

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •