kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
* non-static init in a basic kernel module
@ 2014-06-09  7:28 Warren Turkal
  2014-06-11 13:29 ` Greg KH
  2014-06-16 10:29 ` sanjeev sharma
  0 siblings, 2 replies; 5+ messages in thread
From: Warren Turkal @ 2014-06-09  7:28 UTC (permalink / raw)
  To: kernelnewbies

Hey,

I was writing a basic hello world module. I am using Ubuntu, so I 
installed linux-headers package that corresponded to my kernel. It's 
strange because all of the examples that I saw (including from modules 
in the kernel itself) show things like the following for the init function:

static int netcat_init(void)
{
     ...
     return 0;
}

module_init(netcat_init);

However, I was not able to get it to work with "static". My 
hello_world_init function looks like the following:

int __init hello_world_init(void)
{
     ...
     return 0;
}

module_init(hello_world_init);

The command that is used to make the kernel module is the one suggested 
in Documentation/kbuild/modules.txt. It looks like this:
make -C /lib/modules/`uname -r`/build M=$PWD

Does anyone know why the "static" version would not work?

Thanks,
wt

^ permalink raw reply	[flat|nested] 5+ messages in thread

* non-static init in a basic kernel module
@ 2014-06-09 16:44 Warren Turkal
  2014-06-09 16:49 ` Pranay Srivastava
  0 siblings, 1 reply; 5+ messages in thread
From: Warren Turkal @ 2014-06-09 16:44 UTC (permalink / raw)
  To: kernelnewbies

Hey,

I was writing a basic hello world module. I am using Ubuntu, so I 
installed linux-headers package that corresponded to my kernel. It's 
strange because all of the examples that I saw (including from modules 
in the kernel itself) show things like the following for the init function:

static int netcat_init(void)
{
     ...
     return 0;
}

module_init(netcat_init);

However, I was not able to get it to work with "static". My 
hello_world_init function looks like the following:

int __init hello_world_init(void)
{
     ...
     return 0;
}

module_init(hello_world_init);

The command that is used to make the kernel module is the one suggested 
in Documentation/kbuild/modules.txt. It looks like this:
make -C /lib/modules/`uname -r`/build M=$PWD

Does anyone know why the "static" version would not work?

Thanks,
wt

^ permalink raw reply	[flat|nested] 5+ messages in thread

* non-static init in a basic kernel module
  2014-06-09 16:44 Warren Turkal
@ 2014-06-09 16:49 ` Pranay Srivastava
  0 siblings, 0 replies; 5+ messages in thread
From: Pranay Srivastava @ 2014-06-09 16:49 UTC (permalink / raw)
  To: kernelnewbies

On Jun 9, 2014 10:15 PM, "Warren Turkal" <wt@penguintechs.org> wrote:
>
> Hey,
>
> I was writing a basic hello world module. I am using Ubuntu, so I
> installed linux-headers package that corresponded to my kernel. It's
> strange because all of the examples that I saw (including from modules
> in the kernel itself) show things like the following for the init
function:
>
> static int netcat_init(void)
> {
>      ...
>      return 0;
> }
>
> module_init(netcat_init);
>
> However, I was not able to get it to work with "static". My
> hello_world_init function looks like the following:

can you post the error you got?

>
> int __init hello_world_init(void)
> {
>      ...
>      return 0;
> }
>
> module_init(hello_world_init);
>
> The command that is used to make the kernel module is the one suggested
> in Documentation/kbuild/modules.txt. It looks like this:
> make -C /lib/modules/`uname -r`/build M=$PWD
>
> Does anyone know why the "static" version would not work?
>
> Thanks,
> wt
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20140609/5c5dcf07/attachment.html 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* non-static init in a basic kernel module
  2014-06-09  7:28 non-static init in a basic kernel module Warren Turkal
@ 2014-06-11 13:29 ` Greg KH
  2014-06-16 10:29 ` sanjeev sharma
  1 sibling, 0 replies; 5+ messages in thread
From: Greg KH @ 2014-06-11 13:29 UTC (permalink / raw)
  To: kernelnewbies

On Mon, Jun 09, 2014 at 12:28:13AM -0700, Warren Turkal wrote:
> Hey,
> 
> I was writing a basic hello world module. I am using Ubuntu, so I 
> installed linux-headers package that corresponded to my kernel. It's 
> strange because all of the examples that I saw (including from modules 
> in the kernel itself) show things like the following for the init function:
> 
> static int netcat_init(void)
> {
>      ...
>      return 0;
> }
> 
> module_init(netcat_init);
> 
> However, I was not able to get it to work with "static". My 
> hello_world_init function looks like the following:
> 
> int __init hello_world_init(void)
> {
>      ...
>      return 0;
> }
> 
> module_init(hello_world_init);
> 
> The command that is used to make the kernel module is the one suggested 
> in Documentation/kbuild/modules.txt. It looks like this:
> make -C /lib/modules/`uname -r`/build M=$PWD
> 
> Does anyone know why the "static" version would not work?

What exactly were the errors you got?

^ permalink raw reply	[flat|nested] 5+ messages in thread

* non-static init in a basic kernel module
  2014-06-09  7:28 non-static init in a basic kernel module Warren Turkal
  2014-06-11 13:29 ` Greg KH
@ 2014-06-16 10:29 ` sanjeev sharma
  1 sibling, 0 replies; 5+ messages in thread
From: sanjeev sharma @ 2014-06-16 10:29 UTC (permalink / raw)
  To: kernelnewbies

Hi,

To prevent namespace pollution static is being used but this problem
is nothing to do with static and you should share Error Logs to know
exact problem also pointed by Greg.

Regards
Sanjeev Sharma


On Mon, Jun 9, 2014 at 12:58 PM, Warren Turkal <wt@penguintechs.org> wrote:
> Hey,
>
> I was writing a basic hello world module. I am using Ubuntu, so I
> installed linux-headers package that corresponded to my kernel. It's
> strange because all of the examples that I saw (including from modules
> in the kernel itself) show things like the following for the init function:
>
> static int netcat_init(void)
> {
>      ...
>      return 0;
> }
>
> module_init(netcat_init);
>
> However, I was not able to get it to work with "static". My
> hello_world_init function looks like the following:
>
> int __init hello_world_init(void)
> {
>      ...
>      return 0;
> }
>
> module_init(hello_world_init);
>
> The command that is used to make the kernel module is the one suggested
> in Documentation/kbuild/modules.txt. It looks like this:
> make -C /lib/modules/`uname -r`/build M=$PWD
>
> Does anyone know why the "static" version would not work?
>
> Thanks,
> wt
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-06-16 10:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-09  7:28 non-static init in a basic kernel module Warren Turkal
2014-06-11 13:29 ` Greg KH
2014-06-16 10:29 ` sanjeev sharma
  -- strict thread matches above, loose matches on Subject: below --
2014-06-09 16:44 Warren Turkal
2014-06-09 16:49 ` Pranay Srivastava

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).