Find the answer to your Linux question:
Results 1 to 6 of 6

Thread: Kernel Module

Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Smile Kernel Module

    Hello everyone,
    I am writing a very simple kernel module that is available on the net.
    But while compiling it I am getting the error for include files.

    Can anyone please tell me what is the procedure for include files for kernel modules.

    It would be really helpful if I get an example or a link I can get to learn about include files and kernel module programming starting from basics.

  2. #2


    The Module I got only have printk in the init_module() and that in cleanup_module().

    It has a include file named uaccess.h
    It is not getting this file.
    I dont know where exactly the kernel module needs its include files.
    Is there any specific location.

    I am compiling it using gcc.
    and then using a Makefile for making a .ko .
    Which I suppose then will be inserted as a module using "insmod"
    and removed using "rmmod"

    If there is any other way to do it please tell me.

    I am reading Linux Kernel Module Programming .pdf O'reilly 2nd edition.

  3. #3
    the code looks something like this
    I dont know why it requires that uaccess.h

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

    int init_module(void)
    printk(KERN_INFO "init_module() called\n");
    return 0;

    void cleanup_module(void)
    printk(KERN_INFO "cleanup_module() called\n");

    I tried to locate uaccess.h but not in linux named folder

    Makefile looks like this

    obj-m += hello.o

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

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

  4. $spacer_open
  5. #4
    Linux Enthusiast gerard4143's Avatar
    Join Date
    Dec 2007
    Canada, Prince Edward Island
    Could you please use code tags so that we can see if the formating of your make file is correct..

    Also if you open a terminal and su root and type

    cd /lib/modules/$(uname -r)/build

    What do you get?
    Make mine Arch Linux

  6. #5
    Do you have the linux source in the given folder ?????

  7. #6
    Just Joined! saurabh.nigam's Avatar
    Join Date
    Sep 2008
    here is the MAkefile example(pls notice the usage of tab if you have provided 8 spaces that would be wrong)
    obj-m += usb-skeleton.o
    <tab>make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
    <tab>make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
    save it & then run
    try compiling your code without writing include<uaccess.h> line this could be a user defined header by the author

Posting Permissions

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