Re: Module programming - Basic query !

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

 




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

   /* remover.c    ............ not proc1.c */

>
> > 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 named  proc1 */
> >           {
> >        temp->uc.usecount=zero;
> >            return 0;
> >       }
> >    temp = temp->next;
> >       }
> > return 0;
> > }
>
> This code is a bug. Expect kernel to crash promptly.
> Note: THIS_MODULE is guaranteed to be the module structure for your
> module, so the while is redundant.
>
>
> Amith>  sorry i forgot to mention this is another module called remover.c which
> gets the usecount of whichever module u think u want to rmmod, to zero.It as it
> is evident runs thru the module list starting from its own struct module till it
> finds the module whose usecount needs to be set to zero.

> ( insmod remover.o ) after this proc1 was rmmod'ed.- But no other modules wud be
> using my symbols iam sure abt that :-) .

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