Thread: Kernel Hacking Issue

  1. #1
    Registered User
    Join Date
    Nov 2007

    Kernel Hacking Issue

    I recently added a printk statement to my timer.c file in /usr/src/linux-source-2-6-27/ so that each time SYS_GETPID was called I would have this printed out to my console and to my /var/log/messages file. However, when I create a simple program which uses getpid() and run it I neither get anything printed to the console nor to the messages file. The code for SYS_GETPID I put in is as follows:

    asmlinkage long sys_getpid(void)
    	printk(KERN_CRIT, "SYS_GETPID CALLED...\n");
    	return task_tgid_vnr(current);
    I recompiled my kernel and installed it again but am not sure why this isn't working.

    Also, I just loaded a custom hello world module into the kernel successfully using the insmod function but this was not recorded to my /var/log/messages file. Is there another location in Ubuntu where this file is loaded?

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Farncombe, Surrey, England
    Why don't you do one of the following:
    1. cause a compiler error in you code (e.g. add dashsdhkfasjdjkasd78eq3 to somewhere in the code), to ensure that you are ACTUALLY compiling the source you think you are compiling.
    2. If that works, add somehting that crashes the kernel when you get to a certain point (e.g getpid) - just make sure you have a back-up kernel that you can load if this happens [this is of course true whether you are intentionally causing the kernel to crash or not - becuase no matter how good you are, sooner or later you will make a mistake that causes the kernel to crash on startup, and this is when you need another kernel available to boot from].

    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. SOS - Can a monolithic kernel be used in a micro-kernel style OS?
    By sean in forum A Brief History of
    Replies: 7
    Last Post: 11-20-2008, 09:30 AM
  2. kernel hacking, plz help
    By micke_b in forum Linux Programming
    Replies: 8
    Last Post: 02-18-2008, 04:49 PM
  3. more kernel hacking, the check_preempt_curr_rt() func
    By micke_b in forum Linux Programming
    Replies: 2
    Last Post: 02-18-2008, 11:03 AM
  4. CreateThread ?!
    By Devil Panther in forum Windows Programming
    Replies: 13
    Last Post: 11-15-2005, 10:55 AM
  5. Kernel hacking
    By Spark in forum C Programming
    Replies: 7
    Last Post: 06-20-2002, 08:40 PM