Thread: LKM programming - using set_task_comm

  1. #1
    Registered User
    Join Date
    Mar 2012
    Posts
    3

    LKM programming - using set_task_comm

    Hi...

    I'm trying to compile the following code:

    mod.c
    Code:
    1. #include <linux/init.h>
    2. #include <linux/module.h>
    3. #include <linux/kernel.h>
    4. #include <linux/sched.h>
    5. int init_module(void)
    6. {
    7. struct task_struct *task;
    8. for_each_process(task) {
    9. printk("%s [%d] state: [%ld]\n", task->comm, task->pid, task->state);
    10. if ( strstr(task->comm, "leafpad") )
    11. set_task_comm(task, "leafpod");
    12. }
    13. return 0;
    14. }
    15. void cleanup_module(void)
    16. {
    17. printk(KERN_INFO "Exiting...\n");
    18. }

    Makefile:
    Code:
    obj-m += mod.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


    make output:
    Code:
    root@devil:/home/erick# make
    make -C /lib/modules/3.2.0-2-686-pae/build M=/home/erick modules
    make[1]: Entering directory `/usr/src/linux-headers-3.2.0-2-686-pae'
      Building modules, stage 2.
      MODPOST 1 modules
    WARNING: "set_task_comm" [/home/erick/mod.ko] undefined!
    make[1]: Leaving directory `/usr/src/linux-headers-3.2.0-2-686-pae'
    root@devil:/home/erick#


    Anyone knows what is happening?


    set_task_comm is in linux/sched.h


    Thank you.

  2. #2
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909
    When you copy-paste code from your IDE/editor, please do so as plain text, and let our forum do the line numbering, highlighting, etc.

    I'm far from an expert in this stuff, but notice on line 10 it's "leafpad" and on line 11 "leafpod". Is that it?

  3. #3
    Registered User
    Join Date
    Mar 2012
    Posts
    3
    Quote Originally Posted by anduril462 View Post
    I'm far from an expert in this stuff, but notice on line 10 it's "leafpad" and on line 11 "leafpod". Is that it?
    It's right...


    The problem is specifically with 'set_task_comm undefined'.



    []s

  4. #4
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909
    See if this helps at all: c++ - linux kernel module linker warnings: "*** Warning: <function> [<module>] undefined!" - any way to get rid of them? - Stack Overflow.

    EDIT: Or this: http://www.gossamer-threads.com/list...kernel/1369463. It looks like the get_task_comm (and presumably set_task_comm) kernel symbols may not be available for export. Not sure if this holds for your version of the kernel, since it's quite new.
    Last edited by anduril462; 03-26-2012 at 05:57 PM.

  5. #5
    Registered User
    Join Date
    Mar 2012
    Posts
    3
    Quote Originally Posted by anduril462 View Post
    See if this helps at all: c++ - linux kernel module linker warnings: "*** Warning: <function> [<module>] undefined!" - any way to get rid of them? - Stack Overflow.

    EDIT: Or this: [PATCH] export kernel call get_task_comm(). | Linux | Kernel. It looks like the get_task_comm (and presumably set_task_comm) kernel symbols may not be available for export. Not sure if this holds for your version of the kernel, since it's quite new.


    So.. i'm trying to use a function that is not available to me.


    I'll see what i can do.



    Thank you, anduril.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 12-11-2011, 04:25 PM
  2. Replies: 1
    Last Post: 08-19-2007, 03:55 AM
  3. small programming job VCPP / Object Oriented Programming
    By calgonite in forum Projects and Job Recruitment
    Replies: 10
    Last Post: 01-04-2006, 11:48 PM
  4. Total newb to programming here... Question about the many programming languages. Ty!
    By tsubotakid1 in forum A Brief History of Cprogramming.com
    Replies: 11
    Last Post: 10-05-2003, 10:32 AM