sys_create_module...

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

 



Hi,
I am trying to debug some code I have written. I could not understand some
code in the kernel.
function sys_create_module() in module.c
As far as I understand the functionality is as follows.

in this mod is defined as a struct module *.
checks the user is capable of loading the module.
locks the kernel.
the module name is taken from userspace into the variable 'name', defined
locally. 
memset the vmalloc-ed (module_map) pointer with zeros.
set the size_of_struct to size of the module structure.
Next statement 
mod->name = (char *) (mod + 1) ; puzzles me.
what does this statement do?
if my knowledge of C is corrrect, since mod is a pointer of type struct module
, mod+1 will point to ((void *) &mod)+(sizeof (*mod)), which is an invalid
pointer here.
Then how does this piece of code work?
any idea?

Thanks,
Om.



------------------------------------------------------
"why shall I be afraid now? strange men have always
come to kill me ever since I was twelve years of age"
-- vito corleone, The godfather.
--
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