Re: Simple Hello World error




elliotng.ee@xxxxxxxxx wrote:

Hey everyone,

I am running Linux kernel 2.6.17.8 with ubuntu.

I wrote a simple HelloWorld program, and it is not displaying the init
call on /var/log/kern.log

Here's the hello.c file:
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>

MODULE_LICENSE("Dual BSD/GPL");

static int __init hello_init(void)
{
printk(KERN_ALERT "Hello, world\n");
return 0;
}

static void __exit hello_exit(void)
{
printk(KERN_ALERT "Goodbye, cruel world\n");
}

module_init(hello_init);
module_exit(hello_exit);


Here's the Makefile:
# If KERNELRELEASE is defined, we've been invoked from the
# kernel build system and can use its language

ifneq ($(KERNELRELEASE),)
obj-m := HelloWorld.o

# Otherwise we were called directly from the command
# line , invoke the kernel build system.
else
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)

default:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules

endif

----
sudo insmod ./hello.ko will not display anything in the log
sudo rmmod hello will display the exit statement

It seems your klogd is having problem
Are you able to see other messages in /var/log/kern.log. Check your
/etc/syslog.conf for whether all kern.* messages are sent to
/var/log/kern.log.

Check also wheather its running "/etc/init.d/klogd status"

.



Relevant Pages

  • (usb/bluez/alsa) 2.6.25-rc8 BUG: unable to handle kernel paging request
    ... unable to handle kernel NULL pointer dereference at ... PCI/AGP VGA Display Adapter ... # Infrared-port device drivers ...
    (Linux-Kernel)
  • Re: Two FC7 questions
    ... or to never remove an old kernel. ... display for the motor home. ... map so the direction your moving is up, ... I have used roadnav with a smaller display when when using a GPS, ...
    (Fedora)
  • Re: OpenGL-based framebuffer concepts
    ... The kernel subsystem should be agnostic of the display server. ... you don't want to lose your console in the middle of trying ...
    (Linux-Kernel)
  • Re: Panic on 5.1-RELEASE with ahc
    ... > All the hardware seems to be detected okay, and I've rebuilt a kernel ... > kernel too ISTR) is that on shutting down, I consistently get a panic, ... > RAM parity error, likely hardware failure. ... > This also causes the Hardware LCD display on the front to display "E13F5 ...
    (freebsd-current)
  • Re: Two FC7 questions
    ... or to never remove an old kernel. ... A heads up display would be nice, ... I have used roadnav with a smaller display when when using a GPS, ... having "map tracks GPS" set. ...
    (Fedora)