Results 1 to 5 of 5

Thread: Error while performing insmod for my first kernel programme

  1. #1
    Join Date
    May 2013
    Beans
    48

    Error while performing insmod for my first kernel programme

    root@rahul-VPCEG28FN:/home/rahul/modules# insmod mod_first.ko
    insmod: error inserting 'mod_first.ko': -1 File exists

  2. #2
    Join Date
    Jun 2007
    Location
    Maryland, US
    Beans
    6,264
    Distro
    Kubuntu

    Re: Error while performing insmod for my first kernel programme

    Undoubtedly you have already inserted (loaded) the kernel module in a previous attempt. Now, when you attempt to load it again, you get the error "File exists".

    Try unloading the module before attempting to load it again.
    Code:
    $ sudo rmmod mod_first
    
    $ sudo insmod mod_first.ko

  3. #3
    Join Date
    May 2013
    Beans
    48

    Post Error while performing insmod for my first kernel programme

    Hi all,

    Today I started with my first kernel programming and got an error while executing the command "insmod mod_first.ko"
    Below is the error message:

    root@rahul-VPCEG28FN:/home/rahul/modules# insmod mod_first.ko
    insmod: error inserting 'mod_first.ko': -1 File exists


    I am also providing my "mod_first.c" file:

    #include<linux/module.h>
    #include<linux/init.h>

    MODULE_AUTHOR("Rahul");
    MODULE_DESCRIPTION("My first kernel module");

    int mod_init(void)
    {
    printk("\nModule init\n");
    return 0;
    }

    void mod_exit(void)
    {
    printk("\nModule exit\n");
    }
    module_init(mod_init);
    module_exit(mod_exit);

    Following is my makefile:

    obj-m:=mod_first.o

    KDIR=/lib/modules/$(shell uname -r)/build

    all:
    make -C $(KDIR) M=$(PWD) modules
    clean:
    rm -rf *.o *.ko *.mod.*



    Please tell me what to be done in oorder to remove the error.
    I am very keen/enthusiast to know all these kernel programming.

    Regards,

  4. #4
    Join Date
    Jul 2007
    Location
    Magic City of the Plains
    Beans
    Hidden!
    Distro
    Xubuntu 15.10 Wily Werewolf

    Re: Error while performing insmod for my first kernel programme

    Threads merged. Please do not create multiple threads for the same or similar questions.

  5. #5
    Join Date
    May 2013
    Beans
    48

    Re: Error while performing insmod for my first kernel programme

    Hey thanks! I got it and now working fine..

Bookmarks

Posting Permissions

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