Module programming - Basic query !

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all,
        Some more module related queries .

1)
i found this declaration - extern struct module *module_list;
(or is it a definition i'am always confused :-) ) in module.h . Now
when i include <linux/module.h> this symbol would be part of my
module . i checked "cat /proc/ksyms | grep "module_list" and
didnt find it in /proc/ksyms.My question is is it ok to have an
extern declaration if doesnt exist at all or if it isnt referenced in my program ?
when i insmoded my module "insmod proc1.o" there were no errors so i assume it is ok .
if no please let me know when it is not ok .



2) My usecount somehow went up and i couldnt rmmod my module so i did this :

int
init_module(void)
{
struct module *temp = THIS_MODULE;
atomic_t zero;
zero.counter = 0;
while(temp) {
if(strcmp(temp->name,"proc1")==0) /* my module was name proc1.o */
{ temp->uc.usecount=zero;
return 0;
}
temp = temp->next;
}
return 0;
}


THIS_MODULE i found was #define THIS_MODULE    (&__this_module)
Now, how does this (i.e &__this_module) finally point to my modules
struct module ? How is this done ?


cheers, Amith


-- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux